Hi!
I have a really wierd problem that I still can't solve, even after googling for about 6 hours =(
I've made a simple
test servlet that seems to work fine, I'm using JPA that links to MySQL and it also works perfectly. The problem arise after redeploying application to the
Tomcat. Actually it works fine the first time I start server and access servlet through browser. But if I change something in my code (even if I add something simple like System.out) when I redeploy the application Tomcat gives me a ClassCastException:
It can't cast class com.mycompany.jpatest.Person to itself =)))
Here is the code that gives me an error (to be exact it's the for loop at line 7):
After some debugging I find that after redeploying application Person class has the same hash. That means I think that it's still exists in the memory since the first server start/servlet access. It is loaded by classloader and still hangs there even after I deploy a new version of my class. How can I force Tomcat to reload all this classes to get a new version?
It works fine if a restart Tomcat, but this piss me off to restart server every time I want to change something in my code =( Any suggestions?
Thanks!