环境:
我只是通过使用基本类和表启动项目来获取此错误。 连接详细信息适用于Web服务器中的测试。
在Wildfly 10中使用javax.persistence.EntityListeners时出错。
错误日志
test00:10:10,328 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 72) MSC000001: Failed to start service jboss.persistenceunit."test.war#testPU": org.jboss.msc.service.StartException in service jboss.persistenceunit."test.war#testPU": javax.persistence.PersistenceException: [PersistenceUnit: testPU] Unable to build Hibernate SessionFactory
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:179)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:121)
at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:667)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:193)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: testPU] Unable to build Hibernate SessionFactory
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:954)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:882)
at org.jboss.as.jpa.hibernate5.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:161)
... 7 more
Caused by: org.jboss.weld.exceptions.IllegalArgumentException: WELD-001456: Argument resolvedBean must not be null
at org.jboss.weld.util.Preconditions.checkArgumentNotNull(Preconditions.java:40)
at org.jboss.weld.manager.BeanManagerImpl.getInjectableReference(BeanManagerImpl.java:794)
at org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:92)
at org.jboss.weld.util.Beans.injectBoundFields(Beans.java:364)
at org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:375)
at org.jboss.weld.injection.producer.ResourceInjector$1.proceed(ResourceInjector.java:70)
at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:48)
at org.jboss.weld.injection.producer.ResourceInjector.inject(ResourceInjector.java:72)
at org.jboss.weld.injection.producer.BasicInjectionTarget.inject(BasicInjectionTarget.java:121)
at org.hibernate.jpa.event.internal.jpa.ListenerFactoryBeanManagerStandardImpl$ListenerImpl.<init>(ListenerFactoryBeanManagerStandardImpl.java:84)
at org.hibernate.jpa.event.internal.jpa.ListenerFactoryBeanManagerStandardImpl$ListenerImpl.<init>(ListenerFactoryBeanManagerStandardImpl.java:73)
at org.hibernate.jpa.event.internal.jpa.ListenerFactoryBeanManagerStandardImpl.buildListener(ListenerFactoryBeanManagerStandardImpl.java:59)
at org.hibernate.jpa.event.internal.jpa.CallbackBuilderLegacyImpl.resolveCallbacks(CallbackBuilderLegacyImpl.java:170)
at org.hibernate.jpa.event.internal.jpa.CallbackBuilderLegacyImpl.buildCallbacksForEntity(CallbackBuilderLegacyImpl.java:69)
at org.hibernate.jpa.event.spi.JpaIntegrator.integrate(JpaIntegrator.java:136)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:278)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:879)
... 9 more
的persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="testPU" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<class>es.roscam.light.business.reminders.entity.ToDo</class>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/roscam"/>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>
</properties>
</persistence-unit>
</persistence>
Todo.java
@Entity(name = "ToDo")
@NamedQuery(name = ToDo.findAll, query = "SELECT t FROM ToDo t")
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@EntityListeners(ToDoAuditor.class)
public class ToDo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
static final String PREFIX = "reminders.entity.ToDo.";
public static final String findAll = PREFIX + "findAll";
@NotNull
@Size(min = 2, max = 256)
private String caption;
private String description;
private int priority;
private boolean done;
@Version
private long version;
...
ToDoManager.java
@Stateless
public class ToDoManager {
@PersistenceContext
EntityManager em;
public ToDo findById(long id) {
return this.em.find(ToDo.class, id);
}
...
答案 0 :(得分:0)
问题是@EntityListeners。 我尝试使用payara并且效果很好,所以它应该是服务器wildfly的一个问题。
我评论了这一行,服务器成功加载!