PDA

View Full Version : How do you debug getHibernateTemplate().saveOrUpdate()?



jwhite
Sep 1st, 2004, 10:36 AM
All,

I am receiving a NullPointerException when all call saveOrUpdate. I have made sure the object I am passing in is not null. How do I debug this further?

Joshua



[junit] Testcase: testAddAndRemove(employeeclub.dao.ActivityTicketDa oTest): Caused an ERROR
[junit] null
[junit] java.lang.NullPointerException
[junit] at employeeclub.dao.hibernate.ActivityTicketDaoHibern ate.saveItem(ActivityTicketDaoHibernate.java:41)
[junit] at employeeclub.dao.hibernate.ItemDaoHibernate.saveIt em(ItemDaoHibernate.java:31)
[junit] at employeeclub.dao.ActivityTicketDaoTest.testAddAndR emove(ActivityTicketDaoTest.java:41)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)

Colin Sampaleanu
Sep 1st, 2004, 10:39 AM
It looks like you are getting the null pointer exception in your own code, by the stack trace below. One option is of course to attach to your your code with a debugger (like Eclipse's), and step through your code. As far as I can tell, there is nothing Spring related to this...

jwhite
Sep 1st, 2004, 10:50 AM
I should have mentioned that this is the place where the error is reported:

getHibernateTemplate().saveOrUpdate(activityTicket );

above it, I check to see that getHibernateTemplate() actually returns an object, and it does as expected. The nullPointer seems to occur in the saveOrUpdate implementation.

Any ideas?

jwhite
Sep 1st, 2004, 10:54 AM
I did a clean, recompile and test. Now it works. I am all set.

Thanks,

Joshua

Colin Sampaleanu
Sep 1st, 2004, 10:58 AM
Hmm, that's very very weird that you're losing the stack info from the real location.

All I can suggest is then to actually step into the Spring saveOrUpdate method to see what is going on. Just keep in mind that's just a wrapper around the Session saveOrUpdate method, so probably with a decent amount of certainty, the exception is actually happening inside Hibernate.


Edited later: just saw your second post. Glad to hear it's working.

gigsvoo
May 17th, 2006, 02:35 AM
I am glad to hear this problem is solved. Mine not yet solved and same problem as yours.

I also done the clean and build and redeploy from scratch.

These are my stack trace:



2006-05-17 15:30:15,948 INFO [STDOUT] java.lang.NullPointerException
2006-05-17 15:30:15,963 INFO [STDOUT] at gov.mohr.ems.core.entity.logic.PersistenceImpl.upl oad(PersistenceImpl.java:62)
2006-05-17 15:30:15,979 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
2006-05-17 15:30:16,010 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
2006-05-17 15:30:16,026 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
2006-05-17 15:30:16,041 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
2006-05-17 15:30:16,057 INFO [STDOUT] at org.jboss.webservice.server.InvokerProviderJSE.inv okeServiceEndpoint(InvokerProviderJSE.java:154)
2006-05-17 15:30:16,073 INFO [STDOUT] at org.jboss.webservice.server.InvokerProvider.invoke Method(InvokerProvider.java:305)
2006-05-17 15:30:16,088 INFO [STDOUT] at org.jboss.axis.providers.java.RPCProvider.invokeTa rget(RPCProvider.java:176)
2006-05-17 15:30:16,104 INFO [STDOUT] at org.jboss.webservice.server.InvokerProviderJSE.inv okeTarget(InvokerProviderJSE.java:93)
2006-05-17 15:30:16,119 INFO [STDOUT] at org.jboss.axis.providers.java.RPCProvider.processM essage(RPCProvider.java:121)
2006-05-17 15:30:16,135 INFO [STDOUT] at org.jboss.axis.providers.java.JavaProvider.invoke( JavaProvider.java:358)
2006-05-17 15:30:16,151 INFO [STDOUT] at org.jboss.axis.strategies.InvocationStrategy.visit (InvocationStrategy.java:73)
2006-05-17 15:30:16,166 INFO [STDOUT] at org.jboss.axis.SimpleChain.doVisiting(SimpleChain. java:160)
2006-05-17 15:30:16,182 INFO [STDOUT] at org.jboss.axis.SimpleChain.invoke(SimpleChain.java :123)
2006-05-17 15:30:16,182 INFO [STDOUT] at org.jboss.axis.handlers.soap.SOAPService.invoke(SO APService.java:560)
2006-05-17 15:30:16,198 INFO [STDOUT] at org.jboss.webservice.server.ServerEngine.invokeInt ernal(ServerEngine.java:200)
2006-05-17 15:30:16,198 INFO [STDOUT] at org.jboss.webservice.server.ServerEngine.invoke(Se rverEngine.java:89)
2006-05-17 15:30:16,213 INFO [STDOUT] at org.jboss.axis.transport.http.AxisServlet.doPost(A xisServlet.java:911)
2006-05-17 15:30:16,229 INFO [STDOUT] at javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
2006-05-17 15:30:16,229 INFO [STDOUT] at org.jboss.axis.transport.http.AxisServletBase.serv ice(AxisServletBase.java:370)
2006-05-17 15:30:16,244 INFO [STDOUT] at javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
2006-05-17 15:30:16,244 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:252)
2006-05-17 15:30:16,260 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:173)
2006-05-17 15:30:16,276 INFO [STDOUT] at org.acegisecurity.ui.AbstractProcessingFilter.doFi lter(AbstractProcessingFilter.java:246)
2006-05-17 15:30:16,276 INFO [STDOUT] at org.acegisecurity.util.FilterToBeanProxy.doFilter( FilterToBeanProxy.java:120)
2006-05-17 15:30:16,291 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:202)
2006-05-17 15:30:16,369 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:173)
2006-05-17 15:30:16,369 INFO [STDOUT] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doF ilter(ReplyHeaderFilter.java:81)
2006-05-17 15:30:16,385 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:202)
2006-05-17 15:30:16,401 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:173)
2006-05-17 15:30:16,401 INFO [STDOUT] at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:213)
2006-05-17 15:30:16,416 INFO [STDOUT] at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:178)
2006-05-17 15:30:16,416 INFO [STDOUT] at org.jboss.web.tomcat.security.CustomPrincipalValve .invoke(CustomPrincipalValve.java:39)
2006-05-17 15:30:16,432 INFO [STDOUT] at org.jboss.web.tomcat.security.SecurityAssociationV alve.invoke(SecurityAssociationValve.java:159)
2006-05-17 15:30:16,448 INFO [STDOUT] at org.jboss.web.tomcat.security.JaccContextValve.inv oke(JaccContextValve.java:59)
2006-05-17 15:30:16,448 INFO [STDOUT] at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:126)
2006-05-17 15:30:16,463 INFO [STDOUT] at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:105)
2006-05-17 15:30:16,479 INFO [STDOUT] at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:107)
2006-05-17 15:30:16,479 INFO [STDOUT] at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:148)
2006-05-17 15:30:16,510 INFO [STDOUT] at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:856)
2006-05-17 15:30:16,510 INFO [STDOUT] at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.processConnection(Http11Protocol.jav a:744)
2006-05-17 15:30:16,541 INFO [STDOUT] at org.apache.tomcat.util.net.PoolTcpEndpoint.process Socket(PoolTcpEndpoint.java:527)
2006-05-17 15:30:16,557 INFO [STDOUT] at org.apache.tomcat.util.net.MasterSlaveWorkerThread .run(MasterSlaveWorkerThread.java:112)
2006-05-17 15:30:16,557 INFO [STDOUT] at java.lang.Thread.run(Thread.java:595)


And when I ran a debugger, I also found that this line giving me problem.



getHibernateTemplate().saveOrUpdate(refET);


Please help :confused:

manifoldronin
May 17th, 2006, 10:42 AM
Maybe it doesn't have to do with saveOrUpdate and just getHibernateTempate() is returning null - which would explain the stack trace as well. I remember someone asking here about getHibernateTemplate() always returning null, and it turned out to be some configuration issue, but I can't seem to find the exact messages now.

gigsvoo
May 17th, 2006, 11:10 AM
Ok, it happens that when I tried to connect to the implementation bean bypassing Spring. That is the real reason.

Now I moved web services implementation to EJB to avoid creating additional servlet that talks to bootloader's Spring application context.

Now it works perfectly.

Thanks anyway.