How to configure two separate Jersey servlet containers for individual endpoints

58 views Asked by At

I am implementing the following two Jersey servlets in the server side:

<servlet>
        <servlet-name>DocService</servlet-name>
        <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
        <init-param>
        <param-name>jersey.config.server.provider.classnames</param-name>
        <param-value>org.glassfish.jersey.media.multipart.MultiPartFeature;es.ti.ws.ni.services.EnWS</param-value>
         </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>DocService</servlet-name>
        <url-pattern>/rt/ni/*</url-pattern>
    </servlet-mapping>   
    <servlet>
        <servlet-name>ExpService</servlet-name>
        <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
        <init-param>
        <param-name>jersey.config.server.provider.classnames</param-name>
        <param-value>org.glassfish.jersey.media.multipart.MultiPartFeature;es.ti.ws.ni.exp.services.Enexp</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>ExpService</servlet-name>
        <url-pattern>/rt/ni/*</url-pattern>
    </servlet-mapping>

The client application requires me to have the url patterns to be /rt/ni/* for both services.

This causes me to get an error in Tomcat: The servlets named [DocService] and [ExpService] are both mapped to the url-pattern [/rt/ni/*].

We have two possible calls from customers:

http://ip/Myapp/rt/ni/verificar?request=<?xml version="1.0" encoding="UTF-8" stand....

http://ip/Myapp/rt/ni/obtener?request=<?xml version="1.0....

So, To try to fix the problem I have tried to change the pattern to something more specific.

<servlet>
        <servlet-name>DocService</servlet-name>
        <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
        <init-param>
        <param-name>jersey.config.server.provider.classnames</param-name>
        <param-value>org.glassfish.jersey.media.multipart.MultiPartFeature;es.ti.ws.ni.services.EnWS</param-value>
         </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>DocService</servlet-name>
        <url-pattern>/rt/ni/verificar</url-pattern>
    </servlet-mapping>   
<servlet>
        <servlet-name>ExpService</servlet-name>
        <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
        <init-param>
        <param-name>jersey.config.server.provider.classnames</param-name>
        <param-value>org.glassfish.jersey.media.multipart.MultiPartFeature;es.ti.ws.ni.exp.services.Enexp</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>ExpService</servlet-name>
        <url-pattern>/rt/ni/obtener</url-pattern>
    </servlet-mapping>

But when I make the call, I get a 404

What is the problem, is there a solution?

0

There are 0 answers