Hi,
After we upgraded java from 1.5 to 1.6 on a development machine, we started getting alot of the following exception in the log, and several pages didn't display properly.
2011-06-16 11:04:01 ApplicationDispatcher[] Servlet.service() for servlet jsp threw exception
javax.servlet.jsp.el.ELException: Attempt to coerce a value of type "neo.xredsys.presentation.PresentationArticleImpl" to type "neo.xredsys.api.Article"
at org.apache.commons.el.Logger.logError(Logger.java:481)
at org.apache.commons.el.Logger.logError(Logger.java:498)
at org.apache.commons.el.Logger.logError(Logger.java:566)
at org.apache.commons.el.Coercions.coerceToObject(Coercions.java:799)
at org.apache.commons.el.Coercions.coerce(Coercions.java:343)
at org.apache.commons.el.ExpressionEvaluatorImpl.convertToExpectedType(ExpressionEvaluatorImpl.java:345)
at org.apache.commons.el.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:267)
at org.apache.commons.el.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:190)
at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:899)
at org.apache.jsp.template.ver2_002d0.fp.divider.divider.divider_jsp._jspService(divider_jsp.java:139)
When I look at the file divider_jsp.java I can clearly see that it is using the class "neo.xredsys.api.Article". Maybe I should mention that the tag in question has two set methods with the same name, setArticle, one of them takes a "neo.xredsys.api.Article" and the other takes a "neo.xredsys.presentation.PresentationArticle" (the interface for PresentationArticleImpl).
The jsp in questions looks like:
<article:use article="${someArticle}">
And the "someArticle value is of the type "neo.xredsys.presentation.PresentationArticleImpl". And when I look at an old divider_jsp.java, the same exact line of code uses "neo.xredsys.presentation.PresentationArticle". So for some reason Tomcat/Jasper (/Tomcat 5.0.28) has decided to use the argument type for the *other* setArticle method all of the sudden, and this is causing the error.
Can someone explain why this is happening? Is it not supposed to be able to calculate correctly which setter method it should use, when there are more then one? The tag is created by a third party CMS, and this code has been working for a long time. And we really would like to understand what went wrong, and how we can make it work like before. Any suggestions are welcome.
By the way, is there any official name for the process of turning a jsp file to a java file? I don't think "compile" works very well, because that suggests that the end result is a class file.
EDIT:
I just got some more information from the developer that owns the machine in question, and apparently the problem did not start with the upgrade to java 6. In fact, the problem has occured all the time, and the machine in question is a Mac with Leopard OSX.
So can someone understand why this happens with Tomcat on a Mac? Maybe it is just plain luck that the correct setter method is selected on the windows and linux machines? I would really like to understand the logic behind this setter method selection. Any hint on where the source code is for this?
Regards
/Jimi