commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: Tomcat 4.1.21 and commons-digester.jar
Date Fri, 28 Mar 2003 16:40:20 GMT


On Fri, 28 Mar 2003, F.R. Da Costa Gomez wrote:

> Date: Fri, 28 Mar 2003 17:03:27 +0100
> From: F.R. Da Costa Gomez <dcg@fixed.com>
> Reply-To: Jakarta Commons Users List <commons-user@jakarta.apache.org>,
>      dcg@fixed.com
> To: commons-user@jakarta.apache.org
> Subject: Tomcat 4.1.21 and commons-digester.jar
>
> Hi all,
>
> Encountered a strange thing wnen trying to use the commons-digester.jar
> with Tomcat 4.1.21 on a w2k box.
> TC does not want to start up. Tried it on two different boxed (one
> completely clean install), to no avail.
> The jar was place in the TC-HOME/common/lib dir. Without the digester
> jar things start fine, with the jar it doesn't (taking it out again
> moves all back to normal).
>
> I hope someone can help me out on this one because I am at a loss.
>

It's impossible to know for sure without seeing your code, but I suspect
you are running afoul of the problem that class loaders can only look *up*
the class loader hierarchy, not *down*.  For background info on how Tomcat
sets up class loaders, see:

http://jakarta.apache.org/tomcat/tomcat-4.1-doc/class-loader-howto.html

So, the likely cause of your problem is that you're putting
commons-digester.jar into $CATALINA_HOME/common/lib (so that it is in the
common class loader) but trying to load a class from your webapp's
/WEB-INF/classes or /WEB-INF/lib directories (in the webapp class loader).
Because the digester classes are loaded from the former, they cannot see
the latter.

A straightforward workaround is to tell Digester to use the webapp class
loader to load classes for things like the object create rule.  As you're
setting up your Digester instance, simply call:

  digester.setUseContextClassLoader(true);

because the servlet container provides a thing called the "context class
loader" and sets it to the one for your webapp.

Craig

> Following is the error output.
>
> Thx,
>
> Fermin DCG
>
> Error log:
>
> 10 [main] ERROR digester.Digester  - Begin event threw exception
> java.lang.ClassNotFoundException: org.apache.catalina.core.StandardServer
>   at
> org.apache.catalina.loader.StandardClassLoader.loadClass(StandardClassLoader.java:992)
>   at
> org.apache.catalina.loader.StandardClassLoader.loadClass(StandardClassLoader.java:857)
>   at
> org.apache.commons.digester.ObjectCreateRule.begin(ObjectCreateRule.java:252)
>   at org.apache.commons.digester.Rule.begin(Rule.java:200)
>   at org.apache.commons.digester.Digester.startElement(Digester.java:1268)
>   at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown
> Source)
>   at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown
> Source)
>   at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown
> Source)
>   at
> org.apache.xerces.impl.XMLDocumentScannerImpl$ContentDispatcher.scanRootElementHook(Unknown
> Source)
>   at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
> Source)
>   at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
> Source)
>   at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
>   at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
>   at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
>   at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
>   at org.apache.commons.digester.Digester.parse(Digester.java:1543)
>   at org.apache.catalina.startup.Catalina.start(Catalina.java:449)
>   at org.apache.catalina.startup.Catalina.execute(Catalina.java:400)
>   at org.apache.catalina.startup.Catalina.process(Catalina.java:180)
>   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>   at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>   at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>   at java.lang.reflect.Method.invoke(Method.java:324)
>   at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203)
> Catalina.start: java.lang.ClassNotFoundException:
> org.apache.catalina.core.StandardServer
> java.lang.ClassNotFoundException: org.apache.catalina.core.StandardServer
>   at
> org.apache.commons.digester.Digester.createSAXException(Digester.java:2383)
>   at
> org.apache.commons.digester.Digester.createSAXException(Digester.java:2409)
>   at org.apache.commons.digester.Digester.startElement(Digester.java:1271)
>   at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown
> Source)
>   at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown
> Source)
>   at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown
> Source)
>   at
> org.apache.xerces.impl.XMLDocumentScannerImpl$ContentDispatcher.scanRootElementHook(Unknown
> Source)
>   at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
> Source)
>   at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
> Source)
>   at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
>   at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
>   at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
>   at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
>   at org.apache.commons.digester.Digester.parse(Digester.java:1543)
>   at org.apache.catalina.startup.Catalina.start(Catalina.java:449)
>   at org.apache.catalina.startup.Catalina.execute(Catalina.java:400)
>   at org.apache.catalina.startup.Catalina.process(Catalina.java:180)
>   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>   at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>   at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>   at java.lang.reflect.Method.invoke(Method.java:324)
>   at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203)
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>

Mime
View raw message