org.jboss.weld.exceptions.IllegalArgumentException: WELD-001456: Argument resolvedBean must not be null

懵懂的女人 提交于 2019-12-23 12:29:10

问题


Injecting EJBs into entity listeners is available, since JPA 2.1. WildFly 9.0.2 final however, fails with the following exception.

15:41:12,125 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 149) MSC000001: Failed to start service jboss.persistenceunit."Test.ear/Test-ejb.jar#Test-ejbPU": org.jboss.msc.service.StartException in service jboss.persistenceunit."Test.ear/Test-ejb.jar#Test-ejbPU": javax.persistence.PersistenceException: [PersistenceUnit: Test-ejbPU] 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:665)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:182)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
    at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: Test-ejbPU] Unable to build Hibernate SessionFactory
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:877)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:805)
    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:813)
    at org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:92)
    at org.jboss.weld.util.Beans.injectBoundFields(Beans.java:375)
    at org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:386)
    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.BeanManagerListenerFactory$BeanMetaData.<init>(BeanManagerListenerFactory.java:65)
    at org.hibernate.jpa.event.internal.jpa.BeanManagerListenerFactory$BeanMetaData.<init>(BeanManagerListenerFactory.java:54)
    at org.hibernate.jpa.event.internal.jpa.BeanManagerListenerFactory.buildListener(BeanManagerListenerFactory.java:40)
    at org.hibernate.jpa.event.internal.jpa.LegacyCallbackProcessor.resolveCallbacks(LegacyCallbackProcessor.java:161)
    at org.hibernate.jpa.event.internal.jpa.LegacyCallbackProcessor.processCallbacksForEntity(LegacyCallbackProcessor.java:66)
    at org.hibernate.jpa.event.spi.JpaIntegrator.integrate(JpaIntegrator.java:140)
    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:802)
    ... 9 more

15:41:12,125 ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 2) WFLYCTL0013: Operation ("full-replace-deployment") failed - address: ([]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.\"Test.ear/Test-ejb.jar#Test-ejbPU\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"Test.ear/Test-ejb.jar#Test-ejbPU\": javax.persistence.PersistenceException: [PersistenceUnit: Test-ejbPU] Unable to build Hibernate SessionFactory
    Caused by: javax.persistence.PersistenceException: [PersistenceUnit: Test-ejbPU] Unable to build Hibernate SessionFactory
    Caused by: org.jboss.weld.exceptions.IllegalArgumentException: WELD-001456: Argument resolvedBean must not be null"}}

Asking this question only because I read somewhere that injecting EJBs and/or CDI events into entity listeners is available since WildFly 8.2. Therefore, I feel I go wrong somewhere.

Unlike GlassFish where it succeeds (at least on GlassFish 4.1), does WildFly requires us to take some extra care about injecting EJBs and/or CDI events into entity listeners?


I have tested this on a completely blank enterprise application having nothing other than a blank session bean (stateless) which is to be injected into an entity listener and a few JPA entities.

The listener :

public class ProductListener {

    @Inject
    private TestService service;

    @PostPersist
    public void postPersist() {

    }
}

The EJB is left completely blank :

@Stateless
public class TestBean implements TestService {

}

The exception vanishes, if the injection point (TestService) is removed.

Designating the listener with @ApplicationScoped or @Singleton does not help either (which in turn should not be needed in reality).

The Hibernate version is 5.0.5 final and the Weld version is 2.2.16.


Update 1 :

Updated to Hibernate 5.0.6 final.

Update 2 :

The issue persists in WildFly 10.0.0 final released on Friday, January 29, 2016 having Hibernate 5.0.7 final / Weld 2.3 final.

Update 3 :

According to the issue status, this has been fixed in Hibernate 5.1.0 final and it should have worked accordingly in WildFly 10.0.0 final but it still fails to work with the same exception - no improvement.


回答1:


As pointed out by @Franck, it is a bug and was eventually fixed last year in version 11 only (wildfly) (and so also in EAP 7.1). We use EAP 7.0 (wildfly 10) and same issue and we can't upgrade. As workaround we use now the suggestion of @Tiny, moving our functionality to an EJB and using @EJB iso @Inject.

Credits to all users of this topic, just wanted to consolidate this in an answer for later reference.



来源:https://stackoverflow.com/questions/33891368/org-jboss-weld-exceptions-illegalargumentexception-weld-001456-argument-resolv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!