You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by David Geary <sa...@tri-lakesonline.net> on 2000/12/06 22:54:57 UTC

XSLT Transformations with Tomcat 3.2 Final and Xalan or XT?

Has anyone had success processing XML files with XSLT from a JSP page?
I've tried various combinations of XT and Xalan with Tomcat and Resin,
with very limited success.

I'd really like to process XML with Xalan or XT using Tomcat3.2, but
with Tomcat3.2 and Xalan I get a NoSuchMethodException from the bowels
of Xalan, and with Tomcat3.2 and XT the transformation fails silently.


david


Re: XSLT Transformations with Tomcat 3.2 Final and Xalan or XT?

Posted by John Gentilin <jo...@eyecatching.com>.
I think the answer for this comes from the Cocoon Documentation.
Tomcat has a minimal XML implementation called XML.jar. This
file has to be later in your CLASSPATH that Xerces or Xalan. Now
if you use Tomcat.sh, the script will put your existing CLASSPATH
after Tomcat's configured classpath. You can add Xerces and Xalan
into your $TOMCAT_HOME/lib directory but you need to rename them
so the appear at the top of a directory listing. i.e. aa_Xerces.jar
aa_Xalan.jar.

David Geary wrote:

> Has anyone had success processing XML files with XSLT from a JSP page?
> I've tried various combinations of XT and Xalan with Tomcat and Resin,
> with very limited success.
>
> I'd really like to process XML with Xalan or XT using Tomcat3.2, but
> with Tomcat3.2 and Xalan I get a NoSuchMethodException from the bowels
> of Xalan, and with Tomcat3.2 and XT the transformation fails silently.
>
> david


Re: XSLT Transformations with Tomcat 3.2 Final and Xalan or XT?

Posted by David Geary <sa...@tri-lakesonline.net>.
In case anyone's interested, I was using Xalan 2.0, which I just noticed
today is a Developer's alpha release. I switched to Xalan 1.2, and
everything works fine.

Thanks to all of you that responded.


david

David Geary wrote:

> Has anyone had success processing XML files with XSLT from a JSP page?
> I've tried various combinations of XT and Xalan with Tomcat and Resin,
> with very limited success.
>
> I'd really like to process XML with Xalan or XT using Tomcat3.2, but
> with Tomcat3.2 and Xalan I get a NoSuchMethodException from the bowels
> of Xalan, and with Tomcat3.2 and XT the transformation fails silently.
>
> david


Re: XSLT Transformations with Tomcat 3.2 Final and Xalan or XT?

Posted by David Geary <sa...@tri-lakesonline.net>.
Juan Ramirez wrote:

> Yes, I'm using it successfully now.  The problem you're seeing is
> because the xalan class files can't be found.  Look at your class path
> and make sure the xalan.jar is referenced somewhere.

It is.

>  If that doesn't
> work, sometimes, for some reason, I've had to unjar the classes for
> tomcat to find them.

I tried that with no success. Here's a more explicit description of what I'm
doing:

CLASSPATH:
.;F:/jdk1.3/lib/tools.jar;F:/jakarta-tomcat-3.2/lib/servlet.jar;F:/xalan-j_2_0_D

01/bin/xerces.jar;F:/xalan-j_2_0_D01/bin/xalan.jar;

I've tried many different variations of CLASSPATH; the one listed above is
the latest.

XslProcessorBean, which is called from a JSP custom tag, is listed below:

package beans.xsl;

import java.io.*;
import java.net.URL;
import javax.servlet.*;
import javax.servlet.http.*;

import org.xml.sax.InputSource;
import org.apache.trax.*;

public class XslProcessorBean implements Serializable {
 public XslProcessorBean() {}

 public void process(InputStream xmlstream,
         InputStream xslstream,
         HttpServletRequest req,
         HttpServletResponse res)
         throws IOException, ServletException {
  Processor processor = createProcessor();
  InputSource xmlSource = new InputSource(xmlstream),
        xslSource = new InputSource(xslstream);

  if(xmlSource != null && xslSource != null) {
   try {
    Templates templates = processor.process(xslSource);
    Transformer transformer = templates.newTransformer();
    transformer.transform(xmlSource, new Result(res.getWriter()));
   }
   catch(Exception ex) {
    throw new ServletException(ex);
   }
  }
 }
 private Processor createProcessor() throws ServletException {
  Processor processor = null;
  try {
   processor = Processor.newInstance("xslt");
  }
  catch(Exception ex) {
   throw new ServletException(ex);
  }
  return processor;
 }
}


This line (line 27; see below) results in the exception:
transformer.transform(xmlSource, new Result(res.getWriter()));


And here's the exception:

Location: /xslt/test.jsp
Internal Servlet Error:

javax.servlet.ServletException
 at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:399)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
 at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)

 at org.apache.tomcat.core.Handler.service(Handler.java:286)
 at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
 at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)

 at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
 at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)

 at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
 at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
 at java.lang.Thread.run(Thread.java:484)

Root cause:
java.lang.NoSuchMethodError
 at org.apache.xpath.DOM2Helper.getLocalNameOfNode(DOM2Helper.java:253)
 at org.apache.xalan.templates.TemplateList.getHead(TemplateList.java:416)
 at
org.apache.xalan.templates.TemplateList.getTemplate(TemplateList.java:470)
 at
org.apache.xalan.templates.StylesheetComposed.getWhiteSpaceInfo(StylesheetComposed.java:313)

 at org.apache.xalan.stree.Parent.appendChild(Parent.java:246)
 at org.apache.xalan.stree.DocumentImpl.appendChild(DocumentImpl.java:172)
 at org.apache.xalan.utils.DOMBuilder.append(DOMBuilder.java:175)
 at org.apache.xalan.utils.DOMBuilder.startElement(DOMBuilder.java:276)
 at
org.apache.xalan.stree.SourceTreeHandler.startElement(SourceTreeHandler.java:250)

 at org.apache.xerces.parsers.SAXParser.startElement(SAXParser.java:1371)
 at
org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidator.java:705)

 at
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:989)

 at
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:380)

 at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:861)
 at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:328)

 at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:642)

 at beans.xsl.XslProcessorBean.process(beans/xsl/XslProcessorBean.java:27)
 at tags.xsl.XslApplyTag.doEndTag(tags/xsl/XslApplyTag.java:27)
 at
_0002ftest_0002ejsptest_jsp_1._jspService(_0002ftest_0002ejsptest_jsp_1.java:112)

 at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
 at
org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:177)

 at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318)

 at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
 at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)

 at org.apache.tomcat.core.Handler.service(Handler.java:286)
 at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
 at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)

 at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
 at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)

 at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
 at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
 at java.lang.Thread.run(Thread.java:484)




Re: XSLT Transformations with Tomcat 3.2 Final and Xalan or XT?

Posted by Juan Ramirez <ju...@gluons.com>.
Yes, I'm using it successfully now.  The problem you're seeing is
because the xalan class files can't be found.  Look at your class path
and make sure the xalan.jar is referenced somewhere.  If that doesn't
work, sometimes, for some reason, I've had to unjar the classes for
tomcat to find them.

Juan

David Geary wrote:
> 
> Has anyone had success processing XML files with XSLT from a JSP page?
> I've tried various combinations of XT and Xalan with Tomcat and Resin,
> with very limited success.
> 
> I'd really like to process XML with Xalan or XT using Tomcat3.2, but
> with Tomcat3.2 and Xalan I get a NoSuchMethodException from the bowels
> of Xalan, and with Tomcat3.2 and XT the transformation fails silently.
> 
> david