tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantin Kolinko <knst.koli...@gmail.com>
Subject Re: EL Resolver throws InvocationTargetException (char-long conversation)
Date Mon, 11 Jun 2012 07:58:46 GMT
2012/6/11 burghard.britzke <bubi@charmides.in-berlin.de>:
> with tomcat 7.0.27, primefaces 3.3, myfaces 2.1.17, weld 1.1.8
>
> for the jsf-source
> Line 56: <h:graphicImage
> Line 57:    value="/images/#{personenBean.aktuellePerson.geschlecht eq 'w' ? 'fe':''}male.png">
> Line 58: </h:graphicImage>
>
> and the bean
> public class Person implements Serializable {
>        @Column(name = "\"geschlecht\"", nullable = false, length = 1)
>        private char geschlecht;
> ...
>
> an Exception is thrown
>
> java.lang.reflect.InvocationTargetException
> Caused by:<br/>javax.el.ELException - Cannot convert w of type class java.lang.String
to class java.lang.Long
> at org.apache.el.lang.ELSupport.coerceToNumber(ELSupport.java:304)
> personen.xhtml at line 57 and column 92    value="/images/#{personenBean.aktuellePerson.geschlecht
eq 'w' ? 'fe':''}male.png"
>
> At MyFaces Discussion <users@myfaces.apache.org> they told me this would probably
be an issue with tomcat so I downgraded to Tomcat 7.0.25 and the error disappeared.
> What are the next steps to get rid of this exception with Tomacat 7.0.27?
>

Yes, Tomcat behaviour changed and new behaviour follows the EL
specification more closely. It was because of this bug report:
https://issues.apache.org/bugzilla/show_bug.cgi?id=52666

See EL specification for more details.

According to EL 2.2 ch. 1.18.3 coercion from char to a number is performed as
"If A is Character, convert A to new Short((short)a.charValue()) ..."

so you have to s/'w'/119/.

There might be other workarounds, such as
a) Add another property to that bean that will return the value as String
b) Use a function such as fn:trim() from JSTL to force conversion of
that value into String.

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message