Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run embedded web server in unit test due to conflicting weld-se / weld-servlet versions #214

Open
jansohn opened this issue Sep 20, 2024 · 0 comments

Comments

@jansohn
Copy link

jansohn commented Sep 20, 2024

I'm trying to run an embedded web server (tomcat or jetty) in a junit test. The problem is that during weld bootstrapping when starting the embedded web server it picks up jakarta.enterprise.inject.spi.Extension from the weld-se package (org.jboss.weld.environment.se.WeldSEBeanRegistrant) instead of the weld-servlet package (org.jboss.weld.module.web.WeldWebModule) which leads to the following exception:

Caused by: java.lang.RuntimeException: Service class org.jboss.weld.environment.se.WeldSEBeanRegistrant didn't implement the required interface
        at org.jboss.weld.util.ServiceLoader.loadClass(ServiceLoader.java:230)
        at org.jboss.weld.util.ServiceLoader.loadService(ServiceLoader.java:210)
        at org.jboss.weld.util.ServiceLoader.loadServiceFile(ServiceLoader.java:184)
        at org.jboss.weld.util.ServiceLoader.reload(ServiceLoader.java:164)
        at org.jboss.weld.util.ServiceLoader.iterator(ServiceLoader.java:288)
        at org.jboss.weld.util.collections.ImmutableSet$BuilderImpl.addAll(ImmutableSet.java:158)
        at org.jboss.weld.environment.servlet.WeldServletLifecycle.createDeployment(WeldServletLifecycle.java:275)
        at org.jboss.weld.environment.servlet.WeldServletLifecycle.initialize(WeldServletLifecycle.java:153)
        at org.jboss.weld.environment.servlet.EnhancedListener.onStartup(EnhancedListener.java:66)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4412)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164)
        ... 25 more

Reproducer: https://github.com/jansohn/weld-junit5-embedded-jetty/tree/embedded-tomcat-weld-junit5

Is there any clever trick to make weld-se and weld-servlet-core on the same classloader behave correctly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant