473,554 Members | 3,281 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problems reusing certain Transformers in Tomcat - NullPointerExce ption

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 NullPointerExce ption 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 TestReuseTransf ormerServlet.ja va---
import java.io.IOExcep tion;

import javax.servlet.S ervletConfig;
import javax.servlet.S ervletException ;
import javax.servlet.S ervletRequest;
import javax.servlet.S ervletResponse;
import javax.servlet.h ttp.HttpServlet ;
import javax.xml.parse rs.DocumentBuil derFactory;
import javax.xml.parse rs.FactoryConfi gurationError;
import javax.xml.parse rs.ParserConfig urationExceptio n;
import javax.xml.trans form.Transforme r;
import javax.xml.trans form.Transforme rConfigurationE xception;
import javax.xml.trans form.Transforme rException;
import javax.xml.trans form.Transforme rFactory;
import javax.xml.trans form.dom.DOMSou rce;
import javax.xml.trans form.stream.Str eamResult;
import javax.xml.trans form.stream.Str eamSource;

import org.w3c.dom.Doc ument;
import org.w3c.dom.Ele ment;
import org.w3c.dom.Tex t;

public class TestReuseTransf ormerServlet extends HttpServlet
{
public void init( ServletConfig config ) throws ServletExceptio n
{
try
{
myTestTransform er = TransformerFact ory.newInstance ()
.newTransformer ( new StreamSource(
config.getServl etContext().get RealPath( "test.xslt" ) )
);
}
catch ( TransformerConf igurationExcept ion e )
{
throw new ServletExceptio n( "Transforme r exception: "
+ e.getMessage(), e );
}
}

public void service( ServletRequest request, ServletResponse
response )
throws ServletExceptio n, IOException
{
try
{
Document document = DocumentBuilder Factory.newInst ance()
.newDocumentBui lder().newDocum ent();
Element element = document.create Element( "input" );
document.append Child( element );
Text text = document.create TextNode( "one" );
element.appendC hild( text );

myTestTransform er.transform(
new DOMSource( document ),
new StreamResult( response.getOut putStream() ) );
}
catch ( ParserConfigura tionException e )
{
throw new ServletExceptio n( "Parser config exception: "
+ e.getMessage(), e );
}
catch ( FactoryConfigur ationError e )
{
throw new ServletExceptio n( "Factory config exception: "
+ e.getMessage(), e );
}
catch ( TransformerExce ption e )
{
throw new ServletExceptio n( "Transforme r exception: "
+ e.getMessage(), e );
}
}

Transformer myTestTransform er;
}
---end TestReuseTransf ormerServlet.ja va---

---begin test.xslt---
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:styleshe et 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="documen t($otherPath)"/>

<xsl:template match="/">
<foo>
<xsl:value-of select="$otherP age/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.NullP ointerException
at org.apache.xpat h.axes.AxesWalk er.setRoot(Unkn own Source)
at org.apache.xpat h.axes.WalkingI teratorSorted.s etRoot(Unknown
Source)
at org.apache.xpat h.axes.LocPathI terator.execute (Unknown Source)
at org.apache.xpat h.Expression.ex ecuteCharsToCon tentHandler(Unk nown
Source)
at org.apache.xala n.templates.Ele mValueOf.execut e(Unknown Source)
at org.apache.xala n.transformer.T ransformerImpl. executeChildTem plates(Unknown
Source)
at org.apache.xala n.templates.Ele mLiteralResult. execute(Unknown
Source)
at org.apache.xala n.transformer.T ransformerImpl. executeChildTem plates(Unknown
Source)
at org.apache.xala n.transformer.T ransformerImpl. applyTemplateTo Node(Unknown
Source)
at org.apache.xala n.transformer.T ransformerImpl. transformNode(U nknown
Source)
at org.apache.xala n.transformer.T ransformerImpl. transform(Unkno wn
Source)
at org.apache.xala n.transformer.T ransformerImpl. transform(Unkno wn
Source)
at org.apache.xala n.transformer.T ransformerImpl. transform(Unkno wn
Source)
at TestReuseTransf ormerServlet.se rvice(TestReuse TransformerServ let.java:51)
at org.apache.cata lina.core.Appli cationFilterCha in.internalDoFi lter(Applicatio nFilterChain.ja va:247)
at org.apache.cata lina.core.Appli cationFilterCha in.doFilter(App licationFilterC hain.java:193)
at org.apache.cata lina.core.Stand ardWrapperValve .invoke(Standar dWrapperValve.j ava:256)
at org.apache.cata lina.core.Stand ardPipeline$Sta ndardPipelineVa lveContext.invo keNext(Standard Pipeline.java:6 43)
at org.apache.cata lina.core.Stand ardPipeline.inv oke(StandardPip eline.java:480)
at org.apache.cata lina.core.Conta inerBase.invoke (ContainerBase. java:995)
at org.apache.cata lina.core.Stand ardContextValve .invoke(Standar dContextValve.j ava:191)
at org.apache.cata lina.core.Stand ardPipeline$Sta ndardPipelineVa lveContext.invo keNext(Standard Pipeline.java:6 43)
at org.apache.cata lina.core.Stand ardPipeline.inv oke(StandardPip eline.java:480)
at org.apache.cata lina.core.Conta inerBase.invoke (ContainerBase. java:995)
at org.apache.cata lina.core.Stand ardContext.invo ke(StandardCont ext.java:2416)
at org.apache.cata lina.core.Stand ardHostValve.in voke(StandardHo stValve.java:18 0)
at org.apache.cata lina.core.Stand ardPipeline$Sta ndardPipelineVa lveContext.invo keNext(Standard Pipeline.java:6 43)
at org.apache.cata lina.valves.Err orDispatcherVal ve.invoke(Error DispatcherValve .java:171)
at org.apache.cata lina.core.Stand ardPipeline$Sta ndardPipelineVa lveContext.invo keNext(Standard Pipeline.java:6 41)
at org.apache.cata lina.valves.Err orReportValve.i nvoke(ErrorRepo rtValve.java:17 2)
at org.apache.cata lina.core.Stand ardPipeline$Sta ndardPipelineVa lveContext.invo keNext(Standard Pipeline.java:6 41)
at org.apache.cata lina.core.Stand ardPipeline.inv oke(StandardPip eline.java:480)
at org.apache.cata lina.core.Conta inerBase.invoke (ContainerBase. java:995)
at org.apache.cata lina.core.Stand ardEngineValve. invoke(Standard EngineValve.jav a:174)
at org.apache.cata lina.core.Stand ardPipeline$Sta ndardPipelineVa lveContext.invo keNext(Standard Pipeline.java:6 43)
at org.apache.cata lina.core.Stand ardPipeline.inv oke(StandardPip eline.java:480)
at org.apache.cata lina.core.Conta inerBase.invoke (ContainerBase. java:995)
at org.apache.coyo te.tomcat4.Coyo teAdapter.servi ce(CoyoteAdapte r.java:223)
at org.apache.coyo te.http11.Http1 1Processor.proc ess(Http11Proce ssor.java:601)
at org.apache.coyo te.http11.Http1 1Protocol$Http1 1ConnectionHand ler.processConn ection(Http11Pr otocol.java:392 )
at org.apache.tomc at.util.net.Tcp WorkerThread.ru nIt(PoolTcpEndp oint.java:565)
at org.apache.tomc at.util.threads .ThreadPool$Con trolRunnable.ru n(ThreadPool.ja va:619)
at java.lang.Threa d.run(Unknown Source)
Jul 20 '05 #1
3 3161
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.S ingleThreadMode l
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.myTestTemp lates=Transform erFactory.newIn stance()
.newTemplates( new
StreamSource(co nfig.getServlet Context().getRe alPath( "test.xslt" ) )

// in service()

Transformer reqTansformer=t his.myTestTempl ates.newTransfo rmer();

Hope this helps,
Peter

"Alan Krueger" <ml******@sneak email.com> wrote in message
news:ee******** *************** ***@posting.goo gle.com...
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 NullPointerExce ption 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 TestReuseTransf ormerServlet.ja va---
import java.io.IOExcep tion;

import javax.servlet.S ervletConfig;
import javax.servlet.S ervletException ;
import javax.servlet.S ervletRequest;
import javax.servlet.S ervletResponse;
import javax.servlet.h ttp.HttpServlet ;
import javax.xml.parse rs.DocumentBuil derFactory;
import javax.xml.parse rs.FactoryConfi gurationError;
import javax.xml.parse rs.ParserConfig urationExceptio n;
import javax.xml.trans form.Transforme r;
import javax.xml.trans form.Transforme rConfigurationE xception;
import javax.xml.trans form.Transforme rException;
import javax.xml.trans form.Transforme rFactory;
import javax.xml.trans form.dom.DOMSou rce;
import javax.xml.trans form.stream.Str eamResult;
import javax.xml.trans form.stream.Str eamSource;

import org.w3c.dom.Doc ument;
import org.w3c.dom.Ele ment;
import org.w3c.dom.Tex t;

public class TestReuseTransf ormerServlet extends HttpServlet
{
public void init( ServletConfig config ) throws ServletExceptio n
{
try
{
myTestTransform er = TransformerFact ory.newInstance ()
.newTransformer ( new StreamSource(
config.getServl etContext().get RealPath( "test.xslt" ) )
);
}
catch ( TransformerConf igurationExcept ion e )
{
throw new ServletExceptio n( "Transforme r exception: "
+ e.getMessage(), e );
}
}

public void service( ServletRequest request, ServletResponse
response )
throws ServletExceptio n, IOException
{
try
{
Document document = DocumentBuilder Factory.newInst ance()
.newDocumentBui lder().newDocum ent();
Element element = document.create Element( "input" );
document.append Child( element );
Text text = document.create TextNode( "one" );
element.appendC hild( text );

myTestTransform er.transform(
new DOMSource( document ),
new StreamResult( response.getOut putStream() ) );
}
catch ( ParserConfigura tionException e )
{
throw new ServletExceptio n( "Parser config exception: "
+ e.getMessage(), e );
}
catch ( FactoryConfigur ationError e )
{
throw new ServletExceptio n( "Factory config exception: "
+ e.getMessage(), e );
}
catch ( TransformerExce ption e )
{
throw new ServletExceptio n( "Transforme r exception: "
+ e.getMessage(), e );
}
}

Transformer myTestTransform er;
}
---end TestReuseTransf ormerServlet.ja va---

---begin test.xslt---
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:styleshe et 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="documen t($otherPath)"/>

<xsl:template match="/">
<foo>
<xsl:value-of select="$otherP age/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.NullP ointerException
at org.apache.xpat h.axes.AxesWalk er.setRoot(Unkn own Source)
at org.apache.xpat h.axes.WalkingI teratorSorted.s etRoot(Unknown
Source)
at org.apache.xpat h.axes.LocPathI terator.execute (Unknown Source)
at org.apache.xpat h.Expression.ex ecuteCharsToCon tentHandler(Unk nown
Source)
at org.apache.xala n.templates.Ele mValueOf.execut e(Unknown Source)
at org.apache.xala n.transformer.T ransformerImpl. executeChildTem plates(Unknown Source)
at org.apache.xala n.templates.Ele mLiteralResult. execute(Unknown
Source)
at org.apache.xala n.transformer.T ransformerImpl. executeChildTem plates(Unknown Source)
at org.apache.xala n.transformer.T ransformerImpl. applyTemplateTo Node(Unknown Source)
at org.apache.xala n.transformer.T ransformerImpl. transformNode(U nknown
Source)
at org.apache.xala n.transformer.T ransformerImpl. transform(Unkno wn
Source)
at org.apache.xala n.transformer.T ransformerImpl. transform(Unkno wn
Source)
at org.apache.xala n.transformer.T ransformerImpl. transform(Unkno wn
Source)
at TestReuseTransf ormerServlet.se rvice(TestReuse TransformerServ let.java:51) at org.apache.cata lina.core.Appli cationFilterCha in.internalDoFi lter(Applicatio n
FilterChain.jav a:247) at org.apache.cata lina.core.Appli cationFilterCha in.doFilter(App licationFilterC h
ain.java:193) at org.apache.cata lina.core.Stand ardWrapperValve .invoke(Standar dWrapperValve.j a
va:256) at org.apache.cata lina.core.Stand ardPipeline$Sta ndardPipelineVa lveContext.invo k
eNext(StandardP ipeline.java:64 3) at org.apache.cata lina.core.Stand ardPipeline.inv oke(StandardPip eline.java:480) at org.apache.cata lina.core.Conta inerBase.invoke (ContainerBase. java:995)
at org.apache.cata lina.core.Stand ardContextValve .invoke(Standar dContextValve.j a
va:191) at org.apache.cata lina.core.Stand ardPipeline$Sta ndardPipelineVa lveContext.invo k
eNext(StandardP ipeline.java:64 3) at org.apache.cata lina.core.Stand ardPipeline.inv oke(StandardPip eline.java:480) at org.apache.cata lina.core.Conta inerBase.invoke (ContainerBase. java:995)
at org.apache.cata lina.core.Stand ardContext.invo ke(StandardCont ext.java:2416) at org.apache.cata lina.core.Stand ardHostValve.in voke(StandardHo stValve.java:18 0
) at org.apache.cata lina.core.Stand ardPipeline$Sta ndardPipelineVa lveContext.invo k
eNext(StandardP ipeline.java:64 3) at org.apache.cata lina.valves.Err orDispatcherVal ve.invoke(Error DispatcherValve .
java:171) at org.apache.cata lina.core.Stand ardPipeline$Sta ndardPipelineVa lveContext.invo k
eNext(StandardP ipeline.java:64 1) at org.apache.cata lina.valves.Err orReportValve.i nvoke(ErrorRepo rtValve.java:17 2
) at org.apache.cata lina.core.Stand ardPipeline$Sta ndardPipelineVa lveContext.invo k
eNext(StandardP ipeline.java:64 1) at org.apache.cata lina.core.Stand ardPipeline.inv oke(StandardPip eline.java:480) at org.apache.cata lina.core.Conta inerBase.invoke (ContainerBase. java:995)
at org.apache.cata lina.core.Stand ardEngineValve. invoke(Standard EngineValve.jav a
:174) at org.apache.cata lina.core.Stand ardPipeline$Sta ndardPipelineVa lveContext.invo k
eNext(StandardP ipeline.java:64 3) at org.apache.cata lina.core.Stand ardPipeline.inv oke(StandardPip eline.java:480) at org.apache.cata lina.core.Conta inerBase.invoke (ContainerBase. java:995)
at org.apache.coyo te.tomcat4.Coyo teAdapter.servi ce(CoyoteAdapte r.java:223) at org.apache.coyo te.http11.Http1 1Processor.proc ess(Http11Proce ssor.java:601) at org.apache.coyo te.http11.Http1 1Protocol$Http1 1ConnectionHand ler.processConn e
ction(Http11Pro tocol.java:392) at org.apache.tomc at.util.net.Tcp WorkerThread.ru nIt(PoolTcpEndp oint.java:565) at org.apache.tomc at.util.threads .ThreadPool$Con trolRunnable.ru n(ThreadPool.ja v
a:619) at java.lang.Threa d.run(Unknown Source)

Jul 20 '05 #2

"Alan Krueger" <ml******@sneak email.com> wrote in message
news:ee******** *************** ***@posting.goo gle.com...
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 NullPointerExce ption to be thrown from within the Transformer
object.
The javax.xml.trans form.Transforme r 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 "simultaneo us" 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 TestReuseTransf ormerServlet.ja va---
import java.io.IOExcep tion;

import javax.servlet.S ervletConfig;
import javax.servlet.S ervletException ;
import javax.servlet.S ervletRequest;
import javax.servlet.S ervletResponse;
import javax.servlet.h ttp.HttpServlet ;
import javax.xml.parse rs.DocumentBuil derFactory;
import javax.xml.parse rs.FactoryConfi gurationError;
import javax.xml.parse rs.ParserConfig urationExceptio n;
import javax.xml.trans form.Transforme r;
import javax.xml.trans form.Transforme rConfigurationE xception;
import javax.xml.trans form.Transforme rException;
import javax.xml.trans form.Transforme rFactory;
import javax.xml.trans form.dom.DOMSou rce;
import javax.xml.trans form.stream.Str eamResult;
import javax.xml.trans form.stream.Str eamSource;

import org.w3c.dom.Doc ument;
import org.w3c.dom.Ele ment;
import org.w3c.dom.Tex t;

public class TestReuseTransf ormerServlet extends HttpServlet
{
public void init( ServletConfig config ) throws ServletExceptio n
{
try
{
myTestTransform er = TransformerFact ory.newInstance ()
.newTransformer ( new StreamSource(
config.getServl etContext().get RealPath( "test.xslt" ) )
);
}
catch ( TransformerConf igurationExcept ion e )
{
throw new ServletExceptio n( "Transforme r exception: "
+ e.getMessage(), e );
}
}

public void service( ServletRequest request, ServletResponse
response )
throws ServletExceptio n, IOException
{
try
{
Document document = DocumentBuilder Factory.newInst ance()
.newDocumentBui lder().newDocum ent();
Element element = document.create Element( "input" );
document.append Child( element );
Text text = document.create TextNode( "one" );
element.appendC hild( text );

myTestTransform er.transform(
new DOMSource( document ),
new StreamResult( response.getOut putStream() ) );
}
catch ( ParserConfigura tionException e )
{
throw new ServletExceptio n( "Parser config exception: "
+ e.getMessage(), e );
}
catch ( FactoryConfigur ationError e )
{
throw new ServletExceptio n( "Factory config exception: "
+ e.getMessage(), e );
}
catch ( TransformerExce ption e )
{
throw new ServletExceptio n( "Transforme r exception: "
+ e.getMessage(), e );
}
}

Transformer myTestTransform er;
}
---end TestReuseTransf ormerServlet.ja va---

---begin test.xslt---
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:styleshe et 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="documen t($otherPath)"/>

<xsl:template match="/">
<foo>
<xsl:value-of select="$otherP age/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.NullP ointerException
at org.apache.xpat h.axes.AxesWalk er.setRoot(Unkn own Source)
at org.apache.xpat h.axes.WalkingI teratorSorted.s etRoot(Unknown
Source)
at org.apache.xpat h.axes.LocPathI terator.execute (Unknown Source)
at org.apache.xpat h.Expression.ex ecuteCharsToCon tentHandler(Unk nown
Source)
at org.apache.xala n.templates.Ele mValueOf.execut e(Unknown Source)
at org.apache.xala n.transformer.T ransformerImpl. executeChildTem plates(Unknown Source)
at org.apache.xala n.templates.Ele mLiteralResult. execute(Unknown
Source)
at org.apache.xala n.transformer.T ransformerImpl. executeChildTem plates(Unknown Source)
at org.apache.xala n.transformer.T ransformerImpl. applyTemplateTo Node(Unknown Source)
at org.apache.xala n.transformer.T ransformerImpl. transformNode(U nknown
Source)
at org.apache.xala n.transformer.T ransformerImpl. transform(Unkno wn
Source)
at org.apache.xala n.transformer.T ransformerImpl. transform(Unkno wn
Source)
at org.apache.xala n.transformer.T ransformerImpl. transform(Unkno wn
Source)
at TestReuseTransf ormerServlet.se rvice(TestReuse TransformerServ let.java:51) at org.apache.cata lina.core.Appli cationFilterCha in.internalDoFi lter(Applicatio n
FilterChain.jav a:247) at org.apache.cata lina.core.Appli cationFilterCha in.doFilter(App licationFilterC h
ain.java:193) at org.apache.cata lina.core.Stand ardWrapperValve .invoke(Standar dWrapperValve.j a
va:256) at org.apache.cata lina.core.Stand ardPipeline$Sta ndardPipelineVa lveContext.invo k
eNext(StandardP ipeline.java:64 3) at org.apache.cata lina.core.Stand ardPipeline.inv oke(StandardPip eline.java:480) at org.apache.cata lina.core.Conta inerBase.invoke (ContainerBase. java:995)
at org.apache.cata lina.core.Stand ardContextValve .invoke(Standar dContextValve.j a
va:191) at org.apache.cata lina.core.Stand ardPipeline$Sta ndardPipelineVa lveContext.invo k
eNext(StandardP ipeline.java:64 3) at org.apache.cata lina.core.Stand ardPipeline.inv oke(StandardPip eline.java:480) at org.apache.cata lina.core.Conta inerBase.invoke (ContainerBase. java:995)
at org.apache.cata lina.core.Stand ardContext.invo ke(StandardCont ext.java:2416) at org.apache.cata lina.core.Stand ardHostValve.in voke(StandardHo stValve.java:18 0
) at org.apache.cata lina.core.Stand ardPipeline$Sta ndardPipelineVa lveContext.invo k
eNext(StandardP ipeline.java:64 3) at org.apache.cata lina.valves.Err orDispatcherVal ve.invoke(Error DispatcherValve .
java:171) at org.apache.cata lina.core.Stand ardPipeline$Sta ndardPipelineVa lveContext.invo k
eNext(StandardP ipeline.java:64 1) at org.apache.cata lina.valves.Err orReportValve.i nvoke(ErrorRepo rtValve.java:17 2
) at org.apache.cata lina.core.Stand ardPipeline$Sta ndardPipelineVa lveContext.invo k
eNext(StandardP ipeline.java:64 1) at org.apache.cata lina.core.Stand ardPipeline.inv oke(StandardPip eline.java:480) at org.apache.cata lina.core.Conta inerBase.invoke (ContainerBase. java:995)
at org.apache.cata lina.core.Stand ardEngineValve. invoke(Standard EngineValve.jav a
:174) at org.apache.cata lina.core.Stand ardPipeline$Sta ndardPipelineVa lveContext.invo k
eNext(StandardP ipeline.java:64 3) at org.apache.cata lina.core.Stand ardPipeline.inv oke(StandardPip eline.java:480) at org.apache.cata lina.core.Conta inerBase.invoke (ContainerBase. java:995)
at org.apache.coyo te.tomcat4.Coyo teAdapter.servi ce(CoyoteAdapte r.java:223) at org.apache.coyo te.http11.Http1 1Processor.proc ess(Http11Proce ssor.java:601) at org.apache.coyo te.http11.Http1 1Protocol$Http1 1ConnectionHand ler.processConn e
ction(Http11Pro tocol.java:392) at org.apache.tomc at.util.net.Tcp WorkerThread.ru nIt(PoolTcpEndp oint.java:565) at org.apache.tomc at.util.threads .ThreadPool$Con trolRunnable.ru n(ThreadPool.ja v
a:619) at java.lang.Threa d.run(Unknown Source)

Jul 20 '05 #3
"William Brogden" <wb******@bga.c om> wrote in message news:<3f******* *@giga.realtime .net>...
"Alan Krueger" <ml******@sneak email.com> wrote in message
news:ee******** *************** ***@posting.goo gle.com...
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 NullPointerExce ption to be thrown from within the Transformer
object.


The javax.xml.trans form.Transforme r 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 "simultaneo us" requests.


I didn't say "simultaneo us" 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
4431
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 problem with defining my JDBC resource within Tomcat. I am pretty sure that my code is correct (but I am not certain), and the problem is with...
5
6453
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 created another replica DEVELOPMENT website and upgraded it to Tomcat 4.1.27. I was told this version of Tomcat supports Database Connection Pooling...
0
4408
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 show up via tomcat. I'm running on Fedora Core 2, tomcat-4.1.27-13. I haven't noticed any difference if I start apache httpd-2.0.50-2.1 or not. ...
1
3092
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 Transformer convert that via XSLT to valid XSL-FO. So I define a SAXReader which fires the SAX Events for the Java Object. This works fine and the...
19
2961
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 provide an open TD with a DIV in it for the content of this formlet. (The DIV is for DHTML to hide and show the content) I've created a web page...
1
2202
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 below and have gone as far as given EVERYONE full control of the App_Data folder. I am using the default settings (which I assume is the Cassini...
1
1440
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) org.apache.catalina.manager.HTMLManagerServlet.doGet(HTMLManagerServlet.java:161) javax.servlet.http.HttpServlet.service(HttpServlet.java:743)...
0
1632
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.. actually when i build it, it creates a jar file which is totally fine (i can confirm that because i use that jar file in another project) any idea on...
0
2517
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 enviroment setup and Data source connection. Could anybody help me resolve the issue. Thank you very much for yout time. HTTP Status 500 -
0
7798
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8039
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6140
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5431
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3556
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3545
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2015
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1130
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
838
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.