I'm setting up a GWT application based on GWT/RequestFactory on client side, and JPA/EclipseLink over WebLogic on server side.
However, during development, everytime I change something on the server-side code (it can be an entity, the DAO, or even a comment in a Java file!), I get a ClassCastException
between 2 apparently similar classes when I try to use my application, and the only way to get rid of it is to restart my WebLogic server. Even redeploying the application doesn't help.
Feb 10, 2012 4:08:10 PM com.google.web.bindery.requestfactory.server.RequestFactoryServlet doPost SEVERE: Unexpected error java.lang.ClassCastException: com.mycompany.MyClass cannot be cast to com.mycompany.MyClass at com.mycompany.server.locator.CodeLevelLocator.getId(MyClassLocator.java:1) at com.google.web.bindery.requestfactory.server.LocatorServiceLayer.doGetId(LocatorServiceLayer.java:168) at com.google.web.bindery.requestfactory.server.LocatorServiceLayer.getId(LocatorServiceLayer.java:66) at com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.getId(ServiceLayerDecorator.java:81)
Any idea how to avoid this server restart?
Thanks.
EDIT: I'm setting up a bounty on this, because restarting WebLogic after each server change is really painful!!!
EDIT2 solved thanks to James by adding the following ServletContextListener:
public class DeploymentListener implements ServletContextListener {
private static Logger log = LoggerFactory
.getLogger(DeploymentListener.class.getName());
@Override
public void contextDestroyed(ServletContextEvent arg0) {
try {
// close the Entity Manager Factory.
EMF.close();
} catch (Exception e) {
log.error("Error closing the Entity Manager Factory", e);
}
}
@Override
public void contextInitialized(ServletContextEvent arg0) {
// nothing to do
}
}