Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Hibernate insert and update problem

  • 16-09-2009 1:20pm
    #1
    Registered Users, Registered Users 2 Posts: 366 ✭✭


    I am having a problem with some hibernate code. I am calling the saveOrUpdate() method and every second time I try to do an update I get a NullPointerException. First time it works, second time it doesn't, third time it does. This is happening on updates. I am not refreshing the page, republishing the server, nothing. Here is my code. The exception is being thrown on the session.getTransaction().commit(); line.
    Session session = getSession();
    session.beginTransaction();
    session.saveOrUpdate(com);
    session.getTransaction().commit();
    

    I have tried to do session.flush() and session.close() after the commit but it doesn't help. This happens whether I use save(), update() or saveOrUpdate().

    Any help would be really appreciated.

    And here is the stack trace....
    16/09/09 12:14:06:817 BST] 00000027 ServletWrappe E   SRVE0068E: Uncaught exception thrown in one of the service methods of the servlet: JetspeedContainer. Exception thrown : java.lang.NullPointerException
    at oracle.jdbc.dbaccess.DBData.clearItem(DBData.java:431)
    at oracle.jdbc.dbaccess.DBDataSetImpl.clearItem(DBDataSetImpl.java:3528)
    at oracle.jdbc.driver.OraclePreparedStatement.clearParameters(OraclePreparedStatement.java:3401)
    at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.resetStatement(WSJdbcConnection.java:2369)
    at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.prepareStatement(WSJdbcConnection.java:2020)
    at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.prepareStatement(WSJdbcConnection.java:1972)
    at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:497)
    at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:94)
    at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:87)
    at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:218)
    at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2289)
    at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2242)
    at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2542)
    at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:92)
    at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
    at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
    at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
    at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
    at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
    at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
    at com.fmr.fc.portlet.communications.dao.impl.HibernateCommunicationsDAOImpl.createCommunication(HibernateCommunicationsDAOImpl.java:128)
    at com.fmr.fc.portlet.communications.CommunicationsAdminPortlet.processAction(CommunicationsAdminPortlet.java:168)
    at org.apache.jetspeed.factory.JetspeedPortletInstance.processAction(JetspeedPortletInstance.java:97)
    at org.apache.jetspeed.container.JetspeedContainerServlet.doGet(JetspeedContainerServlet.java:258)
    at org.apache.jetspeed.container.JetspeedContainerServlet.doPost(JetspeedContainerServlet.java:396)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:989)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:501)
    at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:464)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.include(WebAppRequestDispatcher.java:639)
    at org.apache.jetspeed.container.invoker.ServletPortletInvoker.invoke(ServletPortletInvoker.java:273)
    at org.apache.jetspeed.container.invoker.ServletPortletInvoker.action(ServletPortletInvoker.java:148)
    at org.apache.pluto.PortletContainerImpl.processPortletAction(PortletContainerImpl.java:164)
    at org.apache.jetspeed.container.JetspeedPortletContainerWrapper.processPortletAction(JetspeedPortletContainerWrapper.java:133)
    at org.apache.jetspeed.pipeline.valve.impl.ActionValveImpl.invoke(ActionValveImpl.java:148)
    at org.apache.jetspeed.pipeline.JetspeedPipeline$Invocation.invokeNext(JetspeedPipeline.java:167)
    at org.apache.jetspeed.container.ContainerValve.invoke(ContainerValve.java:109)
    at org.apache.jetspeed.pipeline.JetspeedPipeline$Invocation.invokeNext(JetspeedPipeline.java:167)
    at com.fmr.fcpf.util.PageHistoryValve.invoke(PageHistoryValve.java:161)
    at org.apache.jetspeed.pipeline.JetspeedPipeline$Invocation.invokeNext(JetspeedPipeline.java:167)
    at org.apache.jetspeed.profiler.impl.ProfilerValveImpl.invoke(ProfilerValveImpl.java:248)
    at org.apache.jetspeed.pipeline.JetspeedPipeline$Invocation.invokeNext(JetspeedPipeline.java:167)
    at org.apache.jetspeed.security.impl.LoginValidationValveImpl.invoke(LoginValidationValveImpl.java:159)
    at org.apache.jetspeed.pipeline.JetspeedPipeline$Invocation.invokeNext(JetspeedPipeline.java:167)
    at org.apache.jetspeed.localization.impl.LocalizationValveImpl.invoke(LocalizationValveImpl.java:170)
    at org.apache.jetspeed.pipeline.JetspeedPipeline$Invocation.invokeNext(JetspeedPipeline.java:167)
    at org.apache.jetspeed.security.impl.AbstractSecurityValve$1.run(AbstractSecurityValve.java:138)
    at java.security.AccessController.doPrivileged(AccessController.java:215)
    at javax.security.auth.Subject.doAsPrivileged(Subject.java:645)
    at org.apache.jetspeed.security.JSSubject.doAsPrivileged(JSSubject.java:179)
    at org.apache.jetspeed.security.impl.AbstractSecurityValve.invoke(AbstractSecurityValve.java:132)
    at org.apache.jetspeed.pipeline.JetspeedPipeline$Invocation.invokeNext(JetspeedPipeline.java:167)
    at org.apache.jetspeed.container.url.impl.PortalURLValveImpl.invoke(PortalURLValveImpl.java:67)
    at org.apache.jetspeed.pipeline.JetspeedPipeline$Invocation.invokeNext(JetspeedPipeline.java:167)
    at org.apache.jetspeed.capabilities.impl.CapabilityValveImpl.invoke(CapabilityValveImpl.java:126)
    at org.apache.jetspeed.pipeline.JetspeedPipeline$Invocation.invokeNext(JetspeedPipeline.java:167)
    at org.apache.jetspeed.pipeline.JetspeedPipeline.invoke(JetspeedPipeline.java:146)
    at org.apache.jetspeed.engine.JetspeedEngine.service(JetspeedEngine.java:222)
    at org.apache.jetspeed.engine.JetspeedServlet.doGet(JetspeedServlet.java:242)
    at org.apache.jetspeed.engine.JetspeedServlet.doPost(JetspeedServlet.java:269)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:989)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:930)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:145)
    at com.fmr.fc.common.authentication.ERLoginFilter.doFilter(ERLoginFilter.java:216)
    at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
    at com.fmr.fc.common.authentication.FCLoginFilter.doFilter(FCLoginFilter.java:279)
    at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
    at com.fmr.fc.common.authentication.CommonPortalFilter.doFilter(CommonPortalFilter.java:262)
    at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:87)
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:761)
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:673)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:498)
    at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:464)
    at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:90)
    at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:744)
    at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1439)
    at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:112)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:454)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:383)
    at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:102)
    at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
    at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
    at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
    at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
    at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:195)
    at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:743)
    at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:873)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1469)
    


Comments

  • Registered Users, Registered Users 2 Posts: 375 ✭✭unknownlegend


    Hi,
    unfortunately my only advice (not being familiar with the code) would be to Step through until you find where the pointer exception takes place.
    what are you committing to? an oracle table of some sort? check your records/fields definitions correspond to what you should expect as the exception seems to be on an update (maybe invalid data, bogus size...).
    good luck


  • Registered Users, Registered Users 2 Posts: 366 ✭✭Kaskade


    Thanks for the reply. Because it is happening every second time it is not data related.

    It looks like it is some sort of issue with the hibernate session or transaction and after the exception is thrown whatever issue that is there causes things to start from fresh and then it works the next time.

    Unfortunately the error is thrown inside the hibernate source and I do not have access to debug and step through this.


  • Registered Users, Registered Users 2 Posts: 11,989 ✭✭✭✭Giblet


    Does getSession open a new session each time? I know there is a session manager with spring for hibernate which can handle this, but I'm not sure of the pure Hibernate library.


  • Registered Users, Registered Users 2 Posts: 366 ✭✭Kaskade


    no it seems to get an instance of session.

    there is also a method in HibernateDAOSupport getHibernateTemplate.saveOrUpdate() and that does all the session and transaction stuff for you but it also has the same issue every second time an update/insert/delete is done.


  • Registered Users, Registered Users 2 Posts: 2,013 ✭✭✭lynchie


    What is the exact contents of the getSession() method?


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 2,800 ✭✭✭voxpop


    Are the updates cascading to associated tables i.e. cascade="save-update".

    Have you check your object to ensure nothing is null after the first update


  • Registered Users, Registered Users 2 Posts: 366 ✭✭Kaskade


    the getSesion() object is not my method, that is part of Spring framework.

    I have actually managed to somewhat fix the issue but setting the Statement Cache Size in the Websphere Datasourse config to 0 instead of 10. Not really sure what other implications this will have but at least its working for now.

    In terms of cascading the updates. That is not working for me and that is my next problem, its like you read my mind. I assumed calling save() would case the entire object and children to save but that isn't happening. Do you happen to have an example of what config I need to change to get this to work?


  • Registered Users, Registered Users 2 Posts: 2,800 ✭✭✭voxpop


    you just add it in your .hbm.xml files where relationships are . Its important that you have the relationships setup in the database also (ie foreign keys)


  • Registered Users, Registered Users 2 Posts: 366 ✭✭Kaskade


    database is setup correctly. insert works but update does not. I have cascade="all" in the .hbm.xml file but I must be doing something wrong in the way I am updating.


Advertisement