0

I have an JAX-RS integration test that works locally, both in IntelliJ (using Gradle to run the test) and Gradle command line .

But when I run the test in Jenkins, the test fails, with some issue during the Undertow deployment.

This is how I start the container :

public static void startContainer() throws ServletException {
  System.setProperty("org.jboss.resteasy.port", "8085");
  server = new UndertowJaxrsServer().start();

  ResteasyDeployment deployment = new ResteasyDeployment();
  deployment.setInjectorFactoryClass("org.jboss.resteasy.cdi.CdiInjectorFactory");
  deployment.setApplicationClass(MyApp.class.getName());
  DeploymentInfo di = server.undertowDeployment(deployment);
  di.setClassLoader(Server.class.getClassLoader());
  di.setResourceManager(new ClassPathResourceManager(Server.class.getClassLoader()));
  di.setContextPath("/vincent-service");
  di.setDeploymentName("DI");
  di.addListeners(Servlets.listener(org.jboss.weld.environment.servlet.Listener.class));
  server.deploy(di);
}

When the test runs in Jenkins, I get a NullPointerException :

java.lang.RuntimeException: java.lang.NullPointerException at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:254) at org.jboss.resteasy.plugins.server.undertow.UndertowJaxrsServer.deploy(UndertowJaxrsServer.java:266)

...

Caused by: java.lang.NullPointerException at org.jboss.weld.module.web.servlet.WeldInitialListener.contextInitialized(WeldInitialListener.java:94) at org.jboss.weld.servlet.api.helpers.ForwardingServletListener.contextInitialized(ForwardingServletListener.java:34) at org.jboss.weld.environment.servlet.Listener.contextInitialized(Listener.java:121) at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:187) at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:217) at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:186) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:252)

Looking in Weld source code (in weld-web-3.1.2.Final), it seems the exception is thrown from the last line here :

@Override
public void contextInitialized(ServletContextEvent sce) {
    final ServletContext ctx = sce.getServletContext();
    // First try to use the context id obtained from the servlet context (OSGi, Servlet containers, etc.)
    if (beanManager == null) {
        String contextId = ctx.getInitParameter(Container.CONTEXT_ID_KEY);
        if (contextId != null) {
            List<BeanManagerImpl> managers = new ArrayList<BeanManagerImpl>(Container.instance(contextId).beanDeploymentArchives().values());
            Collections.sort(managers, BeanManagers.ID_COMPARATOR);
            beanManager = managers.get(0);
        }
    }
    // servlet containers may not be able to inject fields in a servlet listener
    if (beanManager == null) {
        beanManager = BeanManagerProxy.unwrap(CDI.current().getBeanManager());
    }

Part of the test is running though, as I can see these logs :

[2021-10-06T08:44:16.016Z] [io.undertow.Undertow] [Test worker] [117] [INFO ] starting server: Undertow - 2.1.3.Final

[2021-10-06T08:44:16.016Z] [org.xnio.Xnio] [Test worker] [95] [INFO ] XNIO version 3.8.0.Final

[2021-10-06T08:44:16.016Z] [org.xnio.nio.NioXnio] [Test worker] [59] [INFO ] XNIO NIO Implementation Version 3.8.0.Final

[2021-10-06T08:44:16.016Z] [org.jboss.threads.Version] [Test worker] [52] [INFO ] JBoss Threads version 3.1.0.Final

[2021-10-06T08:44:17.017Z] [org.jboss.weld.environment.servlet.Listener] [Test worker] [115] [INFO ] WELD-ENV-001007: Initialize Weld using ServletContextListener

[2021-10-06T08:44:17.017Z] [org.jboss.weld.bootstrap.WeldStartup] [Test worker] [231] [INFO ] WELD-000101: Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.

[2021-10-06T08:44:17.017Z] [org.jboss.weld.event.ExtensionObserverMethodImpl] [Test worker] [86] [INFO ] WELD-000411: Observer method [BackedAnnotatedMethod] protected org.apache.deltaspike.core.impl.exclude.extension.ExcludeExtension.vetoBeans(@Observes ProcessAnnotatedType, BeanManager) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.

[2021-10-06T08:44:17.017Z] [org.jboss.weld.event.ExtensionObserverMethodImpl] [Test worker] [86] [INFO ] WELD-000411: Observer method [BackedAnnotatedMethod] public org.apache.deltaspike.core.impl.interceptor.interdyn.InterDynExtension.processAnnotatedType(@Observes ProcessAnnotatedType) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.

[2021-10-06T08:44:17.017Z] [org.jboss.weld.event.ExtensionObserverMethodImpl] [Test worker] [86] [INFO ] WELD-000411: Observer method [BackedAnnotatedMethod] protected org.apache.deltaspike.core.impl.message.MessageBundleExtension.detectInterfaces(@Observes ProcessAnnotatedType) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.

[2021-10-06T08:44:17.017Z] [org.jboss.weld.event.ExtensionObserverMethodImpl] [Test worker] [86] [INFO ] WELD-000411: Observer method [BackedAnnotatedMethod] protected org.apache.deltaspike.core.impl.interceptor.GlobalInterceptorExtension.promoteInterceptors(@Observes ProcessAnnotatedType) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.

[2021-10-06T08:44:17.017Z] [org.jboss.weld.event.ExtensionObserverMethodImpl] [Test worker] [86] [INFO ] WELD-000411: Observer method [BackedAnnotatedMethod] public org.apache.deltaspike.core.impl.config.ConfigurationExtension.findDynamicConfigurationBeans(@Observes ProcessAnnotatedType<?>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.

[2021-10-06T08:44:18.018Z] [org.jboss.weld.logging.ValidatorLogger] [Test worker] [59] [WARN ] WELD-001478: Interceptor class org.apache.deltaspike.core.impl.throttling.ThrottledInterceptor is enabled for the application and for the bean archive /tankkarte-service_/var/jenkins_home/.gradle/caches/modules-2/files-2.1/org.apache.deltaspike.core/deltaspike-core-impl/1.9.4/709e0b27bb80e52fcd6a886a216ca3f9c2b8c28/deltaspike-core-impl-1.9.4.jar. It will only be invoked in the @Priority part of the chain.

[2021-10-06T08:44:18.018Z] [org.jboss.weld.logging.ValidatorLogger] [Test worker] [59] [WARN ] WELD-001478: Interceptor class org.apache.deltaspike.core.impl.lock.LockedInterceptor is enabled for the application and for the bean archive /tankkarte-service_/var/jenkins_home/.gradle/caches/modules-2/files-2.1/org.apache.deltaspike.core/deltaspike-core-impl/1.9.4/709e0b27bb80e52fcd6a886a216ca3f9c2b8c28/deltaspike-core-impl-1.9.4.jar. It will only be invoked in the @Priority part of the chain.

[2021-10-06T08:44:18.018Z] [org.jboss.weld.logging.ValidatorLogger] [Test worker] [59] [WARN ] WELD-001478: Interceptor class org.apache.deltaspike.core.impl.future.FutureableInterceptor is enabled for the application and for the bean archive /tankkarte-service_/var/jenkins_home/.gradle/caches/modules-2/files-2.1/org.apache.deltaspike.core/deltaspike-core-impl/1.9.4/709e0b27bb80e52fcd6a886a216ca3f9c2b8c28/deltaspike-core-impl-1.9.4.jar. It will only be invoked in the @Priority part of the chain.

[2021-10-06T08:44:18.018Z] [org.jboss.weld.logging.ValidatorLogger] [Test worker] [59] [WARN ] WELD-001478: Interceptor class org.apache.deltaspike.core.impl.monitoring.InvocationMonitorInterceptor is enabled for the application and for the bean archive /tankkarte-service_/var/jenkins_home/.gradle/caches/modules-2/files-2.1/org.apache.deltaspike.core/deltaspike-core-impl/1.9.4/709e0b27bb80e52fcd6a886a216ca3f9c2b8c28/deltaspike-core-impl-1.9.4.jar. It will only be invoked in the @Priority part of the chain.

[2021-10-06T08:44:18.018Z] [org.jboss.weld.environment.undertow.UndertowContainer] [Test worker] [39] [INFO ] WELD-ENV-001302: Undertow detected, CDI injection will be available in Servlets, Filters and Listeners.

[2021-10-06T08:44:19.019Z] [org.jboss.weld.bootstrap.Validator] [weld-worker-1] [200] [WARN ] WELD-001473: javax.enterprise.inject.spi.Bean implementation liquibase.integration.cdi.CDIBootstrap$1@7c73f99b declared a normal scope but does not implement javax.enterprise.inject.spi.PassivationCapable. It won't be possible to inject this bean into a bean with a passivating scope (@SessionScoped, @ConversationScoped). This can be fixed by assigning the Bean implementation a unique id by implementing the PassivationCapable interface.

[2021-10-06T08:44:20.020Z] [liquibase.logging.core.Slf4jLogger] [Test worker] [42] [INFO ] Booting Liquibase 3.6.2 [2021-10-06T08:44:20.020Z] [liquibase.logging.core.Slf4jLogger] [Test worker] [42] [INFO ] SELECT COUNT() FROM PUBLIC.DATABASECHANGELOGLOCK [2021-10-06T08:44:20.020Z] [liquibase.logging.core.Slf4jLogger] [Test worker] [42] [INFO ] SELECT COUNT() FROM PUBLIC.DATABASECHANGELOGLOCK

[2021-10-06T08:44:20.020Z] [liquibase.logging.core.Slf4jLogger] [Test worker] [42] [INFO ] SELECT LOCKED FROM PUBLIC.DATABASECHANGELOGLOCK WHERE ID=1

[2021-10-06T08:44:20.020Z] [liquibase.logging.core.Slf4jLogger] [Test worker] [42] [INFO ] Successfully acquired change log lock

[2021-10-06T08:44:21.021Z] [liquibase.logging.core.Slf4jLogger] [Test worker] [42] [INFO ] SELECT MD5SUM FROM PUBLIC.DATABASECHANGELOG WHERE MD5SUM IS NOT NULL

[2021-10-06T08:44:21.021Z] [liquibase.logging.core.Slf4jLogger] [Test worker] [42] [INFO ] SELECT COUNT(*) FROM PUBLIC.DATABASECHANGELOG

[2021-10-06T08:44:21.021Z] [liquibase.logging.core.Slf4jLogger] [Test worker] [42] [INFO ] Reading from PUBLIC.DATABASECHANGELOG

[2021-10-06T08:44:21.021Z] [liquibase.logging.core.Slf4jLogger] [Test worker] [42] [INFO ] SELECT * FROM PUBLIC.DATABASECHANGELOG ORDER BY DATEEXECUTED ASC, ORDEREXECUTED ASC

[2021-10-06T08:44:21.021Z] [liquibase.logging.core.Slf4jLogger] [Test worker] [42] [INFO ] Successfully released change log lock

[2021-10-06T08:44:21.021Z] [io.undertow.Undertow] [Test worker] [252] [INFO ] stopping server: Undertow - 2.1.3.Final

But at some point, the exception is thrown..

Any idea of what I could check to understand why this fails only in my Jenkins environment ?

I am using org.jboss.resteasy 3.12.1.Final libraries.

Vincent F
  • 6,523
  • 7
  • 37
  • 79
  • What version of RESTEasy are you using? – James R. Perkins Oct 07 '21 at 23:09
  • I am using RestEasy 3.12.1.Final - I will edit my question – Vincent F Oct 08 '21 at 09:22
  • That definitely seems odd. 3.12 will likely not see any more releases at this point. The latest release will be 5.0.0, currently at Beta1 with final coming out very soon. Is there any chance of being able to upgrade? – James R. Perkins Oct 08 '21 at 15:50
  • I have tried upgrading to restEasy 4.7.2.Final, but I have the same issue.. Could it come from Weld ? I tried upgrading it also (to 4.0.2.Final) , but hen when I run my test I get an exception : Receiver class org.jboss.weld.environment.undertow.WeldServletExtension does not define or inherit an implementation of the resolved method 'abstract void handleDeployment(io.undertow.servlet.api.DeploymentInfo, javax.servlet.ServletContext)' of interface io.undertow.servlet.ServletExtension – Vincent F Oct 09 '21 at 17:18
  • It definitely could be coming from Weld. It's hard to tell really. – James R. Perkins Oct 11 '21 at 18:05

0 Answers0