473,287 Members | 1,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

problems reusing certain Transformers in Tomcat - NullPointerException

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.TransformerConfigurationExcept ion;
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.setRoo t(Unknown
Source)
at org.apache.xpath.axes.LocPathIterator.execute(Unkn own Source)
at org.apache.xpath.Expression.executeCharsToContentH andler(Unknown
Source)
at org.apache.xalan.templates.ElemValueOf.execute(Unk nown Source)
at org.apache.xalan.transformer.TransformerImpl.execu teChildTemplates(Unknown
Source)
at org.apache.xalan.templates.ElemLiteralResult.execu te(Unknown
Source)
at org.apache.xalan.transformer.TransformerImpl.execu teChildTemplates(Unknown
Source)
at org.apache.xalan.transformer.TransformerImpl.apply TemplateToNode(Unknown
Source)
at org.apache.xalan.transformer.TransformerImpl.trans formNode(Unknown
Source)
at org.apache.xalan.transformer.TransformerImpl.trans form(Unknown
Source)
at org.apache.xalan.transformer.TransformerImpl.trans form(Unknown
Source)
at org.apache.xalan.transformer.TransformerImpl.trans form(Unknown
Source)
at TestReuseTransformerServlet.service(TestReuseTrans formerServlet.java:51)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:643)
at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:643)
at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(St andardContext.java:2416)
at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:643)
at org.apache.catalina.valves.ErrorDispatcherValve.in voke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:641)
at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:641)
at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:643)
at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(Co yoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:601)
at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.processConnection(Http11Protocol.jav a:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(P oolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Unknown Source)
Jul 20 '05 #1
3 3141
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.newInstanc e()
.newTemplates( new
StreamSource(config.getServletContext().getRealPat h( "test.xslt" ) )

// in service()

Transformer reqTansformer=this.myTestTemplates.newTransformer( );

Hope this helps,
Peter

"Alan Krueger" <ml******@sneakemail.com> wrote in message
news:ee**************************@posting.google.c om...
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.TransformerConfigurationExcept ion;
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.setRoo t(Unknown
Source)
at org.apache.xpath.axes.LocPathIterator.execute(Unkn own Source)
at org.apache.xpath.Expression.executeCharsToContentH andler(Unknown
Source)
at org.apache.xalan.templates.ElemValueOf.execute(Unk nown Source)
at org.apache.xalan.transformer.TransformerImpl.execu teChildTemplates(Unknown Source)
at org.apache.xalan.templates.ElemLiteralResult.execu te(Unknown
Source)
at org.apache.xalan.transformer.TransformerImpl.execu teChildTemplates(Unknown Source)
at org.apache.xalan.transformer.TransformerImpl.apply TemplateToNode(Unknown Source)
at org.apache.xalan.transformer.TransformerImpl.trans formNode(Unknown
Source)
at org.apache.xalan.transformer.TransformerImpl.trans form(Unknown
Source)
at org.apache.xalan.transformer.TransformerImpl.trans form(Unknown
Source)
at org.apache.xalan.transformer.TransformerImpl.trans form(Unknown
Source)
at TestReuseTransformerServlet.service(TestReuseTrans formerServlet.java:51) at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(Application
FilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterCh
ain.java:193) at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.ja
va:256) at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invok
eNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.ja
va:191) at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invok
eNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(St andardContext.java:2416) at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:180
) at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invok
eNext(StandardPipeline.java:643) at org.apache.catalina.valves.ErrorDispatcherValve.in voke(ErrorDispatcherValve.
java:171) at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invok
eNext(StandardPipeline.java:641) at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:172
) at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invok
eNext(StandardPipeline.java:641) at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java
:174) at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invok
eNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(Co yoteAdapter.java:223) at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:601) at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.processConne
ction(Http11Protocol.java:392) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(P oolTcpEndpoint.java:565) at org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadPool.jav
a:619) at java.lang.Thread.run(Unknown Source)

Jul 20 '05 #2

"Alan Krueger" <ml******@sneakemail.com> wrote in message
news:ee**************************@posting.google.c om...
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.TransformerConfigurationExcept ion;
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.setRoo t(Unknown
Source)
at org.apache.xpath.axes.LocPathIterator.execute(Unkn own Source)
at org.apache.xpath.Expression.executeCharsToContentH andler(Unknown
Source)
at org.apache.xalan.templates.ElemValueOf.execute(Unk nown Source)
at org.apache.xalan.transformer.TransformerImpl.execu teChildTemplates(Unknown Source)
at org.apache.xalan.templates.ElemLiteralResult.execu te(Unknown
Source)
at org.apache.xalan.transformer.TransformerImpl.execu teChildTemplates(Unknown Source)
at org.apache.xalan.transformer.TransformerImpl.apply TemplateToNode(Unknown Source)
at org.apache.xalan.transformer.TransformerImpl.trans formNode(Unknown
Source)
at org.apache.xalan.transformer.TransformerImpl.trans form(Unknown
Source)
at org.apache.xalan.transformer.TransformerImpl.trans form(Unknown
Source)
at org.apache.xalan.transformer.TransformerImpl.trans form(Unknown
Source)
at TestReuseTransformerServlet.service(TestReuseTrans formerServlet.java:51) at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(Application
FilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterCh
ain.java:193) at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.ja
va:256) at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invok
eNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.ja
va:191) at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invok
eNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(St andardContext.java:2416) at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:180
) at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invok
eNext(StandardPipeline.java:643) at org.apache.catalina.valves.ErrorDispatcherValve.in voke(ErrorDispatcherValve.
java:171) at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invok
eNext(StandardPipeline.java:641) at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:172
) at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invok
eNext(StandardPipeline.java:641) at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java
:174) at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invok
eNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(Co yoteAdapter.java:223) at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:601) at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.processConne
ction(Http11Protocol.java:392) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(P oolTcpEndpoint.java:565) at org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadPool.jav
a:619) at java.lang.Thread.run(Unknown Source)

Jul 20 '05 #3
"William Brogden" <wb******@bga.com> wrote in message news:<3f********@giga.realtime.net>...
"Alan Krueger" <ml******@sneakemail.com> wrote in message
news:ee**************************@posting.google.c om...
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.
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jon Dellaria | last post by:
I have been using MySql as the database using JSP's and JavaBeans but recently I have wanted to start using the database connection pooling mechanism built into TomCat. I think I am having a...
5
by: Tom Martin | last post by:
I'm a Java Web developer NEWBIE that has inherited a website that fails every 2 hours due to poor connection pooling between Tomcat 4.0.6 and mySQL. In efforts to resolve this problem, I've...
0
by: Old-timer | last post by:
Not sure where else to post this. I'm sure I'm doing something wrong, but I wouldn't think a simple app would give me so much trouble. I've got a small test java class that I'm trying to have...
1
by: Jens Mueller | last post by:
Hi there, this is a Java-XML Question, so I am not sure whether this is the right place, haven't found anything better .... I try to convert a Java object to XML via SAX and let the FOP...
19
by: Dales | last post by:
I have a custom control that builds what we refer to as "Formlets" around some content in a page. These are basically content "wrapper" sections that are tables that have a colored header and...
1
by: Astera | last post by:
I seem to be having a problem using web parts after the beta 2 release. Any time I try to have the WebPartManager on any page, I get the exception listed below. I've gone through the steps listed...
1
by: marsetty | last post by:
when i am running tomcat manager i am getting this error java.lang.NullPointerException org.apache.catalina.manager.HTMLManagerServlet.list(HTMLManagerServlet.java:423)...
0
by: ycinar | last post by:
hey all, i am working on a Java project using JBuilder.. when i build my code its fine, but when comes to run, it doesnt run and displays the following logs.. i think there is JDK conflict.. ...
0
by: giridharpolaki | last post by:
I am getting the error below mentioned while I am trying to acess msaccess data base from apache , I have cross checked the program , its entirely perfect, I think there should be some problem with...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.