In several contexts, I've been getting ClassNotFoundExceptions with
the same code that works without problem under Tomcat. Actually, I'm
currently on my third instance of this problem after being able to
work around the first two.
Maybe describing my workarounds will help someone understand what my
basic problem is.
First, calls to DocumentBuilderFactory.newInstance() were returning
embedded ClassNotFoundExceptions (embedded in a jaxp specific
exception). I got around this by first explicitly setting the system
property javax.xml.parsers.DocumentBuilderFactory before invoking
DocumentBuilderFactory.newInstance():
System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
"org.apache.crimson.jaxp.DocumentBuilderFactoryImpl");
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
Secondly, and similarly, calls to TransformerFactory.newInstance()
were also resulting in ClassNotFoundExceptions. And, similarly, the
work around was to set a system property prior to calling newInstance:
System.setProperty("javax.xml.transform.TransformerFactory",
"org.apache.xalan.processor.TransformerFactoryImpl");
TransformerFactory tFactory = TransformerFactory.newInstance();
Now, I'm getting another ClassNotFoundException when calling
org.apache.xalan.processor.TransformerFactoryImpl.newTransformer:
Transformer transformer = tFactory.newTransformer(stylesource);
Unfortunately, I've not yet been able to figure out a workaround.
Any help towards solving this problem would be greatly appreciated.
I'm not very well set up to be able to read news group replies, so
please copy responses to my email address
(chuck....@mail.sprint.com).
Thanks
Chuck
PS: Code excerpt attached:
protected String convertToHTML(String xml) throws FMSException {
try {
logger.info("Converting to HTML.");
logger.debug("javax.xml.parsers.DocumentBuilderFactory : " +
System.getProperty(
"javax.xml.parsers.DocumentBuilderFactory"));
System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
"org.apache.crimson.jaxp.DocumentBuilderFactoryImpl");
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
logger.debug("DocumentBuilderFactory class: " +
factory.getClass().toString());
// get stylesheet
InputStream styleInputStream
= MessageHandler.class.getResourceAsStream(xsltStylesheet);
logger.debug("Got styleInputStream.");
// get xml input stream
StringBufferInputStream xmlStringStream
= new StringBufferInputStream(xml);
logger.debug("Got xmlStringStream");
DocumentBuilder builder = factory.newDocumentBuilder();
logger.debug("Got DocumentBuilder.");
Document document = builder.parse(xmlStringStream);
// Use a Transformer for output
System.setProperty("javax.xml.transform.TransformerFactory",
"org.apache.xalan.processor.TransformerFactoryImpl");
TransformerFactory tFactory = TransformerFactory.newInstance();
logger.debug("Got tFactory");
logger.debug("TransformerFactory class: " +
tFactory.getClass().toString());
StreamSource stylesource = new StreamSource(styleInputStream);
Transformer transformer = tFactory.newTransformer(stylesource);
DOMSource source = new DOMSource(document);
ByteArrayOutputStream stringOutputStream = new
ByteArrayOutputStream();
StreamResult result = new StreamResult(stringOutputStream);
transformer.transform(source, result);
String resultString = stringOutputStream.toString();
return resultString;
} catch (TransformerConfigurationException tce) {
throw new FMSException("Transformer Factory error", tce);
} catch (FactoryConfigurationError e) {
Exception raisedEx = e.getException();
if (raisedEx != null) {
logger.debug("Raised Exception: " + raisedEx.getMessage());
raisedEx.printStackTrace();
}
logger.error("FactoryConfigurationError: ", e);
e.printStackTrace();
throw new FMSException("FactoryConfigurationError", e);
} catch (TransformerException te) {
throw new FMSException("Transformation error", te);
} catch (SAXException sxe) {
throw new FMSException(sxe);
} catch (ParserConfigurationException pce) {
throw new FMSException(pce);
} catch (IOException ioe) {
throw new FMSException(ioe);
}
}
java.lang.ClassNotFoundException
at java.lang.Class.forName1(Native Method)
at java.lang.Class.forName(Class.java:134)
at javax.xml.parsers.DocumentBuilderFactory.newInstance(DocumentBuilderFactory.java:115)
at com.sprint.fms.message.handler.MessageHandler.convertToHTML(MessageHandler.java:221)
at com.sprint.fms.message.handler.MessageHandler.process(MessageHandler.java:168)
at com.sprint.fms.servlet.LogonToFms.doGet(LogonToFms.java:80)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.servlet.engine.webapp.StrictServletInstance.doService(ServletManager.java:698)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet._service(StrictLifecycleServlet.java:157)
at com.ibm.servlet.engine.webapp.IdleServletState.service(StrictLifecycleServlet.java:279)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet.service(StrictLifecycleServlet.java:105)
at com.ibm.servlet.engine.webapp.ServletInstance.service(ServletManager.java:410)
at com.ibm.servlet.engine.webapp.ValidServletReferenceState.dispatch(ServletManager.java:842)
at com.ibm.servlet.engine.webapp.ServletInstanceReference.dispatch(ServletManager.java:768)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:484)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:274)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:167)
at com.ibm.servlet.engine.srt.WebAppInvoker.handleInvocationHook(WebGroup.java:899)
at com.ibm.servlet.engine.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:69)
at com.ibm.servlet.engine.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:107)
at com.ibm.servlet.engine.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:162)
at com.ibm.servlet.engine.oselistener.OSEListenerDispatcher.service(OSEListener.java:357)
at com.ibm.servlet.engine.oselistener.inproc.InProcAppServerDispatcher.service(InProcAppServerDispatcher.java:54)
at com.ibm.servlet.engine.oselistener.inproc.InProcThreadPrivateData.dispatchServletRequest(InProcThreadPrivateData.java:117)
at com.ibm.servlet.engine.oselistener.inproc.InProcPlugin.service(InProcPlugin.java:587)
chuck....@mail.sprint.com (cirvine) wrote in message news:<9e00abed.01092...@posting.google.com>...
I was beginning to suspect that the problem might have something to do
with file extraction from the jaxp jar files. Especially suspect was
extraction of resource files of any kind - I've had nasty struggles
with ascii/ebcdic issues involving resource files on OS390. So, for
the heck of it, I un-archived all the jaxp jar files and put them in
the WebSphere application classpath, and, wa la, the
ClassNotFoundExceptions went away. Now I get all the was to performing
the transformation where I get the exception:
java.lang.NoSuchMethodError: org.w3c.dom.Node: method
getLocalName()Ljava/lang/String; not found
This looks like I'm inadvertantly accessing an old dom class. I guess
what I really need at this point is a pointer to the right way of
integrating jaxp-1.1 with WebSphere 3.5 under OS390.
At this point, any help is immensely appreciated. Thanks
Chuck
PS: latest exception stack trace:
at org.apache.xpath.DOM2Helper.getLocalNameOfNode(DOM2Helper.java:326)
at org.apache.xalan.templates.TemplateList.getHead(TemplateList.java:471)
at org.apache.xalan.templates.TemplateList.getTemplate(TemplateList.java:528)
at org.apache.xalan.templates.ElemForEach.transformSelectedNodes(ElemForEach.java:432)
at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:193)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2154)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2097)
at org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(TransformerImpl.java:2029)
at org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1189)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:479)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1118)
at com.sprint.fms.message.handler.MessageHandler.convertToHTML(MessageHandler.java:251)
at com.sprint.fms.message.handler.MessageHandler.process(MessageHandler.java:169)
at com.sprint.fms.servlet.LogonToFms.doGet(LogonToFms.java:80)
...
chuck....@mail.sprint.com (cirvine) wrote in message news:<9e00abed.01092...@posting.google.com>...
I can get JAXP 1.0 work under Websphere 3.5 and 4.0 on NT since I
need to use Strust .... Do you think that will help you ? I can send
you teh details.
Regards
Kelvin AU
Any good WAS40 jobs out there ?
chuck....@mail.sprint.com (cirvine) wrote in message news:<9e00abed.0109...@posting.google.com>...