You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Michael Rasmussen <ra...@gmail.com> on 2006/04/14 21:48:43 UTC

ClassNotFound [digester]

Hello,
  I am working with digester and when executing this line of code

upsResponseDTO = xmlDigester.parse(new ByteArrayInputStream(
upsResponse.getBytes()));

I get a ClassNotFoundException in digester

org.apache.commons.digester.Digester  TRAS0014I: The following exception was
logged java.lang.ClassNotFoundException:
mycompany.service.ups.dto.UPSResponseDTO
    at java.net.URLClassLoader.findClass(URLClassLoader.java(Compiled Code))
    at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java(Compiled
Code))
    at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
    at org.apache.commons.digester.ObjectCreateRule.begin(
ObjectCreateRule.java:204)
    at org.apache.commons.digester.Rule.begin(Rule.java:152)
    at org.apache.commons.digester.Digester.startElement(Digester.java:1286)
    at org.apache.xerces.parsers.AbstractSAXParser.startElement(
AbstractSAXParser.java(Compiled Code))
    at org.apache.xerces.impl.XMLNamespaceBinder.startElement(
XMLNamespaceBinder.java(Compiled Code))
    at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(
XMLDTDValidator.java(Compiled Code))
    at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(
XMLDocumentFragmentScannerImpl.java(Compiled Code))
    at
org.apache.xerces.impl.XMLDocumentScannerImpl$ContentDispatcher.scanRootElementHook
(XMLDocumentScannerImpl.java:929)
    at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch
(XMLDocumentFragmentScannerImpl.java(Compiled Code))
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(
XMLDocumentFragmentScannerImpl.java(Compiled Code))
    at org.apache.xerces.parsers.StandardParserConfiguration.parse(
StandardParserConfiguration.java:525)
    at org.apache.xerces.parsers.StandardParserConfiguration.parse(
StandardParserConfiguration.java:581)
    at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:147)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(
AbstractSAXParser.java:1158)
    at org.apache.commons.digester.Digester.parse(Digester.java:1591)
    at mycompany.service.ups.client.UPSXmlDigester.parse(UPSXmlDigester.java
:84)


I can execute the following line in the same JVM instance with no problems.

UPSResponseDTO upsRp = new UPSResponseDTO();

I have verified that the import is the same as the ClassNotFound

import mycompany.service.ups.dto.UPSResponseDTO;

Is it possible that digester uses a different classpath or classloaded for
the classloading it does?  I'm a little confused here (Actually very
confused)

Thanks,
Michael

Re: ClassNotFound [digester]

Posted by Michael Rasmussen <ra...@gmail.com>.
Thank you all.  I went with Option 3 since the problem didn't seem to be
bubbling into our Dev environment and I am only seeing it on my local box.
For completness sake, I did notice that the line
  d.setClassLoader(Thread.currentThread.getContex
>
> tClassLoader())


should be  Thread.currentThread(), but again thank you very much for the
help.

Michael



On 4/14/06, Simon Kitching <sk...@apache.org> wrote:
>
> Hi Michael,
>
> I think James is probably right.
>
> By default, Digester will look for classes using the same Classloader
> that loaded the Digester class. This means that if the
> commons-digester.jar file is in some container-level dir (rather than in
> WEB-INF/lib or similar) then it can't see that class.
>
> Option 1: put commons-digester.jar in the WEB-INF/lib (or equivalent) of
> your project. This is the cleanest solution, but it does require that
> "child-first" classloading is selected.
>
> Option 2: Tell digester to use the context classloader:
>   Digester d = new Digester();
>   d.setUseContextClassLoader(true);
>
> Option 3: Set the classloader explicitly:
>   Digester d = new Digester();
>   d.setClassLoader(Thread.currentThread.getContextClassLoader())
>   // this is equivalent to the above, assuming that the current
>   // class is from the webapp/ejb
>   // d.setClassLoader(this.getClass().getClassLoader());
>
> Regards,
>
> Simon
>
> On Fri, 2006-04-14 at 15:42 -0500, Michael Rasmussen wrote:
> > That line of code appears to be working properly.  I do not get a
> > ClassNotFoundException on the call to the below code.  Any thoughts on
> why
> > this might be occurring?  More information on my environment
> >
> > IBM JDK 1.3 WebSphere 5.0
> >
> > Thanks,
> > Michael
> >
> > On 4/14/06, James Carman <ja...@carmanconsulting.com> wrote:
> > >
> > > Try this:
> > >
> > > Thread.currentThread().getContextClassLoader().loadClass(
> > > "mycompany.service.ups.dto.UPSResponseDTO" )
> > >
> > > Digester, by default, uses the thread context classloader.  So, if it
> > > can't
> > > find the class, then Digester can't instantiate it.  You can
> optionally
> > > tell
> > > Digester what classloader to use by calling setClassLoader().  Hope
> that
> > > helps!
> > >
> > > James
> > >
> > > -----Original Message-----
> > > From: Michael Rasmussen [mailto:razmaspaz@gmail.com]
> > > Sent: Friday, April 14, 2006 3:49 PM
> > > To: commons-user@jakarta.apache.org
> > > Subject: ClassNotFound [digester]
> > >
> > > Hello,
> > >   I am working with digester and when executing this line of code
> > >
> > > upsResponseDTO = xmlDigester.parse(new ByteArrayInputStream(
> > > upsResponse.getBytes()));
> > >
> > > I get a ClassNotFoundException in digester
> > >
> > > org.apache.commons.digester.Digester  TRAS0014I: The following
> exception
> > > was
> > > logged java.lang.ClassNotFoundException:
> > > mycompany.service.ups.dto.UPSResponseDTO
> > >     at java.net.URLClassLoader.findClass(URLClassLoader.java(Compiled
> > > Code))
> > >     at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled
> Code))
> > >     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java
> (Compiled
> > > Code))
> > >     at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled
> Code))
> > >     at org.apache.commons.digester.ObjectCreateRule.begin(
> > > ObjectCreateRule.java:204)
> > >     at org.apache.commons.digester.Rule.begin(Rule.java:152)
> > >     at org.apache.commons.digester.Digester.startElement(Digester.java
> > > :1286)
> > >     at org.apache.xerces.parsers.AbstractSAXParser.startElement(
> > > AbstractSAXParser.java(Compiled Code))
> > >     at org.apache.xerces.impl.XMLNamespaceBinder.startElement(
> > > XMLNamespaceBinder.java(Compiled Code))
> > >     at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(
> > > XMLDTDValidator.java(Compiled Code))
> > >     at
> > > org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement
> (
> > > XMLDocumentFragmentScannerImpl.java(Compiled Code))
> > >     at
> > >
> > >
> org.apache.xerces.impl.XMLDocumentScannerImpl$ContentDispatcher.scanRootElem
> > > entHook
> > > (XMLDocumentScannerImpl.java:929)
> > >     at
> > >
> > >
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatc
> > > her.dispatch
> > > (XMLDocumentFragmentScannerImpl.java(Compiled Code))
> > >     at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(
> > > XMLDocumentFragmentScannerImpl.java(Compiled Code))
> > >     at org.apache.xerces.parsers.StandardParserConfiguration.parse(
> > > StandardParserConfiguration.java:525)
> > >     at org.apache.xerces.parsers.StandardParserConfiguration.parse(
> > > StandardParserConfiguration.java:581)
> > >     at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:147)
> > >     at org.apache.xerces.parsers.AbstractSAXParser.parse(
> > > AbstractSAXParser.java:1158)
> > >     at org.apache.commons.digester.Digester.parse(Digester.java:1591)
> > >     at mycompany.service.ups.client.UPSXmlDigester.parse(
> > > UPSXmlDigester.java
> > > :84)
> > >
> > >
> > > I can execute the following line in the same JVM instance with no
> > > problems.
> > >
> > > UPSResponseDTO upsRp = new UPSResponseDTO();
> > >
> > > I have verified that the import is the same as the ClassNotFound
> > >
> > > import mycompany.service.ups.dto.UPSResponseDTO;
> > >
> > > Is it possible that digester uses a different classpath or classloaded
> for
> > > the classloading it does?  I'm a little confused here (Actually very
> > > confused)
> > >
> > > Thanks,
> > > Michael
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: commons-user-help@jakarta.apache.org
> > >
> > >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>

Re: ClassNotFound [digester]

Posted by Simon Kitching <sk...@apache.org>.
Hi Michael, 

I think James is probably right.

By default, Digester will look for classes using the same Classloader
that loaded the Digester class. This means that if the
commons-digester.jar file is in some container-level dir (rather than in
WEB-INF/lib or similar) then it can't see that class.

Option 1: put commons-digester.jar in the WEB-INF/lib (or equivalent) of
your project. This is the cleanest solution, but it does require that
"child-first" classloading is selected. 

Option 2: Tell digester to use the context classloader:
  Digester d = new Digester();
  d.setUseContextClassLoader(true);
  
Option 3: Set the classloader explicitly:
  Digester d = new Digester();
  d.setClassLoader(Thread.currentThread.getContextClassLoader())
  // this is equivalent to the above, assuming that the current
  // class is from the webapp/ejb
  // d.setClassLoader(this.getClass().getClassLoader());

Regards,

Simon

On Fri, 2006-04-14 at 15:42 -0500, Michael Rasmussen wrote:
> That line of code appears to be working properly.  I do not get a
> ClassNotFoundException on the call to the below code.  Any thoughts on why
> this might be occurring?  More information on my environment
> 
> IBM JDK 1.3 WebSphere 5.0
> 
> Thanks,
> Michael
> 
> On 4/14/06, James Carman <ja...@carmanconsulting.com> wrote:
> >
> > Try this:
> >
> > Thread.currentThread().getContextClassLoader().loadClass(
> > "mycompany.service.ups.dto.UPSResponseDTO" )
> >
> > Digester, by default, uses the thread context classloader.  So, if it
> > can't
> > find the class, then Digester can't instantiate it.  You can optionally
> > tell
> > Digester what classloader to use by calling setClassLoader().  Hope that
> > helps!
> >
> > James
> >
> > -----Original Message-----
> > From: Michael Rasmussen [mailto:razmaspaz@gmail.com]
> > Sent: Friday, April 14, 2006 3:49 PM
> > To: commons-user@jakarta.apache.org
> > Subject: ClassNotFound [digester]
> >
> > Hello,
> >   I am working with digester and when executing this line of code
> >
> > upsResponseDTO = xmlDigester.parse(new ByteArrayInputStream(
> > upsResponse.getBytes()));
> >
> > I get a ClassNotFoundException in digester
> >
> > org.apache.commons.digester.Digester  TRAS0014I: The following exception
> > was
> > logged java.lang.ClassNotFoundException:
> > mycompany.service.ups.dto.UPSResponseDTO
> >     at java.net.URLClassLoader.findClass(URLClassLoader.java(Compiled
> > Code))
> >     at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
> >     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java(Compiled
> > Code))
> >     at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
> >     at org.apache.commons.digester.ObjectCreateRule.begin(
> > ObjectCreateRule.java:204)
> >     at org.apache.commons.digester.Rule.begin(Rule.java:152)
> >     at org.apache.commons.digester.Digester.startElement(Digester.java
> > :1286)
> >     at org.apache.xerces.parsers.AbstractSAXParser.startElement(
> > AbstractSAXParser.java(Compiled Code))
> >     at org.apache.xerces.impl.XMLNamespaceBinder.startElement(
> > XMLNamespaceBinder.java(Compiled Code))
> >     at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(
> > XMLDTDValidator.java(Compiled Code))
> >     at
> > org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(
> > XMLDocumentFragmentScannerImpl.java(Compiled Code))
> >     at
> >
> > org.apache.xerces.impl.XMLDocumentScannerImpl$ContentDispatcher.scanRootElem
> > entHook
> > (XMLDocumentScannerImpl.java:929)
> >     at
> >
> > org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatc
> > her.dispatch
> > (XMLDocumentFragmentScannerImpl.java(Compiled Code))
> >     at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(
> > XMLDocumentFragmentScannerImpl.java(Compiled Code))
> >     at org.apache.xerces.parsers.StandardParserConfiguration.parse(
> > StandardParserConfiguration.java:525)
> >     at org.apache.xerces.parsers.StandardParserConfiguration.parse(
> > StandardParserConfiguration.java:581)
> >     at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:147)
> >     at org.apache.xerces.parsers.AbstractSAXParser.parse(
> > AbstractSAXParser.java:1158)
> >     at org.apache.commons.digester.Digester.parse(Digester.java:1591)
> >     at mycompany.service.ups.client.UPSXmlDigester.parse(
> > UPSXmlDigester.java
> > :84)
> >
> >
> > I can execute the following line in the same JVM instance with no
> > problems.
> >
> > UPSResponseDTO upsRp = new UPSResponseDTO();
> >
> > I have verified that the import is the same as the ClassNotFound
> >
> > import mycompany.service.ups.dto.UPSResponseDTO;
> >
> > Is it possible that digester uses a different classpath or classloaded for
> > the classloading it does?  I'm a little confused here (Actually very
> > confused)
> >
> > Thanks,
> > Michael
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-user-help@jakarta.apache.org
> >
> >


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: ClassNotFound [digester]

Posted by Michael Rasmussen <ra...@gmail.com>.
That line of code appears to be working properly.  I do not get a
ClassNotFoundException on the call to the below code.  Any thoughts on why
this might be occurring?  More information on my environment

IBM JDK 1.3 WebSphere 5.0

Thanks,
Michael

On 4/14/06, James Carman <ja...@carmanconsulting.com> wrote:
>
> Try this:
>
> Thread.currentThread().getContextClassLoader().loadClass(
> "mycompany.service.ups.dto.UPSResponseDTO" )
>
> Digester, by default, uses the thread context classloader.  So, if it
> can't
> find the class, then Digester can't instantiate it.  You can optionally
> tell
> Digester what classloader to use by calling setClassLoader().  Hope that
> helps!
>
> James
>
> -----Original Message-----
> From: Michael Rasmussen [mailto:razmaspaz@gmail.com]
> Sent: Friday, April 14, 2006 3:49 PM
> To: commons-user@jakarta.apache.org
> Subject: ClassNotFound [digester]
>
> Hello,
>   I am working with digester and when executing this line of code
>
> upsResponseDTO = xmlDigester.parse(new ByteArrayInputStream(
> upsResponse.getBytes()));
>
> I get a ClassNotFoundException in digester
>
> org.apache.commons.digester.Digester  TRAS0014I: The following exception
> was
> logged java.lang.ClassNotFoundException:
> mycompany.service.ups.dto.UPSResponseDTO
>     at java.net.URLClassLoader.findClass(URLClassLoader.java(Compiled
> Code))
>     at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
>     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java(Compiled
> Code))
>     at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
>     at org.apache.commons.digester.ObjectCreateRule.begin(
> ObjectCreateRule.java:204)
>     at org.apache.commons.digester.Rule.begin(Rule.java:152)
>     at org.apache.commons.digester.Digester.startElement(Digester.java
> :1286)
>     at org.apache.xerces.parsers.AbstractSAXParser.startElement(
> AbstractSAXParser.java(Compiled Code))
>     at org.apache.xerces.impl.XMLNamespaceBinder.startElement(
> XMLNamespaceBinder.java(Compiled Code))
>     at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(
> XMLDTDValidator.java(Compiled Code))
>     at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(
> XMLDocumentFragmentScannerImpl.java(Compiled Code))
>     at
>
> org.apache.xerces.impl.XMLDocumentScannerImpl$ContentDispatcher.scanRootElem
> entHook
> (XMLDocumentScannerImpl.java:929)
>     at
>
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatc
> her.dispatch
> (XMLDocumentFragmentScannerImpl.java(Compiled Code))
>     at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(
> XMLDocumentFragmentScannerImpl.java(Compiled Code))
>     at org.apache.xerces.parsers.StandardParserConfiguration.parse(
> StandardParserConfiguration.java:525)
>     at org.apache.xerces.parsers.StandardParserConfiguration.parse(
> StandardParserConfiguration.java:581)
>     at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:147)
>     at org.apache.xerces.parsers.AbstractSAXParser.parse(
> AbstractSAXParser.java:1158)
>     at org.apache.commons.digester.Digester.parse(Digester.java:1591)
>     at mycompany.service.ups.client.UPSXmlDigester.parse(
> UPSXmlDigester.java
> :84)
>
>
> I can execute the following line in the same JVM instance with no
> problems.
>
> UPSResponseDTO upsRp = new UPSResponseDTO();
>
> I have verified that the import is the same as the ClassNotFound
>
> import mycompany.service.ups.dto.UPSResponseDTO;
>
> Is it possible that digester uses a different classpath or classloaded for
> the classloading it does?  I'm a little confused here (Actually very
> confused)
>
> Thanks,
> Michael
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>

RE: ClassNotFound [digester]

Posted by James Carman <ja...@carmanconsulting.com>.
Try this:

Thread.currentThread().getContextClassLoader().loadClass(
"mycompany.service.ups.dto.UPSResponseDTO" )

Digester, by default, uses the thread context classloader.  So, if it can't
find the class, then Digester can't instantiate it.  You can optionally tell
Digester what classloader to use by calling setClassLoader().  Hope that
helps!

James

-----Original Message-----
From: Michael Rasmussen [mailto:razmaspaz@gmail.com] 
Sent: Friday, April 14, 2006 3:49 PM
To: commons-user@jakarta.apache.org
Subject: ClassNotFound [digester]

Hello,
  I am working with digester and when executing this line of code

upsResponseDTO = xmlDigester.parse(new ByteArrayInputStream(
upsResponse.getBytes()));

I get a ClassNotFoundException in digester

org.apache.commons.digester.Digester  TRAS0014I: The following exception was
logged java.lang.ClassNotFoundException:
mycompany.service.ups.dto.UPSResponseDTO
    at java.net.URLClassLoader.findClass(URLClassLoader.java(Compiled Code))
    at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java(Compiled
Code))
    at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
    at org.apache.commons.digester.ObjectCreateRule.begin(
ObjectCreateRule.java:204)
    at org.apache.commons.digester.Rule.begin(Rule.java:152)
    at org.apache.commons.digester.Digester.startElement(Digester.java:1286)
    at org.apache.xerces.parsers.AbstractSAXParser.startElement(
AbstractSAXParser.java(Compiled Code))
    at org.apache.xerces.impl.XMLNamespaceBinder.startElement(
XMLNamespaceBinder.java(Compiled Code))
    at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(
XMLDTDValidator.java(Compiled Code))
    at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(
XMLDocumentFragmentScannerImpl.java(Compiled Code))
    at
org.apache.xerces.impl.XMLDocumentScannerImpl$ContentDispatcher.scanRootElem
entHook
(XMLDocumentScannerImpl.java:929)
    at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatc
her.dispatch
(XMLDocumentFragmentScannerImpl.java(Compiled Code))
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(
XMLDocumentFragmentScannerImpl.java(Compiled Code))
    at org.apache.xerces.parsers.StandardParserConfiguration.parse(
StandardParserConfiguration.java:525)
    at org.apache.xerces.parsers.StandardParserConfiguration.parse(
StandardParserConfiguration.java:581)
    at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:147)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(
AbstractSAXParser.java:1158)
    at org.apache.commons.digester.Digester.parse(Digester.java:1591)
    at mycompany.service.ups.client.UPSXmlDigester.parse(UPSXmlDigester.java
:84)


I can execute the following line in the same JVM instance with no problems.

UPSResponseDTO upsRp = new UPSResponseDTO();

I have verified that the import is the same as the ClassNotFound

import mycompany.service.ups.dto.UPSResponseDTO;

Is it possible that digester uses a different classpath or classloaded for
the classloading it does?  I'm a little confused here (Actually very
confused)

Thanks,
Michael



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org