Bug 65387 - JSP compile error after upgrade 10.0.6 -> 10.0.7
Summary: JSP compile error after upgrade 10.0.6 -> 10.0.7
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 10
Classification: Unclassified
Component: Jasper (show other bugs)
Version: unspecified
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ------
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-06-17 08:08 UTC by qeepcologne
Modified: 2021-06-28 07:21 UTC (History)
1 user (show)



Attachments
login form (9.67 KB, text/plain)
2021-06-17 08:13 UTC, qeepcologne
Details
include header.jsp (3.21 KB, text/plain)
2021-06-17 14:37 UTC, qeepcologne
Details
include Main_Start.jsp (368 bytes, text/plain)
2021-06-17 14:38 UTC, qeepcologne
Details
nested include HTML_Header.jsp (3.01 KB, text/html)
2021-06-17 14:39 UTC, qeepcologne
Details
LoginForm_jsp.java (57.45 KB, text/x-java)
2021-06-18 09:48 UTC, qeepcologne
Details
test_no-libs.zip (371.49 KB, application/octet-stream)
2021-06-18 11:46 UTC, Konstantin Kolinko
Details

Note You need to log in before you can comment on or make changes to this bug.
Description qeepcologne 2021-06-17 08:08:48 UTC
After upgrade tomcat (via docker image: tomcat:10.0.6-jdk16-openjdk-slim-buster / tomcat:10.0.7-jdk16-openjdk-slim-buster) the following error occurs:
(note: this is javax webapp in webapps-javaee folder).

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

An error occurred at line: [509] in the generated java file: [/usr/local/tomcat/work/Catalina/localhost/qeepmaster-new/org/apache/jsp/WEB_002dINF/jsp/LoginForm_jsp.java]
out cannot be resolved to a variable

An error occurred at line: [543] in the generated java file: [/usr/local/tomcat/work/Catalina/localhost/qeepmaster-new/org/apache/jsp/WEB_002dINF/jsp/LoginForm_jsp.java]
out cannot be resolved to a variable

Stacktrace:
	org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)
	org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:213)
	org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:482)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:397)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:367)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:351)
	org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:603)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:399)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:380)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:328)
	jakarta.servlet.http.HttpServlet.service(HttpServlet.java:774)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
	org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:171)
	org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:316)
	org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1396)
	org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1141)
	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1080)
	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)
	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
	jakarta.servlet.http.HttpServlet.service(HttpServlet.java:665)
	org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
	jakarta.servlet.http.HttpServlet.service(HttpServlet.java:774)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
	org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:109)
	org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:204)
	org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:183)
	org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358)
	org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271)
Comment 1 qeepcologne 2021-06-17 08:13:10 UTC
Created attachment 37902 [details]
login form
Comment 2 Mark Thomas 2021-06-17 08:35:16 UTC
Looks like my clean-up of unused code may have been too aggressive despite all the unit tests that were added. Thanks for the example JSP that triggers this. We'll take a look.
Comment 3 Mark Thomas 2021-06-17 13:20:19 UTC
The JSP provided to reproduce the issue has a number of included that have not been provided. We can try and work-around this but we can't know if the content that triggers this issue is in the included files or not.

Please provide a self-contained JSP (it can depend on JSTL if necessary) that demonstrates the issue.
Comment 4 Remy Maucherat 2021-06-17 13:36:20 UTC
(In reply to Mark Thomas from comment #3)
> The JSP provided to reproduce the issue has a number of included that have
> not been provided. We can try and work-around this but we can't know if the
> content that triggers this issue is in the included files or not.
> 
> Please provide a self-contained JSP (it can depend on JSTL if necessary)
> that demonstrates the issue.

I have tried the if.jsp from the examples, and the empty if tag doesn't have the out (this is ok I believe) while the two that are not empty do have it. In the provided example, the if tags are not empty so they should have the out as well.
Comment 5 qeepcologne 2021-06-17 14:37:58 UTC
Created attachment 37903 [details]
include header.jsp
Comment 6 qeepcologne 2021-06-17 14:38:33 UTC
Created attachment 37904 [details]
include Main_Start.jsp
Comment 7 qeepcologne 2021-06-17 14:39:03 UTC
Created attachment 37905 [details]
nested include HTML_Header.jsp
Comment 8 qeepcologne 2021-06-17 14:40:53 UTC
i don't create that include hell and web developer is on holiday at the moment. I try to add all the missing includes. Hope that helps.
Comment 9 Konstantin Kolinko 2021-06-17 16:04:55 UTC
Can you provide the generated java file (LoginForm_jsp.java) ?

/usr/local/tomcat/work/Catalina/localhost/qeepmaster-new/org/apache/jsp/WEB_002dINF/jsp/LoginForm_jsp.java
Comment 10 Mark Thomas 2021-06-18 09:07:06 UTC
Those includes have at least one further include. Konstantin's suggestion is a better one. With the broken .java file we can try and reverse engineer a test case.
Comment 11 qeepcologne 2021-06-18 09:48:08 UTC
Created attachment 37906 [details]
LoginForm_jsp.java
Comment 12 Konstantin Kolinko 2021-06-18 11:33:36 UTC
(In reply to qeepcologne from comment #11)
> Created attachment 37906 [details]
> LoginForm_jsp.java

_jspx_dependants.put("/WEB-INF/lib/spring-security-taglibs-5.5.0.jar"
_jspx_dependants.put("/WEB-INF/lib/spring-webmvc-5.3.8.jar"

OK, I see what versions of the libs were used.

_jspx_dependants.put("/WEB-INF/tld/fn-1.1.1.tld",
_jspx_dependants.put("/WEB-INF/tld/c-1.1.2.tld",

I wonder why the app is using JSTL 1.1.x instead of the current version (1.2.х).
https://tomcat.apache.org/download-taglibs.cgi
https://tomcat.apache.org/taglibs.html

I found those TLD files at
https://repo.maven.apache.org/maven2/taglibs/c/1.1.2/c-1.1.2.tld
https://repo.maven.apache.org/maven2/taglibs/fn/1.1.1/fn-1.1.1.tld

They are the same as c.tld and fn.tld in standard.jar of jakarta-taglibs-standard-1.1.2.zip from http://archive.apache.org/dist/jakarta/taglibs/standard/binaries/


With those libs and files I am able to reproduce the error.
The libraries used:
jstl.jar
spring-beans-5.3.8.jar
spring-expression-5.3.8.jar
spring-security-taglibs-5.5.0.jar
spring-security-web-5.5.0.jar
spring-webmvc-5.3.8.jar
standard.jar
Comment 13 Konstantin Kolinko 2021-06-18 11:46:24 UTC
Created attachment 37907 [details]
test_no-libs.zip

To reproduce:
1) Unzip test_no-libs.zip into an empty directory
2) Download the following libraries and put them into WEB-INF/lib durectory:

https://repo.maven.apache.org/maven2/org/springframework/security/spring-security-taglibs/5.5.0/spring-security-taglibs-5.5.0.jar

https://repo.maven.apache.org/maven2/org/springframework/security/spring-security-web/5.5.0/spring-security-web-5.5.0.jar

https://repo.maven.apache.org/maven2/org/springframework/spring-beans/5.3.8/spring-beans-5.3.8.jar

https://repo.maven.apache.org/maven2/org/springframework/spring-expression/5.3.8/spring-expression-5.3.8.jar

https://repo.maven.apache.org/maven2/org/springframework/spring-webmvc/5.3.8/spring-webmvc-5.3.8.jar

3) zip or jar it and rename to test.war

4) Put the war file into ${catalina.base}/webapps-javaee
5) Start Tomcat 10
6) Open http://localhost:8080/test/LoginForm.jsp

The errors:

[[[
An error occurred at line: [509] in the generated java file: [...\LoginForm_jsp.java]
out cannot be resolved to a variable

An error occurred at line: [543] in the generated java file: [...\LoginForm_jsp.java]
out cannot be resolved to a variable
]]]

Those lines (509, 543) both are:

>           out = _jspx_page_context.popBody();
Comment 14 Mark Thomas 2021-06-18 12:11:45 UTC
Thanks for that. I can recreate the issue now.
Comment 15 Mark Thomas 2021-06-18 12:27:25 UTC
I have a fix. I just want to pull together a simpler test case for this then I'll commit the test and the fix.
Comment 16 Remy Maucherat 2021-06-18 12:50:35 UTC
*** Bug 65390 has been marked as a duplicate of this bug. ***
Comment 17 Mark Thomas 2021-06-18 13:55:07 UTC
Fixed in:
- 10.1.x for 10.1.0-M2 onwards
- 10.0.x for 10.0.8 onwards
Comment 18 Mark Thomas 2021-06-21 10:07:21 UTC
Just following up in this as we'd really like to catch regressions like this in the ~3 working day window between the release candidate being available and the release vote concluding.

It is great that you are using the latest Tomcat release as soon as it as available but what would we, the Tomcat team, need to do for you to be able to test the release candidate as soon as it as available rather than you waiting for the release?
Comment 19 qeepcologne 2021-06-28 07:21:42 UTC
It would be much easier if there is a docker image available for the release candidate (or latest milestone), then we could use it as soon it is available on staging.