Bug 42390 - JSP compilation error with nested tagfile tags with variables with "AT_BEGIN" scope
JSP compilation error with nested tagfile tags with variables with "AT_BEGIN"...
Status: RESOLVED FIXED
Product: Tomcat 5
Classification: Unclassified
Component: Jasper
5.5.27
Macintosh Mac OS X 10.4
: P1 major (vote)
: ---
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2007-05-11 00:59 UTC by MicroNova YUZU Team
Modified: 2010-04-20 10:37 UTC (History)
0 users



Attachments
ready-to-use WAR file that reproduces the issue (1.08 KB, application/zip)
2009-01-02 09:38 UTC, Konstantin Kolinko
Details
patch for tc6.0.x that fixes the issue (581 bytes, patch)
2009-01-02 19:14 UTC, Konstantin Kolinko
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description MicroNova YUZU Team 2007-05-11 00:59:37 UTC
Given a tagfile "test.tag" in /WEB-INF/tags/t:
---- begin test.tag ----
<%@ variable name-given="X" scope="AT_BEGIN" %>
<jsp:doBody/>
---- end test.tag ----
the following JSP "testTest.jsp":
---- begin testTest.jsp ----
<t:test><t:test/></t:test>
---- end testTest.jsp ----
gives a JSP compilation error:
org.apache.jasper.JasperException: Unable to compile class for JSP: 
Stacktrace:
        at
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
        at
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
        at
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:435)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
        at
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
        at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:299)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:542)
        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
        at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
        at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
        at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
        at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
        at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
        at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
        at java.lang.Thread.run(Thread.java:613)
Comment 1 Konstantin Kolinko 2009-01-02 09:38:46 UTC
Created attachment 23070 [details]
ready-to-use WAR file that reproduces the issue
Comment 2 Konstantin Kolinko 2009-01-02 09:48:48 UTC
I have arranged the OP's sources as a ready-to-use web application - that is the WAR file that I attached above.

Using it I can reproduce the problem in the following TC versions:
5.5.27, 6.0.18 and the current tc6.0.x branch as at revision 730794. Thus bumping the Version field.

To reproduce:
1. Deploy the application
2. Access http://localhost:8080/bug42390/
3. The following compilation error is displayed: (tc6.0.x)

org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 99 in the generated java file
_jspx_X_1 cannot be resolved
...

Note: The tag file compiles fine. It is JSP that does not compile.
Comment 3 Konstantin Kolinko 2009-01-02 19:14:26 UTC
Created attachment 23072 [details]
patch for tc6.0.x that fixes the issue

I am attaching patch that fixes the issue. It is against the tc6.0.x branch.

The cause was that scripting var info of the nested Node.CustomTag was not populated by ScriptingVariableVisitor#setScriptingVars() call.

It occurred because it thought that the variable was already declared, because it was present in ScriptingVariableVisitor#scriptVars, because the same instance of ScriptingVariableVisitor was used for the parent and child.
Comment 4 Mark Thomas 2009-04-09 09:15:08 UTC
Again, many thanks for the patch.

It has been applied to trunk and proposed for 6.0.x and 5.5.x
Comment 5 Mark Thomas 2009-05-22 08:46:30 UTC
Patch has been reverted for more testing.
Comment 6 Mark Thomas 2009-08-16 11:08:38 UTC
I have done some further testing of the patch and can't find any regressions. I have therefore re-proposed the patch for 6.0.x and 5.5.x
Comment 7 Mark Thomas 2009-09-20 15:36:16 UTC
The patch has been applied to 6.0.x and will be included in 6.0.21 onwards.
Comment 8 Mark Thomas 2010-01-31 04:27:55 UTC
Note that the patch caused bug48616. Find a solution that fixes both bugs will be tracked in bug48616.
Comment 9 Mark Thomas 2010-01-31 16:09:41 UTC
The proposed patch for 5.5.x has been updated with a fix for the regession.
Comment 10 Konstantin Kolinko 2010-04-20 10:37:43 UTC
This issue was fixed in 5.5.x in r935941 and will be in 5.5.30 onwards.