Hi
On 23/04/14 08:33, Dolezal, Petr wrote:
Hi Sergey,

thanks for the explanation. We will try to use ApplicationPath then when there 
is no other way.

However, there remains one thing that still confuses me and it still looks like 
a bug or something unexpected at least. You wrote:

Using ApplicationPath is indeed the only way to have multiple applications 
within a *single* web.xml.

As I noted in my additional post (the immediate reply to the original post), my 
colleague tried splitting the web application into two independent. I double 
checked his experiment and it indeed crashed with an exception. Therefore the 
two independent web applications are not as independent as one might think.

With all the details: we have now *two* web applications, each with its own 
web.xml. They look like this:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee";
     xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";
     id="WebApp_Sessioning" version="2.5">

     <servlet>
         <servlet-name>SessionServiceServlet</servlet-name>
         
<servlet-class>org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet</servlet-class>

         <init-param>
             <param-name>javax.ws.rs.Application</param-name>
             
<param-value>net.atos.dirx.access.net.rest.services.session.SessionODataApplication</param-value>
         </init-param>
     </servlet>

     <servlet-mapping>
         <servlet-name>SessionServiceServlet</servlet-name>
         <url-pattern>/*</url-pattern>
     </servlet-mapping>
</web-app>

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee";
     xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";
     id="WebApp_Authz" version="2.5">

     <servlet>
         <servlet-name>RequestServiceServlet</servlet-name>
         
<servlet-class>org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet</servlet-class>

         <init-param>
             <param-name>javax.ws.rs.Application</param-name>
             
<param-value>net.atos.dirx.access.net.rest.services.authz.RequestODataApplication</param-value>
         </init-param>
     </servlet>

     <servlet-mapping>
         <servlet-name>RequestServiceServlet</servlet-name>
         <url-pattern>/*</url-pattern>
     </servlet-mapping>
</web-app>


ApplicationPath is applied to none of these applications, relying just on being 
distinct web application.

Because one would expect that the applications are independent, it is somewhat 
surprising. CXF looks like holding some information about the endpoints 
globally... OK, I can understand it, but it means then that there is no way to 
override JAX-RS application paths (specified by ApplicationPath annotation), 
even putting the applications in separate web applications (with own web.xml 
and mapped by means of the container to different contexts) does not help, does 
it?

Hmm...Do you have CXF loaded from the container shared lib ? This might affect it, CXF default bus is probably used in this case, and its endpoint/destination registry is thus shared between webapps using CXF. With Spring contexts one can easily nominate custom buses, but not so with servlets alone.

I wonder if the proper solution is to optionally ask CXF(JAXRS)NonSpringServlet create unique per-servlet specific buses...

Ok, please experiment with ApplicationPath for now, I'll see if I can update the servlet code...

Cheers, Sergey




Best regards,
Petr



--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Reply via email to