Bug 63724

Summary: Compile JSP to class when using Tiles and custom tag fails
Product: Tomcat 9 Reporter: Carlos Hager <guilhermevh>
Component: JasperAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: major    
Priority: P2    
Version: 9.0.21   
Target Milestone: -----   
Hardware: All   
OS: Mac OS X 10.1   
Attachments: stacktrace
source code of the project to be tested
print of debug showing why it fails
print of debug showing how it was when used to work
stacktrace of the example project

Description Carlos Hager 2019-09-04 11:10:42 UTC
Created attachment 36758 [details]
stacktrace

The commit "Replace custom split(String,String) method with call to String.split by Christopher Schultz on 08/05/19 at 21:55 and git hash f7c41d120c6374a8221b684a5ad5ede3d1621ff4" introduced a bug in the version of Apache Tomcat 9.0.21 where the jsp pages using taglibs within struts tiles template are no longer being parsed properly.


I got the latest git version and revert the commit (f7c41d120c6374a8221b684a5ad5ede3d1621ff4) mentioned above. The jsp pages are being parsed properly again.

This is bug under jasper.jar / class org.apache.jasper.compiler.JspUtil.java
Comment 1 Mark Thomas 2019-09-04 17:22:40 UTC
Please provide the simplest possible example (which is probably going to be a WAR file) - including source - that demonstrates this issue.
Comment 2 Carlos Hager 2019-09-05 13:58:05 UTC
Created attachment 36760 [details]
source code of the project to be tested

simple project which works till version 9.0.20 and fail with the higher versions 

using gradle 4.10.X to generate the war to be deployed run: $ gradle clean build war
Comment 3 Carlos Hager 2019-09-05 13:59:50 UTC
Created attachment 36761 [details]
print of debug showing why it fails

print of debug showing why it fails, when new split method is considering the first "/" and adding and extra "." to the package name causing the fail
Comment 4 Carlos Hager 2019-09-05 14:00:55 UTC
Created attachment 36762 [details]
print of debug showing how it was when used to work

the local split method wasn't considering the the first "/" and the package name was being build properly
Comment 5 Carlos Hager 2019-09-05 14:08:46 UTC
(In reply to Mark Thomas from comment #1)
> Please provide the simplest possible example (which is probably going to be
> a WAR file) - including source - that demonstrates this issue.

Hi Mark, thank for the quick reply. I have attached the source code of the project (war had 4mb and was being blocked) and 2 prints while debugging.

On the method JspUtil().makeJavaPackage, the split method used to not considerate the first "/" of the String. But the new refactor it does take this situation in count, causing the make a java package with "..", how you can see in the stacktrace.

Stacktrace:

An error occurred at line: [1] in the generated java file: [/Users/carloshager/Library/Caches/IntelliJIdea2019.2/tomcat/Unnamed_error-example/work/Catalina/localhost/error_example/org/apache/jsp/tag/meta//WEB_002dINF/customTldResource_tld/main/jsPerformanceLog_tag.java]
The declared package "" does not match the expected package "org.apache.jsp.tag.meta.WEB_002dINF.customTldResource_tld.main"

An error occurred at line: [9] in the generated java file: [/Users/carloshager/Library/Caches/IntelliJIdea2019.2/tomcat/Unnamed_error-example/work/Catalina/localhost/error_example/org/apache/jsp/tag/meta//WEB_002dINF/customTldResource_tld/main/jsPerformanceLog_tag.java]
Syntax error on token ".", delete this token
Comment 6 Carlos Hager 2019-09-05 14:12:51 UTC
Created attachment 36763 [details]
stacktrace of the example project

stacktrace of the example project
Comment 7 Mark Thomas 2019-09-05 18:38:09 UTC
Thanks for the test case. It made it much easier to be sure that the issue was fixed.

Fixed in:
- master for 9.0.25 onwards