ClassNotFoundException: org.apache.xml.serializer.TreeWalker

Sara picture Sara · May 4, 2012 · Viewed 19.4k times · Source

I wrote a simple app with xml database & appache tomcat. I worked fine, till I tried to zip the workspace while it was open. After that anytime I try to create tomcat server promptly I get this error:

ClassNotFoundException: org.apache.xml.serializer.TreeWalker

So I left this. Now I was working on xmlspy, trying to generate a pdf file using tomcat FO engine. I installed new tomcat & pointed to this in the xmlspy. Now when I try to run fo in xmlspy I get the following error.

Note: The serializer.jar & xalan jar files are already in lib folder.

log4j:WARN No appenders could be found for logger (org.apache.fop.util.ContentHandlerFactoryRegistry).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xml/serializer/TreeWalker
  at org.apache.xalan.processor.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:823)
  at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:278)
  at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:130)
  at org.apache.fop.cli.Main.startFOP(Main.java:174)
  at org.apache.fop.cli.Main.main(Main.java:205)
Caused by: java.lang.ClassNotFoundException: org.apache.xml.serializer.TreeWalker
  at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
  at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
  ... 5 more

Answer

Otto M. picture Otto M. · Apr 23, 2019

Following helped me:

System.setProperty("javax.xml.transform.TransformerFactory", "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl");