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 <[EMAIL PROTECTED]> 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:[EMAIL PROTECTED] > > Sent: Friday, April 14, 2006 3:49 PM > > To: [email protected] > > 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: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
