Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error running Xalan sample: servlet.SimpleXSLTServlet

 
Francois Bourgault
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I try to run the above Xalan sample and I get the following error:
org.apache.xalan.processor.TransformerFactoryImpljava.lang.ClassCastException: org.apache.xalan.processor.TransformerFactoryImpl at javax.xml.transform.TransformerFactory.newInstance(TransformerFactory.java:148) at servlet.SimpleXSLTServlet.doGet(SimpleXSLTServlet.java:98) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:201) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at

below is part of the servlet:
try
{
TransformerFactory tFactory = TransformerFactory.newInstance();
// Get the XML input document and the stylesheet.
Source xmlSource = new StreamSource(new URL("file:todo.xml").openStream());
Source xslSource = new StreamSource(new URL("file:todo.xsl").openStream());

// Generate the transformer.
Transformer transformer = tFactory.newTransformer(xslSource);
System.out.println( "1- SimpleXSLTServlet" );

// Perform the transformation, sending the output to the response.
transformer.transform(xmlSource, new StreamResult(out));

System.out.println( "2- SimpleXSLTServlet" );
}
catch (Exception e)
{
System.out.println( "Catch- SimpleXSLTServlet" );
out.write(e.getMessage());
e.printStackTrace(out);
}
out.close();
When I call the servlet thru an HTML page I get:
1- SimpleXSLTServlet
It never gets to the 2nd System.out.println
I did setup xalanservlet.jar in the classpath, but it doesn't work. The very 1st error is a "ClassCastException", Not sure what else I need to setup. Has someone else got the same problem?
Any help would be appreciated.
Francois.
 
Francois Bourgault
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I forgot to mention, I use jdk1.4
Francois
 
Francois Bourgault
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I forgot to mention, I use jdk1.4
Francois
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic