Monday, December 22, 2008

Gilead: PersistentRemoteService

Gilead does merge operations when you made a service call using PersistentRemoteService, before with hibernate4gwt it didn't do it on all service calls. So we had this nice error

[WARN] StandardContext[]Exception while dispatching incoming RPC call
java.lang.NullPointerException: null
at net.sf.gilead.core.PersistentBeanManager.mergePojo(PersistentBeanManager.java:423)
at net.sf.gilead.core.PersistentBeanManager.merge(PersistentBeanManager.java:289)
at net.sf.gilead.gwt.GileadRPCHelper.parseInputParameters(GileadRPCHelper.java:89)
at net.sf.gilead.gwt.PersistentRemoteService.processCall(PersistentRemoteService.java:147)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:86)

So if you don't use spring to create your PersistentRemoteServices, then you have to include these 2 lines in the constructor of all your services.

XmlBeanFactory application = ApplicationContextFactory.getXmlBeanFactoryInstance();
setBeanManager((PersistentBeanManager) application.getBean("hibernateBeanManager"));