You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Roxana <mi...@gmail.com> on 2010/07/06 19:20:39 UTC

Strange difference in behavior ELSupport in Tomcat 6.0.20 and Tomcat 6.0.26

Hi,

I have a problem that i don't understand and i hope you can help me with.

I migrate from Tomcat 6.0.20 to Tomcat 6.0.26 and suddenly  i get an
exception like this:

05-Jul-2010 16:22:50 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
javax.el.ELException: Cannot convert CREATION_TIME of type class
com.docbox.tag.DocboxListColumn to class
com.owt.tag.ListContent.GenericListColumn
 at org.apache.el.lang.ELSupport.coerceToEnum(ELSupport.java:155)
 at org.apache.el.lang.ELSupport.equals(ELSupport.java:110)
 at org.apache.el.parser.AstNotEqual.getValue(AstNotEqual.java:39)
 at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
 at
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:935)
 at
org.apache.jsp.owt.list_005fcontent_jsp._jspx_meth_c_005fwhen_005f1(list_005fcontent_jsp.java:876)
 at
org.apache.jsp.owt.list_005fcontent_jsp._jspx_meth_c_005fchoose_005f1(list_005fcontent_jsp.java:846)
 at
org.apache.jsp.owt.list_005fcontent_jsp._jspService(list_005fcontent_jsp.java:282)
 at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
etc etc...................................



What i don't understand is why, with the same code , Tomcat 6.0.20 didn't
complain.  Is the type check in ELSupport stronger now?
In my case i try to compare two different enums: DocboxListColumn  and
GenericListColumn, but they both implement  interface ListColumn.

I hope you can help me with an answer

 Thanks in advanced

Roxana Frunza

Re: Strange difference in behavior ELSupport in Tomcat 6.0.20 and Tomcat 6.0.26

Posted by Mark Thomas <ma...@apache.org>.
On 06/07/2010 22:20, Pid wrote:
> On 06/07/2010 18:20, Roxana wrote:

>> What i don't understand is why, with the same code , Tomcat 6.0.20 didn't
>> complain.  Is the type check in ELSupport stronger now?

Have you read to EL specification to see what the correct behaviour 
should be?

Have you looked at the changelog to see if there are any changes between 
6.0.20 and 6.0.26 that might apply (Hint: EL related changes will be in 
the Jasper sections)?

This is *open* source. Have you looked at the svn commit messages to see 
if there are any relevant changes?
(Hint: tomcat.markmail.org ha a nice UI that makes this fairly easy. The 
EL implementation is in the org.apache.el package)

>> In my case i try to compare two different enums: DocboxListColumn  and
>> GenericListColumn, but they both implement  interface ListColumn.
>>
>> I hope you can help me with an answer

See above and you should be able to find the answer yourself.

> Bit of a mystery without seeing the JSP content.

I'm fairly sure this is an application bug but without a concrete 
example, it is hard to be certain.

Mark



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


Re: Strange difference in behavior ELSupport in Tomcat 6.0.20 and Tomcat 6.0.26

Posted by Pid <pi...@pidster.com>.
On 06/07/2010 18:20, Roxana wrote:
> Hi,
> 
> I have a problem that i don't understand and i hope you can help me with.
> 
> I migrate from Tomcat 6.0.20 to Tomcat 6.0.26 and suddenly  i get an
> exception like this:
> 
> 05-Jul-2010 16:22:50 org.apache.catalina.core.StandardWrapperValve invoke
> SEVERE: Servlet.service() for servlet jsp threw exception
> javax.el.ELException: Cannot convert CREATION_TIME of type class
> com.docbox.tag.DocboxListColumn to class
> com.owt.tag.ListContent.GenericListColumn
>  at org.apache.el.lang.ELSupport.coerceToEnum(ELSupport.java:155)
>  at org.apache.el.lang.ELSupport.equals(ELSupport.java:110)
>  at org.apache.el.parser.AstNotEqual.getValue(AstNotEqual.java:39)
>  at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
>  at
> org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:935)
>  at
> org.apache.jsp.owt.list_005fcontent_jsp._jspx_meth_c_005fwhen_005f1(list_005fcontent_jsp.java:876)
>  at
> org.apache.jsp.owt.list_005fcontent_jsp._jspx_meth_c_005fchoose_005f1(list_005fcontent_jsp.java:846)
>  at
> org.apache.jsp.owt.list_005fcontent_jsp._jspService(list_005fcontent_jsp.java:282)
>  at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
>  at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
> etc etc...................................
> 
> 
> 
> What i don't understand is why, with the same code , Tomcat 6.0.20 didn't
> complain.  Is the type check in ELSupport stronger now?
> In my case i try to compare two different enums: DocboxListColumn  and
> GenericListColumn, but they both implement  interface ListColumn.
> 
> I hope you can help me with an answer


Bit of a mystery without seeing the JSP content.


p


Re: Strange difference in behavior ELSupport in Tomcat 6.0.20 and Tomcat 6.0.26

Posted by Mark Thomas <ma...@apache.org>.
On 27/09/2010 03:39, sbrejeon wrote:
> The spec says that "If A or B is an enum, coerce both A and B to enum, apply
> operator".
> Does't it simply mean that both A and B must be coercible to enums. instead
> of if A is an enum then B must be an enum of type A, or vice versa.

No. Both must be of the same type. There are several reasons for this:
- There is no provision in the EL spec for enum to enum type conversion
via a string value
- If both A & B are enums, should both values be coerced to enum A or
enum B? One may work whilst the other fails. If the spec permitted this
then the behaviour in this case would need to be defined. It isn't.
- Section 1.17 is clear the String values must be used to trigger enum
type conversion

> Like the original creator of this post, I have a series of enums of
> different types that implement a common interface. I need to be able to
> compare them and I don't want to have to translate them to Strings.

The EL spec doesn't support what you are trying to do.

Mark

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


Re: Strange difference in behavior ELSupport in Tomcat 6.0.20 and Tomcat 6.0.26

Posted by sbrejeon <sb...@daesim.com>.

markt-2 wrote:
> 
> On 27/09/2010 02:23, sbrejeon wrote:
>> A.test==B.test throws the exception. couldn't it just return false?
> 
> Such a change would put Tomcat's EL implementation in breach of the EL
> spec so this behaviour will not be changed.
> 
> Mark
> 

Thank you for your quick reply.

The spec says that "If A or B is an enum, coerce both A and B to enum, apply
operator".
Does't it simply mean that both A and B must be coercible to enums. instead
of if A is an enum then B must be an enum of type A, or vice versa.

in the coerceToEnum method I would return the object if it is an enum
(whatever its type is):

public final static Enum<?> coerceToEnum(final Object obj, Class type) {
    if (obj == null || "".equals(obj)) {
        return null;
    }

    if(obj.getClass().isEnum()){
         return (Enum<?>)obj;
    }
...
}

Like the original creator of this post, I have a series of enums of
different types that implement a common interface. I need to be able to
compare them and I don't want to have to translate them to Strings.

Regards
Sbrejeon


-- 
View this message in context: http://old.nabble.com/Strange-difference-in-behavior-ELSupport-in-Tomcat-6.0.20-and-Tomcat--6.0.26-tp29088066p29815521.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


Re: Strange difference in behavior ELSupport in Tomcat 6.0.20 and Tomcat 6.0.26

Posted by Mark Thomas <ma...@apache.org>.
On 27/09/2010 02:23, sbrejeon wrote:
> A.test==B.test throws the exception. couldn't it just return false?

Such a change would put Tomcat's EL implementation in breach of the EL
spec so this behaviour will not be changed.

Mark

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


Re: Strange difference in behavior ELSupport in Tomcat 6.0.20 and Tomcat 6.0.26

Posted by sbrejeon <sb...@daesim.com>.

Konstantin Kolinko wrote:
> 
> 2010/7/6 Roxana <mi...@gmail.com>:
> BTW, if you really need to compare apples with oranges, you can
> convert one of them or both to strings.
> Best regards,
> Konstantin Kolinko
> 

http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/lang/ELSupport.java?revision=981816&view=markup

equals:
144 	 } else if (obj0.getClass().isEnum()) {
145 	return obj0.equals(coerceToEnum(obj1, obj0.getClass())); 

coerceToEnum(obj, type):
180 	 if (type.isAssignableFrom(obj.getClass())) {
181 	return (Enum<?>) obj;
182 	}
183 	
184 	if (!(obj instanceof String)) {
185 	throw new ELException(MessageFactory.get("error.convert",
186 	obj, obj.getClass(), type));
187 	} 

enum A{
 test
}

enum B{
 test
}

A.test==B.test throws the exception. couldn't it just return false?

Regards
Sbrejeon






-- 
View this message in context: http://old.nabble.com/Strange-difference-in-behavior-ELSupport-in-Tomcat-6.0.20-and-Tomcat--6.0.26-tp29088066p29815264.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


Re: Strange difference in behavior ELSupport in Tomcat 6.0.20 and Tomcat 6.0.26

Posted by Konstantin Kolinko <kn...@gmail.com>.
2010/7/6 Roxana <mi...@gmail.com>:
>
> What i don't understand is why, with the same code , Tomcat 6.0.20 didn't
> complain.  Is the type check in ELSupport stronger now?

Yes, it is stronger.

> In my case i try to compare two different enums: DocboxListColumn  and
> GenericListColumn, but they both implement  interface ListColumn.
>

The chapter 1.8.2 of the EL spec (jsp-2_1-fr-spec-el.pdf) says that
equals operator is applied as follows:
If A or B is an enum, coerce both A and B to enum, apply operatorr


BTW, if you really need to compare apples with oranges, you can
convert one of them or both to strings. There is no string "concat"
operator in EL, but there is support for  "Composite expressions",
such as “${firstName} ${lastName}”

Best regards,
Konstantin Kolinko

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