0

Recently we upgraded Weld to 3.0.3.Final (with is the one in Wildfly 12). Now weld-junit5 1.3.1.Final (the most recent version) throws an exception

java.lang.NoSuchMethodError: javax.enterprise.inject.spi.AfterBeanDiscovery.addBean()Ljavax/enterprise/inject/spi/configurator/BeanConfigurator;

We added weld-se-core to the dependency management:

<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.jboss.weld.se</groupId>
                <artifactId>weld-se-core</artifactId>
                <version>3.0.3.Final</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

This overrules the default Version of weld-se-core 2.4.8.Final, which is defined in weld-junit5. But it seems that weld-junit5 depends on the structure of weld 2.x

weld-junit5 states on its github page that weld 3 is supported but there is no description how to use it. I have found this in the POM of weld-junit5:

<profile>
         <id>weld3</id>
         <activation>
            <activeByDefault>false</activeByDefault>
            <property>
               <name>env.WELD_JUNIT_PROFILE</name>
               <value>weld3</value>
            </property>
         </activation>
         <dependencies>
            <dependency>
               <groupId>org.jboss.weld.module</groupId>
               <artifactId>weld-ejb</artifactId>
               <version>${version.weld}</version>
               <scope>test</scope>
            </dependency>
         </dependencies>
      </profile>

But I did not get this profile activated.

How can this be solved?

Marc von Renteln
  • 1,229
  • 15
  • 34

1 Answers1

0

With weld-se-shaded instead of weld-se-core it works.

Marc von Renteln
  • 1,229
  • 15
  • 34
  • 1
    Good that you figured out! BTW weld-junit will be switching to CDI 2.0 and Weld 3.x as its default settings. See this issue - https://github.com/weld/weld-junit/issues/68 – Siliarus Mar 04 '19 at 15:52
  • 1
    To expand, the profile is there for testing with Weld 3. Part of the profile is in parent and part is in junit5. Altogether is overrides the version of Weld SE core and adds the EJB module. What you didn't have there is actually (according to the exception) the CDI 2.0 API. The `shaded` artifact brings that in as well. – Siliarus Mar 04 '19 at 16:00