Closed jens-stahl closed 1 year ago
Hi, is this linked to this SO question? If so, both have different stacks - namely the one on SO shows error coming from jboss classfilewriter while here it's coming from Weld internals.
Either way, I will take a look in the coming days - Weld 3 wasn't developed with Java 17 in mind back then but I don't think there is a reason why it shouldn't work.
Yes this is the same question. Thanks a lot for taking a look! Since Wildfly 26 uses Weld 3.1.9 I think it is not so unusual to run it with Java 17... I am not quite sure why the stack trace is different, I testet a lot with different versions/variations the last days. Here is the complete stack trace I get with 2.0.2 and Java 17:
org.jboss.weld.exceptions.WeldException: WELD-001524: Unable to load proxy class for bean Managed Bean [class de.XXX] with qualifiers [@Any @Default] with class class de.XXX using classloader jdk.internal.loader.ClassLoaders$AppClassLoader@2aae9190
at org.jboss.weld.bean.proxy.ProxyFactory.getProxyClass(ProxyFactory.java:370)
at org.jboss.weld.injection.producer.SubclassedComponentInstantiator.createEnhancedSubclass(SubclassedComponentInstantiator.java:113)
at org.jboss.weld.injection.producer.SubclassedComponentInstantiator.initEnhancedSubclass(SubclassedComponentInstantiator.java:86)
at org.jboss.weld.injection.producer.SubclassedComponentInstantiator.<init>(SubclassedComponentInstantiator.java:79)
at org.jboss.weld.injection.producer.SubclassedComponentInstantiator.forInterceptedDecoratedBean(SubclassedComponentInstantiator.java:63)
at org.jboss.weld.injection.producer.BeanInjectionTarget.initializeAfterBeanDiscovery(BeanInjectionTarget.java:121)
at org.jboss.weld.injection.producer.InjectionTargetInitializationContext.initialize(InjectionTargetInitializationContext.java:42)
at org.jboss.weld.injection.producer.InjectionTargetService.initialize(InjectionTargetService.java:63)
at org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:475)
at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:86)
at org.jboss.weld.environment.se.Weld.initialize(Weld.java:814)
at org.jboss.weld.junit.AbstractWeldInitiator.initWeldContainer(AbstractWeldInitiator.java:522)
at org.jboss.weld.junit5.WeldInitiator.initWeld(WeldInitiator.java:191)
at org.jboss.weld.junit5.WeldJunit5Extension.startWeldContainerIfAppropriate(WeldJunit5Extension.java:276)
at org.jboss.weld.junit5.WeldJunit5Extension.beforeEach(WeldJunit5Extension.java:200)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeEachCallbacks$2(TestMethodTestDescriptor.java:166)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeMethodsOrCallbacksUntilExceptionOccurs$6(TestMethodTestDescriptor.java:202)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeMethodsOrCallbacksUntilExceptionOccurs(TestMethodTestDescriptor.java:202)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeEachCallbacks(TestMethodTestDescriptor.java:165)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:132)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:68)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:147)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:127)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:90)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:55)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:102)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:54)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57)
at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55)
Caused by: java.lang.ExceptionInInitializerError
at org.jboss.weld.bean.proxy.ProxyFactory.createProxyClass(ProxyFactory.java:469)
at org.jboss.weld.bean.proxy.ProxyFactory.getProxyClass(ProxyFactory.java:362)
... 68 more
Caused by: java.lang.RuntimeException: cannot initialize ClassPool
at org.jboss.weld.util.bytecode.ClassFileUtils.<clinit>(ClassFileUtils.java:71)
... 70 more
Caused by: java.lang.NoSuchFieldException: override
at java.base/java.lang.Class.getDeclaredField(Class.java:2610)
at org.jboss.weld.util.bytecode.ClassFileUtils$1.run(ClassFileUtils.java:59)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:569)
at org.jboss.weld.util.bytecode.ClassFileUtils.<clinit>(ClassFileUtils.java:48)
... 70 more
@jens-stahl the exception you showed is coming from a class(org.jboss.weld.util.bytecode.ClassFileUtils
) that is no longer present in Weld 3.1.9.Final.
It is however present in 3.1.6.Final which is what weld-junit 2.0.2 pulls in by default - you need to explicitly override the version for 3.1.9.Final in your testing setup.
How would I override it for version 3.1.9.Final?
I tried to define the dependency like this:
<dependency>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se-core</artifactId>
<version>3.1.9.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-junit5</artifactId>
<version>2.0.2.Final</version>
<scope>test</scope>
</dependency>
But still get the same error.
Yes, that should do the trick; when you look at the dependency tree (mvn dependency:tree
), what version do you see?
IIRC, you need to declare weld-se-core
dependency prior to weld-junit
dependency because of how maven determines versions.
Or you could try to explicitly exclude weld dep from weld-junit
. Which would look something like this:
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-junit5</artifactId>
<version>2.0.2.Final</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se-core</artifactId>
</exclusion>
</exclusions>
</dependency>
Dependency tree looks like this:
[INFO] +- org.jboss.weld.se:weld-se-core:jar:3.1.9.Final:test [INFO] | +- org.jboss.weld.environment:weld-environment-common:jar:3.1.9.Final:test [INFO] | | - org.jboss.weld:weld-core-impl:jar:3.0.5.Final:test [INFO] | | +- org.jboss.weld:weld-api:jar:3.0.SP4:test [INFO] | | | - javax.enterprise:cdi-api:jar:2.0.SP1:provided [INFO] | | | - javax.inject:javax.inject:jar:1:provided [INFO] | | +- org.jboss.weld:weld-spi:jar:3.0.SP4:test [INFO] | | +- org.jboss.spec.javax.el:jboss-el-api_3.0_spec:jar:1.0.7.Final:test [INFO] | | - org.jboss.spec.javax.interceptor:jboss-interceptors-api_1.2_spec:jar:1.0.0.Final:test [INFO] | +- org.jboss.weld.probe:weld-probe-core:jar:3.1.9.Final:test [INFO] | +- jakarta.enterprise:jakarta.enterprise.cdi-api:jar:2.0.2:test [INFO] | | - jakarta.inject:jakarta.inject-api:jar:1.0.5:test [INFO] | - org.jboss.classfilewriter:jboss-classfilewriter:jar:1.2.5.Final:test [INFO] +- org.jboss.weld:weld-junit5:jar:2.0.2.Final:test [INFO] | - org.jboss.weld:weld-junit-common:jar:2.0.2.Final:test [INFO] | - org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:test
[INFO] +- org.jboss.weld.se:weld-se-core:jar:3.1.9.Final:test
[INFO] | +- org.jboss.weld.environment:weld-environment-common:jar:3.1.9.Final:test
[INFO] | | - org.jboss.weld:weld-core-impl:jar:3.0.5.Final:test
This is weird, you have 3.0.5.Final version of the weld-core-impl
which is where that class is coming from.
It looks like some misconfiguration is dependencies; perhaps you are declaring some other versions explicitly or excluding others?
You are correct! I have no idea why it is pulling an older version of weld-core-impl. If I explicitly define the following weld libs it is running! Thank you very much for your help, much appreciated!
<dependency>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se-core</artifactId>
<version>3.1.9.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-core-impl</artifactId>
<version>3.1.9.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-api</artifactId>
<version>3.1.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-junit5</artifactId>
<version>2.0.2.Final</version>
<scope>test</scope>
</dependency>
You are correct! I have no idea why it is pulling an older version of weld-core-impl. If I explicitly define the following weld libs it is running!
You shouldn't need to explicitly write it all out . It might be worth looking deeper into your project config to figure out the discrepancies; but that's something I cannot help with.
Thank you very much for your help, much appreciated!
Glad I could help :) Closing the issue.
Hello,
we are using weld-junit5:2.0.2.Final with Java 17.
After migration from Java 11 to Java 17 we get the following exception: Caused by: java.lang.NoSuchFieldException: override at java.base/java.lang.Class.getDeclaredField(Class.java:2610) at org.jboss.weld.util.bytecode.ClassFileUtils$1.run(ClassFileUtils.java:59) at java.base/java.security.AccessController.doPrivileged(AccessController.java:569) at org.jboss.weld.util.bytecode.ClassFileUtils.(ClassFileUtils.java:48)
... 70 more
I tried to include as mentioned in #80
but it has no effect.
Does weld-junit5 in version 2.0.2 work with Java 17? This is our current set up. (using wildfly 26 in production) Thanks a lot for any feedback or help!