Tuesday, July 1, 2014

GlassFish 4.0 ClassCastException on Class with the Same Type

Repeated deploy and undeploy of applications in GlassFish you may encounter the following class loader issue.

java.lang.ClassCastException: my.com.Test cannot be cast to my.com.Test

Within the GlassFish administration console:

Disable and Undeploy the application.
Restart the server.
Deploy the application.

Using Reload or Redeploy will not resolve the issue.