I am using Glassfish-v2ur2 on a Windows machine for developing a J2EE web-app. It is being run with the -client option. Sometimes, while re-deploying an application under development, I see a deployment failure with the server log indicating a ClassCastException. This always involves one of the many Entity classes we have in our application. At deployment time, we load a few rows from the database tables that corresponding to these entity classes into memory, and it is while loading these rows that we see this exception. Even the log messages indicates that the class is what it should be cast to.
To clarify, the exception stack contains an error message of the type:
java.lang.ClassCastException: [i]MyClass[/i] cannot be cast to [i]MyClass[/i]
When I say "at deployment time" above, I mean within a [i]ServletContextListener[/i], implying that the loading happens afresh everytime the application is deployed/re-deployed and never otherwise.
Also, please note that this failure is seen only once in a while and even if I haven't changed anything in the code/database, so I am not sure if it indicates a code/schema problem. The failure always goes away for a while if I restart my Glassfish instance.
Any pointers will be much appreciated.
Thanks
[Message sent by forum member 'tspladmin' (ruchirbindal_at_gmail.com)]
http://forums.java.net/jive/thread.jspa?messageID=371115