*
The moose likes JSP and the fly likes problem in Transformation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "problem in Transformation" Watch "problem in Transformation" New topic
Author

problem in Transformation

Joseph Bashir
Ranch Hand

Joined: Jun 16, 2004
Posts: 41
I want to create an HTML page from xml and xsl in JSP using TransformFactory and Transform. Here is the code:

<%
File xsl_File = new File("D:/_Joseph/www/customers.xsl");
File xml_File = new File("D:/_Joseph/www/customers.xml");
if(xsl_File.exists() && xml_File.exists()) {
StreamSource xslSource = new StreamSource(xsl_File);
StreamSource xmlSource = new StreamSource(xml_File);
StreamResult result = new StreamResult(out);
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(xslSource);
transformer.transform(xmlSource, result);
} else {
out.println("xml file and xsl file not exists");
}
%>



It throws the exception:

org.apache.jasper.JasperException: org.apache.xml.dtm.ref.DTMManagerDefault

Here is the detail of it:

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: org.apache.xml.dtm.ref.DTMManagerDefault
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

java.lang.ClassCastException: org.apache.xml.dtm.ref.DTMManagerDefault
org.apache.xml.dtm.DTMManager.newInstance(DTMManager.java:174)
org.apache.xpath.XPathContext.<init>(XPathContext.java:125)
org.apache.xalan.transformer.TransformerImpl.<init>(TransformerImpl.java:401)
org.apache.xalan.templates.StylesheetRoot.newTransformer(StylesheetRoot.java:197)
org.apache.xalan.processor.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:710)
org.apache.jsp.index_jsp._jspService(index_jsp.java:69)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


Can someone please tell me whats wrong with the code and please suggest the solution.

Thanks
Yuriy Zilbergleyt
Ranch Hand

Joined: Dec 13, 2004
Posts: 429
I ran your code without any problems. Your stack trace shows a Class Cast exception inside xalan.jar. Could be you have a bad jar, a bad system configuration or properties file somewhere, or its always possible you are missing some necessary jars.

The following jars may be necessary in addition to xalan.jar:

xerces.jar
xml-apis.jar
xerces.jar
saxpath.jar

-Yuriy
Joseph Bashir
Ranch Hand

Joined: Jun 16, 2004
Posts: 41
Yuriy Zilbergleyt

I had problem with xalan.jar. After fixing it everything was ok. Thank you very much.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in Transformation