weld / weld-testing

Set of test framework extensions (JUnit 4, JUnit 5, Spock) to enhance the testing of CDI components via Weld. Supports Weld 5.
http://weld.cdi-spec.org/
Apache License 2.0
102 stars 30 forks source link

Unsatisfied dependencies for type BeanContainer #146

Closed JohT closed 2 years ago

JohT commented 2 years ago

Description

Reproducer

JohT/livecoding#67

StackTrace

org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type BeanContainer with qualifiers @Default
  at injection point [BackedAnnotatedField] @Inject org.joht.livecoding.eventsourcing.infrastructure.axon.AxonConfiguration.beanContainer
  at org.joht.livecoding.eventsourcing.infrastructure.axon.AxonConfiguration.beanContainer(AxonConfiguration.java:0)

    at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:367)
    at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:285)
    at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:141)
    at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:162)
    at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:515)
    at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:501)
    at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:476)
    at org.jboss.weld.bootstrap.WeldStartup.validateBeans(WeldStartup.java:492)
    at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:94)
    at org.jboss.weld.environment.se.Weld.initialize(Weld.java:826)
    at org.jboss.weld.junit.AbstractWeldInitiator.initWeldContainer(AbstractWeldInitiator.java:536)
    at org.jboss.weld.junit5.WeldInitiator.initWeld(WeldInitiator.java:193)
    at org.jboss.weld.junit5.WeldJunit5Extension.startWeldContainerIfAppropriate(WeldJunit5Extension.java:246)
    at org.jboss.weld.junit5.WeldJunit5Extension.beforeEach(WeldJunit5Extension.java:218)
manovotn commented 2 years ago

Thanks for the report, will look into it this week.

@Inject BeanManager beanManager;works as expected.

This is a safe replacement as BeanManager directly implements BeanContainer (and Weld should give you the same object for both).

manovotn commented 2 years ago

So this is in fact a pretty serious oversight in Weld, see https://issues.redhat.com/browse/WELD-2731 It will be fixed in Weld 5.0.2.Final, pending PR is here.

I noticed that your projects doesn't declare any Weld version. I'd recommend you declare it explicitly as the version brought in with this weld-testing is more likely to be the minimal required version and not the latest release. I am talking about this dependency on Weld SE core - https://github.com/weld/weld-testing/blob/master/pom.xml#L73-L77

I'll close this issue as it isn't directly related to this project. You're safe to use BeanManager for now; later on you can use Weld 5.0.2.Final and it should work just fine :)

JohT commented 2 years ago

Thanks for reporting it downstream and for your advices.👍