Details
-
Bug
-
Status: Closed
-
Resolution: Fixed
-
7.2.X, 7.3.X, Master
-
7.3.x, 7.2.x
-
Committed
-
3
Description
Initial Findings
Liferay's JSP Compiler ends up using classes from Liferay's global Spring libraries, instead of the OSGI module's provided Spring libraries.
This can lead to compilation failures, especially when the Spring versions don't match (e.g. Spring 3 vs 4)
Steps to Reproduce
- Deploy poc-older-spring-library.war
- Add portlet: poc-older-spring-library to the page
Expected Result
The portlet is displayed without any errors and stacktraces
Actual Result
The portlet shows an error and a stacktraces are thrown
Sample Stacktrace: poc-sample-stacktrace.txt
Additional Details
Creating: poc-older-spring-library
Source code attached: poc-older-spring-library-src.zip
- Run: blade init -v 7.3
- Run: blade create -t spring-mvc-portlet -p poc.older.spring.library --framework springportletmvc --view-type jsp poc-older-spring-library
- Edit file: modules/poc-older-spring-library/build.gradle to use older Spring libraries
- Replace version: 4.1.9.RELEASE with 3.2.18.RELEASE
- Edit file: modules/poc-older-spring-library/src/main/webapp/WEB-INF/views/user.jspx to add disabled attribute
- Replace: <form:input id="${namespace}firstName" cssClass="form-control" path="firstName"/>
- With: <form:input id="${namespace}firstName" cssClass="form-control" path="firstName" disabled="true"/>
- Run: gradlew build
- Locate compiled WAR: modules/poc-older-spring-library/build/libs/poc-older-spring-library.war
Note: The portlet works as expected if we skip step 4
Compile Error - Analysis
Using the attribute disabled="true" introduces this compilation error, due to code differences between Spring 3.2.18.RELEASE vs 4.1.9.RELEASE
The error seems to be related on not recognizing the parameter as String and expecting a boolean instead.
This conclusion was made because the class org.springframework.web.servlet.tags.form.InputTag extends org.springframework.web.servlet.tags.form.AbstractHtmlInputElementTag and in this class there are some codes refactor regarding getter and setter, in https://mvnrepository.com/artifact/org.springframework/spring-webmvc version 3.x receives and returns String and in version 4.x receives and returns boolean, maybe here is the clue.
For 3.2.18: spring-framework - v3.2.18.RELEASE - AbstractHtmlInputElementTag.java#L139-L145
/** * Set the value of the '{@code disabled}' attribute. * May be a runtime expression. */ public void setDisabled(String disabled) { this.disabled = disabled; }
For 4.1.9: spring-framework - v4.1.9.RELEASE - AbstractHtmlInputElementTag.java#L139-L144
/** * Set the value of the '{@code disabled}' attribute. */ public void setDisabled(boolean disabled) { this.disabled = disabled; }