1

I am upgrading some of the libraries in my JEE application, hoping to solve a strange issue (see JAX-RS integration test with Undertow failing in Jenkins but working locally)

While upgrading restEasy, then Weld, my tests are failing because there are some "internal" compilation issues due to the change of namespace from javax.servlet.ServletContext to jakarta.servlet.ServletContext :

in my dependencies I have :

in weld-servlet-core 4.0.2.Final :

package org.jboss.weld.environment.undertow;

import io.undertow.servlet.ServletExtension;
import jakarta.servlet.ServletContext;
...

public class WeldServletExtension implements ServletExtension {

    @Override
    public void handleDeployment(DeploymentInfo deploymentInfo, ServletContext servletContext) {
...
}
}

and in undertow-servlet 2.2.7.Final :

package io.undertow.servlet;

import io.undertow.servlet.api.DeploymentInfo;

import javax.servlet.ServletContext;

public interface ServletExtension {

    void handleDeployment(final DeploymentInfo deploymentInfo, final ServletContext servletContext);

}

This can't work, because WeldServletExtension actually does not implement ServletExtension in that setup : it uses a jakarta.servlet.ServletContext, while the interface requires the use of javax.servlet.ServletContext

undertow-servlet:2.2.7.Final is brought transitively by resteasy-undertow:5.0.0.Beta1 (latest version available, from October 2021), and I add myself weld-servlet-core:4.0.2.Final (also latest version : from July 2021)

Looking at ServletExtension in its main branch, Undertow is still using javax.* namespace, not jakarta.* - it hasn't been updated since 2014. So even if I were using Undertow latest version (2.2.12.Final), I would still have the issue

So I am a bit puzzled... what is the trick here ? can't we use Undertow once we upgrade to RestEasy 5.x and use Weld ?

Vincent F
  • 6,523
  • 7
  • 37
  • 79
  • There is not currently a Jakarta REST 3.0 implementation of RESTEasy. Though this is coming, there is no official date ATM. I would say within a month there will at least be an alpha version. – James R. Perkins Oct 14 '21 at 17:26

1 Answers1

1

Undertow is shipping a special separate artifact that uses EE 9 namespaces. It has a slightly different GAV - io.undertow:undertow-servlet-jakartaee9:2.2.12.Final

It is available in Maven Central, as you can see here. Weld 4 is actually using precisely this artifact, which can be seen from pom.xml.

This should be the missing part in your puzzle.

Siliarus
  • 6,393
  • 1
  • 14
  • 30
  • thanks, it helps. I by excluding undertow-servlet and adding the other one, I get a bit further. testImplementation ('org.jboss.resteasy:resteasy-undertow:5.0.0.Beta1'){ exclude module: 'undertow-servlet' } testImplementation 'io.undertow:undertow-servlet-jakartaee9:2.2.12.Final' But now, it fails with a similar error further, complaining that org.jboss.resteasy.plugins.server.servlet.HttpServlet30Dispatcher (from resteasy-core 5.0.0.Beta, implements javax.servlet.Servlet and not jakarta.servlet.Servlet .. it's a never ending story, right ? – Vincent F Oct 14 '21 at 07:22
  • Well, IMO you'll need a different version of `resteasy-undertow` as well, e.g. some that uses `jakarta` namespace. However, that's outside of my knowledge so I cannot give you a definite answer. – Siliarus Oct 15 '21 at 07:05