I can't reproduce this issue.

I've updated the local test in 3.0.0-SNAPSHOT to have a single web.xml and two servlets with different URL patterns loading exactly the same Application, ignoring its ApplicationPath, (exactly as you had in the original case, except that you have 2 different Applications as well) and then expecting to see the error I actually saw the test still passing. Checked the code, each servlet instance creates a new unique bus and this is why it passes.

I think the reason you have it failing is that the same single bus instance gets somehow reused but I'm not sure how exactly it can be happening now that I see CXF(JAXRS)NonSpringServlet creates unique buses unless it is injected with the bus instance somehow...

Can you have a breakpoint in CXFNonSpringServlet.init and see where you have the shared bus coming from ? Or may be create a test project for me to look into it further ?

Cheers, Sergey

On 23/04/14 10:18, Sergey Beryozkin wrote:
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




Reply via email to