ElArbi
ElArbi

Reputation: 1183

ServletPath changes from RESTEasy 3.0.10.Final to 3.0.23.Final

I've upgraded my Wildfly 8.2.1.Final with a new version of RESTEasy to be able to use SNI support (not available in 3.0.10.Final version). So I copied the resteasy-jboss-modules-3.0.23.Final content in my /wildfly/modules/system/layers/base directory. But now I have a different behavior ! my Rest services are not called. And when I've inspected the context/servlet path I found different values between 3.0.10.Final and 3.0.23.Final versions:

With RESTEasy 3.0.10.Final I have the following values :

        String contextPath = request.getContextPath(); // = "/myApp"
        String servletPath = request.getServletPath(); // = "/api"
        String pathInfo = request.getPathInfo(); // = "/auth"

And with RESTEasy 3.0.23.Final I have :

        String contextPath = request.getContextPath(); // = "/myApp"
        String servletPath = request.getServletPath(); // = "/api/auth"
        String pathInfo = request.getPathInfo(); // = null

my jboss-web.xml :

<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
    <context-root>/myApp</context-root>
</jboss-web>

And I have no servlet mappings in my web.xml. All I have is class extending javax.ws.rs.core.Application with @ApplicationPath annotation :

@ApplicationPath("/api")
public class RESTActivator extends Application {
    private final Set<Class<?>> classes;

    public RESTActivator() {
        HashSet<Class<?>> c = new HashSet<>();
        c.add(ARestService.class);
        c.add(AnotherRestService.class);
        classes = Collections.unmodifiableSet(c);
    }

    @Override
    public Set<Class<?>> getClasses() {
        return classes;
    }
}

Upvotes: 1

Views: 158

Answers (1)

Steve C
Steve C

Reputation: 19445

The behaviour of request.getServletPath() and request.getPathInfo() in a JAX-RS context is not defined by the specification, so I guess that an implementation is free to manage these how it sees fit.

If these path components are important to you consider using the services of an injected javax.ws.rs.core.UriInfo via @javax.ws.rs.core.Context instead.

Upvotes: 1

Related Questions