Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Tomcat 5 compiles jsp with wrong argument type for a tag on a Mac OSX

 
Jimi Brankenberg
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65535
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Having overloaded ambiguous setters violates the JavaBean standard and I am not surprised you are having problems. You'll need to fix your bean if you want deterministic behavior.
 
Jimi Brankenberg
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Having overloaded ambiguous setters violates the JavaBean standard and I am not surprised you are having problems.


ok, I was not aware that java tags was supposed to follow the JavaBean standard.

You'll need to fix your bean if you want deterministic behavior.


Well, as I wrote above the tag is written by a third party vendor. But if you possibly can point me to where I can find some detailed description of how tags should follow the JavaBean standard then I can write to them and complain that their tags doesn't do that. I have looked, but can't find anything.

Regards
/Jimi
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65535
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, tag setters are expected to follow bean patterns. Both JSP and the EL expects JavaBean conventions to be followed. The manner that JSP and the EL operate, including coercion rules, are detailed in their specifications. I believe that links can be found in the JspFaq.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65535
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you cannot change the 3rd party code, perhaps you can put a better-behaved proxy in front of it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!