Re: Random ClassCastException : I'm expecting Long, Struts gives me String on some servers...
I put some @Conversion(), @Element(value = java.lang.Long.class) and @TypeConversion(rule = ConversionRule.COLLECTION, converter = java.lang.Long) in my Action and it's not working better. So I set the convertion in a properties file with : Element_idsCommerciaux=java.lang.Long and it is working, thanks Ralf. I tried to put v2.1.6 but I had a lot of trouble with EL expression (s:if test=${}, s:if test=#session...) which seemed to have changed, but I see nothing in the docs, release ntoes or migration guide, so I gave up (600 JSP to change and no time to do it) Thanks for your help. -- View this message in context: http://www.nabble.com/Random-ClassCastException-%3A-I%27m-expecting-Long%2C-Struts-gives-me-String-on-some-servers...-tp21722894p21743689.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Random ClassCastException : I'm expecting Long, Struts gives me String on some servers...
On Fri, Jan 30, 2009 at 10:10 AM, mleneveut mlenev...@abusinessware.com wrote: I put some @Conversion(), @Element(value = java.lang.Long.class) and @TypeConversion(rule = ConversionRule.COLLECTION, converter = java.lang.Long) in my Action and it's not working better. So I set the convertion in a properties file with : Element_idsCommerciaux=java.lang.Long and it is working, thanks Ralf. I tried to put v2.1.6 but I had a lot of trouble with EL expression (s:if test=${}, s:if test=#session...) which seemed to have changed, but I see nothing in the docs, release ntoes or migration guide, EL expressions attributes of struts tags which are evaluated on the ValueStack are a security risk. See [1]. Outside from struts tags you can still access objects on the valuestack, as struts intercepts the lookup to the page context. For the other way around you have to fully markup when you want to access the page context and such. ( foo=#attr.bar ). so I gave up (600 JSP to change and no time to do it) Take peace and comfort in the fact that you're not the only one who has/had to do this :-) Cheers, -Ralf [1] https://issues.apache.org/struts/browse/WW-2107 Thanks for your help. -- View this message in context: http://www.nabble.com/Random-ClassCastException-%3A-I%27m-expecting-Long%2C-Struts-gives-me-String-on-some-servers...-tp21722894p21743689.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Random ClassCastException : I'm expecting Long, Struts gives me String on some servers...
Hi all, I have a very strange thing. I have a multiple select in my JSP, and a ListLong of ids in my Action. When I submit the form, I iterate on that List of Long, and I have this error : java.lang.ClassCastException: java.lang.String Struts has String in the List instead of Long. The strange thing is that it appends on some servers (TomCat 5.5) but not on other : it works on my local computer, bug on the test server, works on the production server, and works on all other servers. I first thought it was a Struts dtd cache version problem on the Eclipse of the person building the WAR, but I have the same problem on my Eclipse (which build working WAR for other servers). We copied all jars files from shared/lib of a working TomCat to the bugging TomCat, but it doesn't fix the problem. Did someone already see such a thing ? Do you have an idea of where it could bug ? Thanks a lot. Here is my code : JSP : (id is a long, nomComplet is a String) s:select id=selectCommercial name=idsCommerciaux list=listCommercial listKey=id listValue=nomComplet cssStyle=width: 200 emptyOption=true multiple=true size=10 /s:select Action : private ListLong idsCommerciaux; public ListLong getIdsCommerciaux() { return idsCommerciaux; } public void setIdsCommerciaux(ListLong idsCommerciaux) { this.idsCommerciaux = idsCommerciaux; } for (Long unCommercial : idsCommerciaux) { //ClassCastException here Struts2 version : 2.1.0 -- View this message in context: http://www.nabble.com/Random-ClassCastException-%3A-I%27m-expecting-Long%2C-Struts-gives-me-String-on-some-servers...-tp21722894p21722894.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Random ClassCastException : I'm expecting Long, Struts gives me String on some servers...
Hi, On Thu, Jan 29, 2009 at 10:06 AM, mleneveut mlenev...@abusinessware.com wrote: Hi all, I have a very strange thing. I have a multiple select in my JSP, and a ListLong of ids in my Action. When I submit the form, I iterate on that List of Long, and I have this error : java.lang.ClassCastException: java.lang.String Struts has String in the List instead of Long. The strange thing is that it appends on some servers (TomCat 5.5) but not on other : it works on my local computer, bug on the test server, works on the production server, and works on all other servers. I first thought it was a Struts dtd cache version problem on the Eclipse of the person building the WAR, but I have the same problem on my Eclipse (which build working WAR for other servers). We copied all jars files from shared/lib of a working TomCat to the bugging TomCat, but it doesn't fix the problem. Did someone already see such a thing ? Do you have an idea of where it could bug ? Thanks a lot. Here is my code : JSP : (id is a long, nomComplet is a String) s:select id=selectCommercial name=idsCommerciaux list=listCommercial listKey=id listValue=nomComplet cssStyle=width: 200 emptyOption=true multiple=true size=10 /s:select Action : private ListLong idsCommerciaux; public ListLong getIdsCommerciaux() { return idsCommerciaux; } public void setIdsCommerciaux(ListLong idsCommerciaux) { this.idsCommerciaux = idsCommerciaux; } for (Long unCommercial : idsCommerciaux) { //ClassCastException here This seems like a type erasure problem. Reflection is used to set the entries into the list. As the generic type of the idsCommerciaux list is not available at runtime the no convertion to Long takes place for the List elements. So a List containing Strings is injected. Check out the Collection and Map Support portion from the type conversion documentation[1]. You might want use an ObjectTypeDeterminer I think. Struts2 version : 2.1.0 You should think about upgrading to 2.1.6, as it became GA recently. Cheers, -Ralf [1] http://struts.apache.org/2.0.14/docs/type-conversion.html -- View this message in context: http://www.nabble.com/Random-ClassCastException-%3A-I%27m-expecting-Long%2C-Struts-gives-me-String-on-some-servers...-tp21722894p21722894.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Random ClassCastException : I'm expecting Long, Struts gives me String on some servers...
Hi, Thanks for your reply. What I can't understand is why it works in some environments, and no others. The war is the same. And why do you say that the generic type of the idsCommerciaux list is not available at runtime ? I defined it as a ListLong in the Action. So Struts should know that it has to convert the data submitted to Long, doesn't it ? Ralf Fischer-2 wrote: Hi, This seems like a type erasure problem. Reflection is used to set the entries into the list. As the generic type of the idsCommerciaux list is not available at runtime the no convertion to Long takes place for the List elements. So a List containing Strings is injected. Check out the Collection and Map Support portion from the type conversion documentation[1]. You might want use an ObjectTypeDeterminer I think. Struts2 version : 2.1.0 You should think about upgrading to 2.1.6, as it became GA recently. Cheers, -Ralf [1] http://struts.apache.org/2.0.14/docs/type-conversion.html -- View this message in context: http://www.nabble.com/Random-ClassCastException-%3A-I%27m-expecting-Long%2C-Struts-gives-me-String-on-some-servers...-tp21722894p21729390.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Random ClassCastException : I'm expecting Long, Struts gives me String on some servers...
mleneveut wrote: What I can't understand is why it works in some environments, and no others. The war is the same. Probably because there were known bugs in 2.1.0 (both struts and xwork). As such, it was never intended for general use. The first GA (General Availability) 2.1.x was 2.1.6. Upgrade to an actual release and *then* see if the issue is resolved. If your bug remains then there might be people here motivated to help you. If you're just trying to find a bug that's already been fixed, I wouldn't expect that to motivate the *volunteers* here to respond. -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org