You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by david2 <Da...@l-3comcept.com> on 2007/08/09 17:25:54 UTC

Tomcat giving JDK Precedence Over JARs in WAR

I have a web application that uses commons XML (xml-apis-1.3.03.jar).  The
usage of javax.xml.xpath.XPathFactory.newInstance() works fine in the
Eclipse debugger, but when the code is packaged into a WAR and deployed to
Tomcat, I get a NullPointerException when
javax.xml.xpath.XPathFactory.newInstance() is called:



java.lang.NullPointerException
        at
javax.xml.xpath.XPathFactoryFinder._newFactory(XPathFactoryFinder.java:222)
        at
javax.xml.xpath.XPathFactoryFinder.newFactory(XPathFactoryFinder.java:143)
        at javax.xml.xpath.XPathFactory.newInstance(XPathFactory.java:185)
        at javax.xml.xpath.XPathFactory.newInstance(XPathFactory.java:99)
        at
com.myorg.myapp.ws.notification.impl.ExtnMessagePatternFilter.accepts(ExtnMessagePatternFilter.java:69)
        at
org.apache.muse.ws.notification.impl.FilterCollection.accepts(FilterCollection.java:64)
        at
com.myorg.myapp.ws.notification.impl.BufferedSubscriptionManager.publish(BufferedSubscriptionManager.java:73)
        at
com.myorg.myapp.ws.notification.impl.NewsNotificationProducer.publish(NewsNotificationProducer.java:38)
        at
org.apache.muse.ws.notification.impl.SimpleNotificationProducer.publish(SimpleNotificationProducer.java:420)
        at com.myorg.myapp.ws.handler.DDSHandler.run(DDSHandler.java:304)
        at
com.myorg.commons.util.reactor.ReactorAdapter.run(ReactorAdapter.java:19)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
        at java.lang.Thread.run(Thread.java:619)



Any idea what might be going wrong here?

Thanks,
-David
-- 
View this message in context: http://www.nabble.com/Tomcat-giving-JDK-Precedence-Over-JARs-in-WAR-tf4243247.html#a12074492
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Tomcat giving JDK Precedence Over JARs in WAR

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Gregor Schneider [mailto:rc46fi@googlemail.com] 
> Subject: Re: Tomcat giving JDK Precedence Over JARs in WAR
> 
> as to what i understood, david thinks he's using the ones coming with
> jdk 1.6, however, they are giving a nullpointer.

One possible cause is having the same libraries visible to multiple
classloaders in the hierarchy.  This often results in symptoms like the
NPE.  The OP needs to check that there are no duplicate classes amongst
those in WEB-INF/lib, Tomcat's lib directory, the endorsed directory (if
any), and the JRE/JDK in use.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat giving JDK Precedence Over JARs in WAR

Posted by Gregor Schneider <rc...@googlemail.com>.
as to what i understood, david thinks he's using the ones coming with
jdk 1.6, however, they are giving a nullpointer.

therefore, it has to be checked if tomcat uses the endorsed mechanism
using it's very own libraries. seems as in this very case something is
in eclipse's classpath what's missing in the application-classpath
within tomcat.

gregor
-- 
what's puzzlin' you, is the nature of my game
gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
gpgp-key available @ http://pgpkeys.pca.dfn.de:11371

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat giving JDK Precedence Over JARs in WAR

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
javax.xml and the whole endorsed fiasco is very tricky. What I would 
suggest is to simply ditch your additional XML libraries and use the 
ones that come with the JDK

saves you a lot of head ache and time

Filip

Gregor Schneider wrote:
> david,
>
>   
>> I already include xml-apis-1.3.03.jar in the WAR's WEB-INF/lib-directory.
>>     
>
> are you saying that the jar containing the said class is in your
> WEB-INF/lib-directory already and you get that NullPointer?
>
> On which OS are you running? Is it possible, that you have set an
> environment-variable like JAVA_ENDORSED? This overwrites the default
> XML-handling
>
> In your logs, is there a root-cause for that exception you posted?
>
> If all that doesn't give you a clue, start Tomcat in JPDA-mode,
> connect remotely with your Eclipse-debugger and set a breakpoint at
>
> com.myorg.myapp.ws.notification.impl.BufferedSubscriptionManager.publish(BufferedSubscriptionManager.java:73)
>
> Then check the variables which are null but ought to be set, maybe
> that gives you a figure.
>
> HTH
>
> Gregor
>   


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat giving JDK Precedence Over JARs in WAR

Posted by Gregor Schneider <rc...@googlemail.com>.
david,

> I already include xml-apis-1.3.03.jar in the WAR's WEB-INF/lib-directory.

are you saying that the jar containing the said class is in your
WEB-INF/lib-directory already and you get that NullPointer?

On which OS are you running? Is it possible, that you have set an
environment-variable like JAVA_ENDORSED? This overwrites the default
XML-handling

In your logs, is there a root-cause for that exception you posted?

If all that doesn't give you a clue, start Tomcat in JPDA-mode,
connect remotely with your Eclipse-debugger and set a breakpoint at

com.myorg.myapp.ws.notification.impl.BufferedSubscriptionManager.publish(BufferedSubscriptionManager.java:73)

Then check the variables which are null but ought to be set, maybe
that gives you a figure.

HTH

Gregor
-- 
what's puzzlin' you, is the nature of my game
gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
gpgp-key available @ http://pgpkeys.pca.dfn.de:11371

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat giving JDK Precedence Over JARs in WAR

Posted by david2 <Da...@l-3comcept.com>.
Gregor,

I am using the following:

    Tomcat 5.5.20
    Xalan 2.7.0
    Eclipse 3.2.2 
    JDK build 1.6.0-b105

I already include xml-apis-1.3.03.jar in the WAR's WEB-INF/lib-directory. 
However, while I need the class javax.xml.xpath.XPathFactory contained in
xml-apis-1.3.03.jar, this class also occurs in the SDK's rt.jar.

How can you be sure of which jar gets used by Tomcat for a WAR produced in a
Maven build?

-David



Gregor Schneider wrote:
> 
> 1st, it would help if you let us know which Tomcat / Eclipse-Version...
> 
> Anyways, it should work if you do the following:
> 
> - Copy your xml-apis-1.3.03.jar into your application's
> WEB-INF/lib-directory, so that your application's classloader can find
> the corrosponding classes.
> Tomcat (at least until Tomcat 5.5) does not come with commons xml
> 
> Cheers
> 
> Gregor
> -- 
> what's puzzlin' you, is the nature of my game
> gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
> gpgp-key available @ http://pgpkeys.pca.dfn.de:11371
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Tomcat-giving-JDK-Precedence-Over-JARs-in-WAR-tf4243247.html#a12075436
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat giving JDK Precedence Over JARs in WAR

Posted by Gregor Schneider <rc...@googlemail.com>.
1st, it would help if you let us know which Tomcat / Eclipse-Version...

Anyways, it should work if you do the following:

- Copy your xml-apis-1.3.03.jar into your application's
WEB-INF/lib-directory, so that your application's classloader can find
the corrosponding classes.
Tomcat (at least until Tomcat 5.5) does not come with commons xml

Cheers

Gregor
-- 
what's puzzlin' you, is the nature of my game
gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
gpgp-key available @ http://pgpkeys.pca.dfn.de:11371

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org