Spring invalid dynamic attributes when updating to Java 7
I am in charge of a quite old website who was at first compiling with Java 5 and now Java 6. I'm using Spring 3.1.
I'm trying to update from Java 6/ Tomcat 6 to Java 7 / Tomcat 7 and I have a lot of problems regarding the form tags.
For this code:
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%> ... <form:textarea path="myPath" placeholder="hello world" id="myId" rows="1" />
I get that error:
Attribute placeholder invalid for tag textarea according to TLD
It seems that a lot of the attributes I was using before updating Java don't work anymore. Do you have any idea why? Thanks!
It looks like the WAR contains accidentally several versions of the TLD, and in Tomcat 6 the correct version is found, but on Tomcat 7 the wrong version is loaded instead.
If two different versions of the same jar are present in WEB-INF/lib, there is no way to predict which one will be chosen, the results are dependent on the classloader implementation details, and so different Tomcat versions might yield different results.
To verify this, try looking in your IDE by the multiple versions of file spring.schemas. These files contain the mapping between url's such as http://www.springframework.org/tags/form and the XSDs /TLDs shipped inside the same jar.
This mechanism exists for XSDs/TLDs that are not published online such as the url of this case, if you paste the url to a browser the file does not exist.
In this case there should be two spring.schemas both with mention to url http://www.springframework.org/tags/form. Remove the one with the wrong version of the XSD/TLD and it should work correctly in both Tomcat versions.