You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by yourang <ad...@lmco.com> on 2011/05/04 20:52:04 UTC

How to Guarantee that a WAR Imports the Same Version of javax.servlet As Pax Web?

I am running into an issue wherein the Pax Web WAR Extender is importing a
different version of javax.servlet than a WAR that it is deploying.  This
causes class cast exceptions on javax.servlet.*.  I tried specifying the
version of javax.servlet in my WAR's manifest as the same version that was
being imported by the WAR Extender, but I discovered that the WAR Extender
picks up different versions of javax.servlet depending on when it is loaded. 
Is there a way to guarantee that my war picks up the same version of
javax.servlet as the PAX Web War Extender?

--
View this message in context: http://karaf.922171.n3.nabble.com/How-to-Guarantee-that-a-WAR-Imports-the-Same-Version-of-javax-servlet-As-Pax-Web-tp2900224p2900224.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: How to Guarantee that a WAR Imports the Same Version of javax.servlet As Pax Web?

Posted by yourang <ad...@lmco.com>.
Thanks for the quick reply.  It is indeed included on the class-path (not due
to an explicit decision on our part, but because the application we
OSGifying included it).  I've made the change, but need to get it onto a box
that was showing the problem.  I'll provide an update in the next couple of
days.

--
View this message in context: http://karaf.922171.n3.nabble.com/How-to-Guarantee-that-a-WAR-Imports-the-Same-Version-of-javax-servlet-As-Pax-Web-tp2900224p2901234.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: How to Guarantee that a WAR Imports the Same Version of javax.servlet As Pax Web?

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Just as reminder, it's the same problem outside OSGi/Karaf. For 
instance, try to deploy a WAR in Tomcat or JBoss if you embed 
servlet.jar from another version, it will fail ;)

The J2EE best practice specifies to avoid to include servlet.jar in the 
webapp classloader.

Regards
JB

On 05/04/2011 09:05 PM, Achim Nierbeck wrote:
> Hi could you please provide some more information on which karaf version
> and what you have included inside your war archive. But from my
> experience this is due to the fact that your war archive includes some
> sort of
> servlet.jar which is actually not allowed by any web container, just
> that the
> regular tomcat / jetty with it's hierarchical classloader has no issue
> with this
> since the servlet jar is already loaded.
> So for you it's just to get the servlet.jar out of your classpath or
> better remove it
> out of the war archive.
>
>
> Btw. a future version of pax-web will make sure that the servlet.jar is not
> included in the classpath.
>
>
> regards, Achim
>
>
>> I am running into an issue wherein the Pax Web WAR Extender is
>> importing a
>> different version of javax.servlet than a WAR that it is deploying. This
>> causes class cast exceptions on javax.servlet.*. I tried specifying the
>> version of javax.servlet in my WAR's manifest as the same version that
>> was
>> being imported by the WAR Extender, but I discovered that the WAR
>> Extender
>> picks up different versions of javax.servlet depending on when it is
>> loaded.
>> Is there a way to guarantee that my war picks up the same version of
>> javax.servlet as the PAX Web War Extender?
>>
>> --
>> View this message in context:
>> http://karaf.922171.n3.nabble.com/How-to-Guarantee-that-a-WAR-Imports-the-Same-Version-of-javax-servlet-As-Pax-Web-tp2900224p2900224.html
>>
>> Sent from the Karaf - User mailing list archive at Nabble.com.
>

Re: How to Guarantee that a WAR Imports the Same Version of javax.servlet As Pax Web?

Posted by Achim Nierbeck <bc...@googlemail.com>.
Hi could you please provide some more information on which karaf version
and what you have included inside your war archive. But from my
experience this is due to the fact that your war archive includes some 
sort of
servlet.jar which is actually not allowed by any web container, just 
that the
regular tomcat / jetty with it's hierarchical classloader has no issue 
with this
since the servlet jar is already loaded.
So for you it's just to get the servlet.jar out of your classpath or 
better remove it
out of the war archive.


Btw. a future version of pax-web will make sure that the servlet.jar is not
included in the classpath.


regards, Achim


> I am running into an issue wherein the Pax Web WAR Extender is importing a
> different version of javax.servlet than a WAR that it is deploying.  This
> causes class cast exceptions on javax.servlet.*.  I tried specifying the
> version of javax.servlet in my WAR's manifest as the same version that was
> being imported by the WAR Extender, but I discovered that the WAR Extender
> picks up different versions of javax.servlet depending on when it is loaded.
> Is there a way to guarantee that my war picks up the same version of
> javax.servlet as the PAX Web War Extender?
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/How-to-Guarantee-that-a-WAR-Imports-the-Same-Version-of-javax-servlet-As-Pax-Web-tp2900224p2900224.html
> Sent from the Karaf - User mailing list archive at Nabble.com.