problems reusing certain Transformers in Tomcat - NullPointerException

Discussion in 'Java' started by Alan Krueger, Sep 8, 2003.

  1. Alan Krueger

    Alan Krueger Guest

    Greetings,

    I've been able to cache Transformer objects in a Tomcat-based servlet
    application to avoid unnecessary Transformer rebuilding, except for
    certain ones on certain machines. I'm running Tomcat 4.1.27 under
    Eclipse 2.1.0 using the Sysdeo Tomcat plugin using j2re1.4.1_02 under
    Windows 2000 SP4.

    I've digested this down to a small (albeit convoluted) sample that
    exhibits the behavior reliably on my development workstation.
    Accessing this servlet more than once (hitting reload in the browser)
    causes a NullPointerException to be thrown from within the Transformer
    object.

    Any help in figuring out what we're doing wrong, or what could be
    causing this exception, would be greatly appreciated.

    Thanks,
    Alan Krueger


    ---begin TestReuseTransformerServlet.java---
    import java.io.IOException;

    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    import javax.servlet.http.HttpServlet;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.FactoryConfigurationError;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerConfigurationException;
    import javax.xml.transform.TransformerException;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamResult;
    import javax.xml.transform.stream.StreamSource;

    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.Text;

    public class TestReuseTransformerServlet extends HttpServlet
    {
    public void init( ServletConfig config ) throws ServletException
    {
    try
    {
    myTestTransformer = TransformerFactory.newInstance()
    .newTransformer( new StreamSource(
    config.getServletContext().getRealPath( "test.xslt" ) )
    );
    }
    catch ( TransformerConfigurationException e )
    {
    throw new ServletException( "Transformer exception: "
    + e.getMessage(), e );
    }
    }

    public void service( ServletRequest request, ServletResponse
    response )
    throws ServletException, IOException
    {
    try
    {
    Document document = DocumentBuilderFactory.newInstance()
    .newDocumentBuilder().newDocument();
    Element element = document.createElement( "input" );
    document.appendChild( element );
    Text text = document.createTextNode( "one" );
    element.appendChild( text );

    myTestTransformer.transform(
    new DOMSource( document ),
    new StreamResult( response.getOutputStream() ) );
    }
    catch ( ParserConfigurationException e )
    {
    throw new ServletException( "Parser config exception: "
    + e.getMessage(), e );
    }
    catch ( FactoryConfigurationError e )
    {
    throw new ServletException( "Factory config exception: "
    + e.getMessage(), e );
    }
    catch ( TransformerException e )
    {
    throw new ServletException( "Transformer exception: "
    + e.getMessage(), e );
    }
    }

    Transformer myTestTransformer;
    }
    ---end TestReuseTransformerServlet.java---

    ---begin test.xslt---
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:variable name="foo">
    <xsl:value-of select="/input"/>
    </xsl:variable>
    <xsl:variable name="otherPath" select="concat( 'test_', $foo,
    '.xml')"/>
    <xsl:variable name="otherPage" select="document($otherPath)"/>

    <xsl:template match="/">
    <foo>
    <xsl:value-of select="$otherPage/foo/foo[@id='id']/foo[@id='id']"/>
    </foo>
    </xsl:template>

    </xsl:stylesheet>
    ---end test.xslt---

    ---begin test_one.xml---
    <foo>
    <foo id="id">
    <foo id="id">one</foo>
    </foo>
    </foo>
    ---end test_one.xml---


    The exception I get is the following: (nothing snipped because I
    wasn't sure what would be significant)

    java.lang.NullPointerException
    at org.apache.xpath.axes.AxesWalker.setRoot(Unknown Source)
    at org.apache.xpath.axes.WalkingIteratorSorted.setRoot(Unknown
    Source)
    at org.apache.xpath.axes.LocPathIterator.execute(Unknown Source)
    at org.apache.xpath.Expression.executeCharsToContentHandler(Unknown
    Source)
    at org.apache.xalan.templates.ElemValueOf.execute(Unknown Source)
    at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(Unknown
    Source)
    at org.apache.xalan.templates.ElemLiteralResult.execute(Unknown
    Source)
    at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(Unknown
    Source)
    at org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(Unknown
    Source)
    at org.apache.xalan.transformer.TransformerImpl.transformNode(Unknown
    Source)
    at org.apache.xalan.transformer.TransformerImpl.transform(Unknown
    Source)
    at org.apache.xalan.transformer.TransformerImpl.transform(Unknown
    Source)
    at org.apache.xalan.transformer.TransformerImpl.transform(Unknown
    Source)
    at TestReuseTransformerServlet.service(TestReuseTransformerServlet.java:51)
    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:256)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:601)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
    at java.lang.Thread.run(Unknown Source)
    Alan Krueger, Sep 8, 2003
    #1
    1. Advertising

  2. not sure if this is the problem, but afaik the Transformer is not thread
    safe, so two simulataneous requests (even slightly overlapping) could cause
    problems.

    You could try making the servlet implement javax.servlet.SingleThreadModel
    to ensure requests are serialized inside your servlet and see if it works
    then.

    As a more general solution, I would suggest storing a compiled (thread-safe)
    Templates object in the servlet, and generating a new Transformer for each
    request.

    e.g.

    // shared Templates object

    private Templates myTestTemplates;

    // in init()

    this.myTestTemplates=TransformerFactory.newInstance()
    .newTemplates( new
    StreamSource(config.getServletContext().getRealPath( "test.xslt" ) )

    // in service()

    Transformer reqTansformer=this.myTestTemplates.newTransformer();

    Hope this helps,
    Peter

    "Alan Krueger" <> wrote in message
    news:...
    > Greetings,
    >
    > I've been able to cache Transformer objects in a Tomcat-based servlet
    > application to avoid unnecessary Transformer rebuilding, except for
    > certain ones on certain machines. I'm running Tomcat 4.1.27 under
    > Eclipse 2.1.0 using the Sysdeo Tomcat plugin using j2re1.4.1_02 under
    > Windows 2000 SP4.
    >
    > I've digested this down to a small (albeit convoluted) sample that
    > exhibits the behavior reliably on my development workstation.
    > Accessing this servlet more than once (hitting reload in the browser)
    > causes a NullPointerException to be thrown from within the Transformer
    > object.
    >
    > Any help in figuring out what we're doing wrong, or what could be
    > causing this exception, would be greatly appreciated.
    >
    > Thanks,
    > Alan Krueger
    >
    >
    > ---begin TestReuseTransformerServlet.java---
    > import java.io.IOException;
    >
    > import javax.servlet.ServletConfig;
    > import javax.servlet.ServletException;
    > import javax.servlet.ServletRequest;
    > import javax.servlet.ServletResponse;
    > import javax.servlet.http.HttpServlet;
    > import javax.xml.parsers.DocumentBuilderFactory;
    > import javax.xml.parsers.FactoryConfigurationError;
    > import javax.xml.parsers.ParserConfigurationException;
    > import javax.xml.transform.Transformer;
    > import javax.xml.transform.TransformerConfigurationException;
    > import javax.xml.transform.TransformerException;
    > import javax.xml.transform.TransformerFactory;
    > import javax.xml.transform.dom.DOMSource;
    > import javax.xml.transform.stream.StreamResult;
    > import javax.xml.transform.stream.StreamSource;
    >
    > import org.w3c.dom.Document;
    > import org.w3c.dom.Element;
    > import org.w3c.dom.Text;
    >
    > public class TestReuseTransformerServlet extends HttpServlet
    > {
    > public void init( ServletConfig config ) throws ServletException
    > {
    > try
    > {
    > myTestTransformer = TransformerFactory.newInstance()
    > .newTransformer( new StreamSource(
    > config.getServletContext().getRealPath( "test.xslt" ) )
    > );
    > }
    > catch ( TransformerConfigurationException e )
    > {
    > throw new ServletException( "Transformer exception: "
    > + e.getMessage(), e );
    > }
    > }
    >
    > public void service( ServletRequest request, ServletResponse
    > response )
    > throws ServletException, IOException
    > {
    > try
    > {
    > Document document = DocumentBuilderFactory.newInstance()
    > .newDocumentBuilder().newDocument();
    > Element element = document.createElement( "input" );
    > document.appendChild( element );
    > Text text = document.createTextNode( "one" );
    > element.appendChild( text );
    >
    > myTestTransformer.transform(
    > new DOMSource( document ),
    > new StreamResult( response.getOutputStream() ) );
    > }
    > catch ( ParserConfigurationException e )
    > {
    > throw new ServletException( "Parser config exception: "
    > + e.getMessage(), e );
    > }
    > catch ( FactoryConfigurationError e )
    > {
    > throw new ServletException( "Factory config exception: "
    > + e.getMessage(), e );
    > }
    > catch ( TransformerException e )
    > {
    > throw new ServletException( "Transformer exception: "
    > + e.getMessage(), e );
    > }
    > }
    >
    > Transformer myTestTransformer;
    > }
    > ---end TestReuseTransformerServlet.java---
    >
    > ---begin test.xslt---
    > <?xml version="1.0" encoding="ISO-8859-1"?>
    > <xsl:stylesheet version="1.0"
    > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    >
    > <xsl:variable name="foo">
    > <xsl:value-of select="/input"/>
    > </xsl:variable>
    > <xsl:variable name="otherPath" select="concat( 'test_', $foo,
    > '.xml')"/>
    > <xsl:variable name="otherPage" select="document($otherPath)"/>
    >
    > <xsl:template match="/">
    > <foo>
    > <xsl:value-of select="$otherPage/foo/foo[@id='id']/foo[@id='id']"/>
    > </foo>
    > </xsl:template>
    >
    > </xsl:stylesheet>
    > ---end test.xslt---
    >
    > ---begin test_one.xml---
    > <foo>
    > <foo id="id">
    > <foo id="id">one</foo>
    > </foo>
    > </foo>
    > ---end test_one.xml---
    >
    >
    > The exception I get is the following: (nothing snipped because I
    > wasn't sure what would be significant)
    >
    > java.lang.NullPointerException
    > at org.apache.xpath.axes.AxesWalker.setRoot(Unknown Source)
    > at org.apache.xpath.axes.WalkingIteratorSorted.setRoot(Unknown
    > Source)
    > at org.apache.xpath.axes.LocPathIterator.execute(Unknown Source)
    > at org.apache.xpath.Expression.executeCharsToContentHandler(Unknown
    > Source)
    > at org.apache.xalan.templates.ElemValueOf.execute(Unknown Source)
    > at

    org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(Unknown
    > Source)
    > at org.apache.xalan.templates.ElemLiteralResult.execute(Unknown
    > Source)
    > at

    org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(Unknown
    > Source)
    > at

    org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(Unknown
    > Source)
    > at org.apache.xalan.transformer.TransformerImpl.transformNode(Unknown
    > Source)
    > at org.apache.xalan.transformer.TransformerImpl.transform(Unknown
    > Source)
    > at org.apache.xalan.transformer.TransformerImpl.transform(Unknown
    > Source)
    > at org.apache.xalan.transformer.TransformerImpl.transform(Unknown
    > Source)
    > at

    TestReuseTransformerServlet.service(TestReuseTransformerServlet.java:51)
    > at

    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
    FilterChain.java:247)
    > at

    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
    ain.java:193)
    > at

    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
    va:256)
    > at

    org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
    eNext(StandardPipeline.java:643)
    > at

    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    > at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    > at

    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
    va:191)
    > at

    org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
    eNext(StandardPipeline.java:643)
    > at

    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    > at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    > at

    org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416)
    > at

    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180
    )
    > at

    org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
    eNext(StandardPipeline.java:643)
    > at

    org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.
    java:171)
    > at

    org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
    eNext(StandardPipeline.java:641)
    > at

    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172
    )
    > at

    org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
    eNext(StandardPipeline.java:641)
    > at

    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    > at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    > at

    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
    :174)
    > at

    org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
    eNext(StandardPipeline.java:643)
    > at

    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    > at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    > at

    org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
    > at

    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:601)
    > at

    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConne
    ction(Http11Protocol.java:392)
    > at

    org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
    > at

    org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav
    a:619)
    > at java.lang.Thread.run(Unknown Source)
    Peter McDonnell, Sep 9, 2003
    #2
    1. Advertising

  3. "Alan Krueger" <> wrote in message
    news:...
    > Greetings,
    >
    > I've been able to cache Transformer objects in a Tomcat-based servlet
    > application to avoid unnecessary Transformer rebuilding, except for
    > certain ones on certain machines. I'm running Tomcat 4.1.27 under
    > Eclipse 2.1.0 using the Sysdeo Tomcat plugin using j2re1.4.1_02 under
    > Windows 2000 SP4.
    >
    > I've digested this down to a small (albeit convoluted) sample that
    > exhibits the behavior reliably on my development workstation.
    > Accessing this servlet more than once (hitting reload in the browser)
    > causes a NullPointerException to be thrown from within the Transformer
    > object.


    The javax.xml.transform.Transformer API states that an instance can not be
    used
    in multiple Threads running concurrently. You should not be surprised that
    it
    blows up with two "simultaneous" requests.

    >
    > Any help in figuring out what we're doing wrong, or what could be
    > causing this exception, would be greatly appreciated.
    >
    > Thanks,
    > Alan Krueger
    >
    >
    > ---begin TestReuseTransformerServlet.java---
    > import java.io.IOException;
    >
    > import javax.servlet.ServletConfig;
    > import javax.servlet.ServletException;
    > import javax.servlet.ServletRequest;
    > import javax.servlet.ServletResponse;
    > import javax.servlet.http.HttpServlet;
    > import javax.xml.parsers.DocumentBuilderFactory;
    > import javax.xml.parsers.FactoryConfigurationError;
    > import javax.xml.parsers.ParserConfigurationException;
    > import javax.xml.transform.Transformer;
    > import javax.xml.transform.TransformerConfigurationException;
    > import javax.xml.transform.TransformerException;
    > import javax.xml.transform.TransformerFactory;
    > import javax.xml.transform.dom.DOMSource;
    > import javax.xml.transform.stream.StreamResult;
    > import javax.xml.transform.stream.StreamSource;
    >
    > import org.w3c.dom.Document;
    > import org.w3c.dom.Element;
    > import org.w3c.dom.Text;
    >
    > public class TestReuseTransformerServlet extends HttpServlet
    > {
    > public void init( ServletConfig config ) throws ServletException
    > {
    > try
    > {
    > myTestTransformer = TransformerFactory.newInstance()
    > .newTransformer( new StreamSource(
    > config.getServletContext().getRealPath( "test.xslt" ) )
    > );
    > }
    > catch ( TransformerConfigurationException e )
    > {
    > throw new ServletException( "Transformer exception: "
    > + e.getMessage(), e );
    > }
    > }
    >
    > public void service( ServletRequest request, ServletResponse
    > response )
    > throws ServletException, IOException
    > {
    > try
    > {
    > Document document = DocumentBuilderFactory.newInstance()
    > .newDocumentBuilder().newDocument();
    > Element element = document.createElement( "input" );
    > document.appendChild( element );
    > Text text = document.createTextNode( "one" );
    > element.appendChild( text );
    >
    > myTestTransformer.transform(
    > new DOMSource( document ),
    > new StreamResult( response.getOutputStream() ) );
    > }
    > catch ( ParserConfigurationException e )
    > {
    > throw new ServletException( "Parser config exception: "
    > + e.getMessage(), e );
    > }
    > catch ( FactoryConfigurationError e )
    > {
    > throw new ServletException( "Factory config exception: "
    > + e.getMessage(), e );
    > }
    > catch ( TransformerException e )
    > {
    > throw new ServletException( "Transformer exception: "
    > + e.getMessage(), e );
    > }
    > }
    >
    > Transformer myTestTransformer;
    > }
    > ---end TestReuseTransformerServlet.java---
    >
    > ---begin test.xslt---
    > <?xml version="1.0" encoding="ISO-8859-1"?>
    > <xsl:stylesheet version="1.0"
    > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    >
    > <xsl:variable name="foo">
    > <xsl:value-of select="/input"/>
    > </xsl:variable>
    > <xsl:variable name="otherPath" select="concat( 'test_', $foo,
    > '.xml')"/>
    > <xsl:variable name="otherPage" select="document($otherPath)"/>
    >
    > <xsl:template match="/">
    > <foo>
    > <xsl:value-of select="$otherPage/foo/foo[@id='id']/foo[@id='id']"/>
    > </foo>
    > </xsl:template>
    >
    > </xsl:stylesheet>
    > ---end test.xslt---
    >
    > ---begin test_one.xml---
    > <foo>
    > <foo id="id">
    > <foo id="id">one</foo>
    > </foo>
    > </foo>
    > ---end test_one.xml---
    >
    >
    > The exception I get is the following: (nothing snipped because I
    > wasn't sure what would be significant)
    >
    > java.lang.NullPointerException
    > at org.apache.xpath.axes.AxesWalker.setRoot(Unknown Source)
    > at org.apache.xpath.axes.WalkingIteratorSorted.setRoot(Unknown
    > Source)
    > at org.apache.xpath.axes.LocPathIterator.execute(Unknown Source)
    > at org.apache.xpath.Expression.executeCharsToContentHandler(Unknown
    > Source)
    > at org.apache.xalan.templates.ElemValueOf.execute(Unknown Source)
    > at

    org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(Unknown
    > Source)
    > at org.apache.xalan.templates.ElemLiteralResult.execute(Unknown
    > Source)
    > at

    org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(Unknown
    > Source)
    > at

    org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(Unknown
    > Source)
    > at org.apache.xalan.transformer.TransformerImpl.transformNode(Unknown
    > Source)
    > at org.apache.xalan.transformer.TransformerImpl.transform(Unknown
    > Source)
    > at org.apache.xalan.transformer.TransformerImpl.transform(Unknown
    > Source)
    > at org.apache.xalan.transformer.TransformerImpl.transform(Unknown
    > Source)
    > at

    TestReuseTransformerServlet.service(TestReuseTransformerServlet.java:51)
    > at

    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
    FilterChain.java:247)
    > at

    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
    ain.java:193)
    > at

    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
    va:256)
    > at

    org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
    eNext(StandardPipeline.java:643)
    > at

    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    > at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    > at

    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
    va:191)
    > at

    org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
    eNext(StandardPipeline.java:643)
    > at

    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    > at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    > at

    org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416)
    > at

    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180
    )
    > at

    org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
    eNext(StandardPipeline.java:643)
    > at

    org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.
    java:171)
    > at

    org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
    eNext(StandardPipeline.java:641)
    > at

    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172
    )
    > at

    org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
    eNext(StandardPipeline.java:641)
    > at

    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    > at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    > at

    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
    :174)
    > at

    org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
    eNext(StandardPipeline.java:643)
    > at

    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
    > at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    > at

    org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
    > at

    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:601)
    > at

    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConne
    ction(Http11Protocol.java:392)
    > at

    org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
    > at

    org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav
    a:619)
    > at java.lang.Thread.run(Unknown Source)
    William Brogden, Sep 9, 2003
    #3
  4. Alan Krueger

    Alan Krueger Guest

    "William Brogden" <> wrote in message news:<3f5dd00e$>...
    > "Alan Krueger" <> wrote in message
    > news:...
    > > Greetings,
    > >
    > > I've been able to cache Transformer objects in a Tomcat-based servlet
    > > application to avoid unnecessary Transformer rebuilding, except for
    > > certain ones on certain machines. I'm running Tomcat 4.1.27 under
    > > Eclipse 2.1.0 using the Sysdeo Tomcat plugin using j2re1.4.1_02 under
    > > Windows 2000 SP4.
    > >
    > > I've digested this down to a small (albeit convoluted) sample that
    > > exhibits the behavior reliably on my development workstation.
    > > Accessing this servlet more than once (hitting reload in the browser)
    > > causes a NullPointerException to be thrown from within the Transformer
    > > object.

    >
    > The javax.xml.transform.Transformer API states that an instance can not be
    > used in multiple Threads running concurrently. You should not be surprised
    > that it blows up with two "simultaneous" requests.


    I didn't say "simultaneous" requests. I was the only one running
    against Tomcat on my workstation, and the second request was not
    performed until the first one had completed. I was running Tomcat in
    Eclipse with a breakpoint, so I know there are no threading issues
    entering here.

    This sample case was contrived to be as small as possible to manifest
    the problem I was having, and obviously could not contain
    thread-safety and the pooling code present in the full web
    application. I'm sorry if this minimization of the code caused any
    confusion, but usually presenting a minimal manifestation of an error
    is recommended in programming newsgroups.

    In any case, I ended up blowing away all Java JDKs and runtimes, all
    Xerces/Xalan instances, and Eclipse with all plugins. I reinstalled
    everything with only JDK 1.3_09 and things now seem to be working
    without any Java or XSLT changes. Weird.
    Alan Krueger, Sep 12, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dhek Bhun Kho
    Replies:
    0
    Views:
    2,225
    Dhek Bhun Kho
    Jul 9, 2003
  2. Replies:
    0
    Views:
    635
  3. Replies:
    7
    Views:
    7,516
    Anonymous
    Oct 14, 2005
  4. Alan Krueger
    Replies:
    3
    Views:
    474
    Alan Krueger
    Sep 12, 2003
  5. AC [MVP MCMS]

    Web Part connections & using transformers...

    AC [MVP MCMS], Jul 28, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    490
    AC [MVP MCMS]
    Jul 28, 2006
Loading...

Share This Page