gpt4 book ai didi

java - 注入(inject)EntityListener

转载 作者:行者123 更新时间:2023-12-02 12:37:24 25 4
gpt4 key购买 nike

当我尝试启动服务器 JBoss 7.0 时遇到问题,因为抛出错误。当将entityListiner放在Entity上时会发生这种情况。

是否可以注入(inject)实体监听器?

跟踪:

MSC000001: Failed to start service jboss.persistenceunit."pagos-0.8.105.war#pagos_PU": org.jboss.msc.service.StartException in service jboss.persistenceunit."pagos-0.8.105.war#pagos_PU": javax.persistence.PersistenceException: [PersistenceUnit: pagos_PU] Unable to build Hibernate SessionFactory
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:172)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:117)
at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:667)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:182)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: pagos_PU] 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:154)
... 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:363)
at org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:374)
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)

实体:

@Entity
@EntityListeners({Listener.class})
public class DetalleBeca implements Serializable {
...
..
}

监听者:

public class Listener {
@Inject
private LogFacade logFacade;

@PostRemove
public void metodoRemover(DetalleBeca detalle) throws LogException {
logfacade.reg(detalle)
System.out.println(detalle);
}

最佳答案

你是对的。这是EAP 7.0 中的一个错误。这是门票:JBEAP-5371 , WFLY-2387

关于java - 注入(inject)EntityListener,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45085990/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com