I am using EJB2.0 .I am executing a query that first populate data into a bean and then add this bean into a list and i am returning this list from a business method in the stateless SessionBean. Everything is fine it is executing the query and returning the list containing the beans but when i used to cast the list.get(i) to my bean type then it throwing ClasscastException in my Action class in the web client .Bean class id serializable..?? please help
Please check the type in which you are getting the list.get(i). In java ClasscastException is thrown when you wrongly cast one object to other type. For example yesterday I was trying to cast Enumeration object into Vector and I was also gettng the same exception.
posted 12 years ago
thanks akhi i am uing the same type of class to cast it but still it is throwing this problem
We're pleased to have you here with us here on the ranch, but there are a few rules that need to be followed. One is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.
In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious. Initials are OK for the first and middle names but not the last. You can change it here [ June 09, 2008: Message edited by: Ben Souther ]
If you are certain that the class types are identical, then there must be a classloading problem. If you have one application, then build a single EAR file containing your WAR and EJB files. This will work because the EJB server will load the EJB classes before the web classes, thus ensuring that the EJB classes will be visible to the web application and not loaded twice.
SCJP 1.4, SCWCD 1.3, SCBCD 1.3
There's a way to do it better - find it. -Edison. A better tiny ad: