TransformerFactory.newInstance() stops?
I have code written that converts my Document to a string prior to printing
TransformerFactory tf = TransformerFactory.newInstance();
Transformer trans = tf.newTransformer();
trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
trans.setOutputProperty(OutputKeys.INDENT, "yes");
//create string from xml tree
StringWriter sw = new StringWriter();
StreamResult result = new StreamResult(sw);
DOMSource source = new DOMSource(doc);
trans.transform(source, result);
xmlString = sw.toString();
This works perfectly in a standalone program. I have cut and pasted this code directly into a module running under jakarta-tomcat-5.0.28 (JDK 1.5) and it stops 开发者_运维知识库prior to the TransformerFactory.newInstance(). Is there something that I need to tell my jvm under jakarta about where to find the appropriate classes? BTW, the call never returns, it just stops with no response.
What error do you get? It sounds like you need to have a Java XML library on your classpath, if you run under Java 6 you have JAXP TransformerFactory in your classpath by default, otherwise you will need to add Xalan/SAX etc. to your classpath.
精彩评论