Bug 47013 - JSP not compiled at startup when used as a servlet
JSP not compiled at startup when used as a servlet
Status: RESOLVED FIXED
Product: Tomcat 6
Classification: Unclassified
Component: Jasper
6.0.18
PC Windows XP
: P2 normal (vote)
: default
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2009-04-10 09:26 UTC by Robert Flaherty
Modified: 2009-05-02 18:33 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Flaherty 2009-04-10 09:26:22 UTC
I created a servlet with a jsp and the following web.xml entry:

	<servlet>
		<servlet-name>Repository</servlet-name>
		<jsp-file>/Repository.jsp</jsp-file>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>Repository</servlet-name>
		<url-pattern>/Repository</url-pattern>
	</servlet-mapping>

I altered the JSP and started Tomcat.  The initial startup invokes the JSP with the following call stack:

	org.apache.jsp.Repository_jsp.jspInit(Repository_jsp.java:42)
	org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:51)
	org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:159)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1191)
	org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:992)
	org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4058)
	org.apache.catalina.core.StandardContext.start(StandardContext.java:4371)
	org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
	org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
	org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
	org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
	org.apache.catalina.core.StandardService.start(StandardService.java:516)
	org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
	org.apache.catalina.startup.Catalina.start(Catalina.java:578)
	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	java.lang.reflect.Method.invoke(Method.java:597)
	org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
	org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)

Then I hit the servlet with a normal request with http://localhost:8080/context/Repository which yields this call stack:

	org.apache.jsp.Repository_jsp.jspInit(Repository_jsp.java:42)
	org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:51)
	org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:159)
	org.apache.jasper.servlet.JspServletWrapper.getDependants(JspServletWrapper.java:263)
	org.apache.jasper.compiler.Compiler.isOutDated(Compiler.java:430)
	org.apache.jasper.compiler.Compiler.isOutDated(Compiler.java:351)
	org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:582)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
	java.lang.Thread.run(Thread.java:619)

The JSP gets compiled on the request, but not at startup.  I backtracked a little and found StandardWrapper is doing:

	req.setQueryString("jsp_precompile=true");

which is unsafe b/c the precompile param can be specified as system property org.apache.jasper.Constants.PRECOMPILE.  Instead it should be:

	req.setQueryString(Constants.PRECOMPILE + "=true");

Anyway, I wasn't overriding it so that didn't help.
Comment 1 Mark Thomas 2009-04-14 14:58:08 UTC
I don;t see this with trunk. Looks to be a duplicate of bug 41606 that was fixed recently.

*** This bug has been marked as a duplicate of bug 41606 ***
Comment 2 Robert Flaherty 2009-04-14 15:07:53 UTC
Shouldn't that precompile flag be changed though (bottom of the note).
Comment 3 Mark Thomas 2009-04-14 15:19:01 UTC
Re-opening to track the secondary issue. It has been fixed in trunk and proposed for 6.0.x.
Comment 4 Mark Thomas 2009-05-02 18:33:11 UTC
This has been fixed in trunk and will be in 6.0.20 onwards.