[ http://issues.apache.org/jira/browse/VELOCITY-383?page=comments#action_12417291 ]
Stu Belden commented on VELOCITY-383: ------------------------------------- I believe this is the same issue as I reported here: VELTOOLS-59 The root of the problem is that the Template class is not thread safe. This is not necessarily the end of the world unless you are modifying templates on the fly, and then sharing those Template instances between threads. I think that would be peculiar behavior for an app to have, but like the issue above, it's possible to introduce that behavior by accident. I believe careful synchronization of all access to the "data" member (the AST) would fix this problem, but I don't know what ramifications that would have, if any. I'll attach a simple proof of concept class here in a second. > NPE when processing template under heavy concurrent load > -------------------------------------------------------- > > Key: VELOCITY-383 > URL: http://issues.apache.org/jira/browse/VELOCITY-383 > Project: Velocity > Type: Bug > Components: Source > Versions: 1.4 > Environment: Operating System: Windows XP > Platform: PC > Reporter: Hans > Priority: Critical > > During load testing the server, with 50 concurrent users, the > VelocityViewServlet would throw a null pointer exception about 3% of the > time. > 97% of the time, the page would serve normally. > Below is the trace: > java.lang.NullPointerException > at org.apache.velocity.runtime.parser.node.ASTDirective.init > (ASTDirective.java:94) > at org.apache.velocity.runtime.parser.node.SimpleNode.init > (SimpleNode.java:201) > at org.apache.velocity.Template.initDocument(Template.java:199) > at org.apache.velocity.Template.process(Template.java:124) > at > org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource > (ResourceManagerImpl.java:423) > at org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource > (ResourceManagerImpl.java:341) > at org.apache.velocity.runtime.RuntimeInstance.getTemplate > (RuntimeInstance.java:831) > at org.apache.velocity.runtime.RuntimeInstance.getTemplate > (RuntimeInstance.java:813) > at org.apache.velocity.runtime.RuntimeSingleton.getTemplate > (RuntimeSingleton.java:285) > at > org.apache.velocity.tools.view.servlet.VelocityViewServlet.getTemplate > (VelocityViewServlet.java:540) > at > org.apache.velocity.tools.view.servlet.VelocityViewServlet.handleRequest > (VelocityViewServlet.java:475) > at org.apache.velocity.tools.view.servlet.VelocityViewServlet.doRequest > (VelocityViewServlet.java:407) > at org.apache.velocity.tools.view.servlet.VelocityViewServlet.doPost > (VelocityViewServlet.java:383) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:709) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) > at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter > (ApplicationFilterChain.java:237) > at org.apache.catalina.core.ApplicationFilterChain.doFilter > (ApplicationFilterChain.java:157) > at org.apache.catalina.core.ApplicationDispatcher.invoke > (ApplicationDispatcher.java:674) > at org.apache.catalina.core.ApplicationDispatcher.doInclude > (ApplicationDispatcher.java:576) > at org.apache.catalina.core.ApplicationDispatcher.include > (ApplicationDispatcher.java:501) > at org.apache.velocity.tools.view.ImportSupport.acquireString > (ImportSupport.java:140) > at org.apache.velocity.tools.struts.TilesTool.doInsert > (TilesTool.java:476) > at org.apache.velocity.tools.struts.TilesTool.doInsert > (TilesTool.java:419) > at org.apache.velocity.tools.struts.TilesTool.processUrl > (TilesTool.java:398) > at org.apache.velocity.tools.struts.TilesTool.processAsDefinitionOrURL > (TilesTool.java:357) > at org.apache.velocity.tools.struts.TilesTool.processObjectValue > (TilesTool.java:305) > at org.apache.velocity.tools.struts.TilesTool.get(TilesTool.java:135) > at sun.reflect.GeneratedMethodAccessor136.invoke(Unknown Source) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) > at java.lang.reflect.Method.invoke(Unknown Source) > at org.apache.velocity.runtime.parser.node.GetExecutor.execute > (GetExecutor.java:65) > at > org.apache.velocity.util.introspection.UberspectImpl$VelGetterImpl.invoke > (UberspectImpl.java:302) > at org.apache.velocity.runtime.parser.node.ASTIdentifier.execute > (ASTIdentifier.java:157) > at org.apache.velocity.runtime.parser.node.ASTReference.execute > (ASTReference.java:175) > at org.apache.velocity.runtime.parser.node.ASTReference.render > (ASTReference.java:220) > at org.apache.velocity.runtime.parser.node.SimpleNode.render > (SimpleNode.java:230) > at org.apache.velocity.Template.merge(Template.java:256) > at > org.apache.velocity.tools.view.servlet.VelocityViewServlet.mergeTemplate > (VelocityViewServlet.java:592) > at org.apache.velocity.tools.view.servlet.VelocityViewServlet.doRequest > (VelocityViewServlet.java:417) > at org.apache.velocity.tools.view.servlet.VelocityViewServlet.doPost > (VelocityViewServlet.java:383) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:709) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) > at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter > (ApplicationFilterChain.java:237) > at org.apache.catalina.core.ApplicationFilterChain.doFilter > (ApplicationFilterChain.java:157) > at org.apache.catalina.core.ApplicationDispatcher.invoke > (ApplicationDispatcher.java:674) > at org.apache.catalina.core.ApplicationDispatcher.processRequest > (ApplicationDispatcher.java:465) > at org.apache.catalina.core.ApplicationDispatcher.doForward > (ApplicationDispatcher.java:400) > at org.apache.catalina.core.ApplicationDispatcher.forward > (ApplicationDispatcher.java:303) > at org.apache.struts.action.RequestProcessor.doForward > (RequestProcessor.java:1063) > at org.apache.struts.tiles.TilesRequestProcessor.doForward > (TilesRequestProcessor.java:263) > at org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition > (TilesRequestProcessor.java:239) > at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig > (TilesRequestProcessor.java:302) > at org.apache.struts.action.RequestProcessor.process > (RequestProcessor.java:229) > at org.apache.struts.action.ActionServlet.process > (ActionServlet.java:1194) > at org.apache.struts.action.ActionServlet.doPost > (ActionServlet.java:432) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:709) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) > at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter > (ApplicationFilterChain.java:237) > at org.apache.catalina.core.ApplicationFilterChain.doFilter > (ApplicationFilterChain.java:157) > at org.apache.catalina.core.StandardWrapperValve.invoke > (StandardWrapperValve.java:214) > at org.apache.catalina.core.StandardContextValve.invoke > (StandardContextValve.java:178) > at org.apache.catalina.core.StandardHostValve.invoke > (StandardHostValve.java:126) > at org.apache.catalina.valves.ErrorReportValve.invoke > (ErrorReportValve.java:105) > at org.apache.catalina.core.StandardEngineValve.invoke > (StandardEngineValve.java:107) > at org.apache.catalina.connector.CoyoteAdapter.service > (CoyoteAdapter.java:148) > at org.apache.coyote.http11.Http11Processor.process > (Http11Processor.java:825) > at > org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnecti > on(Http11Protocol.java:731) > at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket > (PoolTcpEndpoint.java:526) > at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt > (LeaderFollowerWorkerThread.java:80) > at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run > (ThreadPool.java:684) > at java.lang.Thread.run(Unknown Source) -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
