The exception message coming from ensureObj() is somewhat confusing, it should be something like
Cannot get java.lang.Long field com.test.ProductBean$ID.productID from instance of type com.test.ProductBean$ID
as the class of the passed instance == com.test.ProductBean$ID.class is not assignable to the field.getDeclaringClass() == com.test.ProductBean$ID.class.
Smells like class-loading issue up the stack.
I agree that this sounds like a class-loader issue. It sounds like the second level cache has references to the previous deployments classes. I believe that Paul's patch ( HHH-10545 + HHH-10546) is helping to ensure that the second level cache is stopped at application undeployment time. I expect that stopping the cache at application undeploy time, should mean that when the application is deployed again, it starts with an empty cache (so no references to the undeployed classloader will be kept around). Make sense? |