SourceForge.net Logo
Main Overview Wiki Issues Forum Build Fisheye
Issue Details (XML | Word | Printable)

Key: CMP-764
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Blocker Blocker
Assignee: Shay Banon
Reporter: Adam Lane
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Compass

Saving object getting NPE in processCollectionEvent of HibernateCollectionEventListener

Created: 31/Oct/08 02:54 PM   Updated: 31/Oct/08 06:33 PM
Component/s: Compass::Gps
Affects Version/s: 2.1.0 RC
Fix Version/s: 2.1.0 GA

Environment: Linux, no mirroring, using spring, mysql. Can provide anything specific that would help.


 Description  « Hide
When we upgraded from 2.1 M4 to the RC version, we started getting NPE when saving some of our objects that we are not indexing.
I set it to blocker status because of this exception because it is blocking our use of the current RC version.

Objects we are indexing seem to be working great so I am not sure why this is suddenly happening in this object. I see in Fisheye that the code changes we are failing in are new for the RC version.

The error seems to be because of collectionEntry is coming back null on this line of HibernateCollectionEventListener:
if (collectionEntry.getLoadedPersister() == null)

I believe the fix is to first check for collectionEntry being null and return in that case too:
if ((collectionEntry == null) || (collectionEntry.getLoadedPersister() == null)) {

Thanks for your time and help on this!

Here is the full segment:

private void processCollectionEvent(final AbstractCollectionEvent event) {
final Object entity = event.getAffectedOwnerOrNull();
if (entity == null) { //Hibernate cannot determine every single time the owner especially incase detached objects are involved // or property-ref is used //Should log really but we don't know if we're interested in this collection for indexing return; }

CollectionEntry collectionEntry = event.getSession().getPersistenceContext().getCollectionEntry(event.getCollection());
if (collectionEntry.getLoadedPersister() == null) { // ignore this entry, since Hibernate will cause NPE when doing SAVE // TODO is there a better way to solve this? return; }



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Adam Lane added a comment - 31/Oct/08 03:05 PM
Adding in the stack in case it helps at all:

java.lang.NullPointerException
at org.compass.gps.device.hibernate.lifecycle.HibernateCollectionEventListener.processCollectionEvent(HibernateCollectionEventListener.java:70)
at org.compass.gps.device.hibernate.lifecycle.HibernateCollectionEventListener.onPostRemoveCollection(HibernateCollectionEventListener.java:53)
at org.hibernate.action.CollectionRemoveAction.postRemove(CollectionRemoveAction.java:127)
at org.hibernate.action.CollectionRemoveAction.execute(CollectionRemoveAction.java:100)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:169)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
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 org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:655)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:709)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:678)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:321)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:116)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy56.addReport(Unknown Source)
at estalea.reporting.report.controller.ReportWizardController.processFinish(ReportWizardController.java:952)
at org.springframework.web.servlet.mvc.AbstractWizardFormController.validatePagesAndFinish(AbstractWizardFormController.java:642)
at org.springframework.web.servlet.mvc.AbstractWizardFormController.processFormSubmission(AbstractWizardFormController.java:492)
at org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:265)
at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:165)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:103)
at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:103)
at com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:118)
at com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:52)
at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:87)
at estalea.savings.seo.SavingsFrameworkFilter.doFilter(SavingsFrameworkFilter.java:154)
at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:87)
at estalea.base.threadcontext.ThreadContextFilter.doFilterInternal(ThreadContextFilter.java:48)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:87)
at estalea.accountmanagement.user.filter.AbstractSessionFilter.doFilterInternal(AbstractSessionFilter.java:44)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:87)
at estalea.accountmanagement.user.filter.AbstractSessionFilter.doFilterInternal(AbstractSessionFilter.java:44)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:236)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:87)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:359)
at org.springframework.security.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
at org.springframework.security.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
at org.springframework.security.ui.ExceptionTranslationFilter.doFilterHttp(ExceptionTranslationFilter.java:101)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
at estalea.accountmanagement.security.authentication.DeactivateableRememberMeProcessingFilter.doFilterHttp(DeactivateableRememberMeProcessingFilter.java:39)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
at org.springframework.security.ui.AbstractProcessingFilter.doFilterHttp(AbstractProcessingFilter.java:268)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
at org.springframework.security.context.HttpSessionContextIntegrationFilter.doFilterHttp(HttpSessionContextIntegrationFilter.java:235)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
at org.springframework.security.util.FilterChainProxy.doFilter(FilterChainProxy.java:174)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:236)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:87)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:87)
at estalea.management.controller.ManagementFilter.doFilter(ManagementFilter.java:217)
at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:87)
at com.caucho.filters.GzipFilter.doFilter(GzipFilter.java:208)
at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:87)
at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:181)
at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:266)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:268)
at com.caucho.server.port.TcpConnection.run(TcpConnection.java:602)
at com.caucho.util.ThreadPool$Item.runTasks(ThreadPool.java:690)
at com.caucho.util.ThreadPool$Item.run(ThreadPool.java:612)
at java.lang.Thread.run(Thread.java:613)


Shay Banon added a comment - 31/Oct/08 06:03 PM
You are absolutely right. I fixed it, but took the && path instead of the || path. Here is what I added:

CollectionEntry collectionEntry = event.getSession().getPersistenceContext().getCollectionEntry(event.getCollection());
if (collectionEntry != null && collectionEntry.getLoadedPersister() == null) { // ignore this entry, since Hibernate will cause NPE when doing SAVE // TODO is there a better way to solve this? return; }

The collection event in Hibernate is not the best implementation out there, so I try to do as best as possible. The good news is that Hibernate Search uses the same event listener, so hopefully it will be fixed... .


Adam Lane added a comment - 31/Oct/08 06:33 PM
I am sure this not the right place for this but I am very impressed by the turnaround. I have watched several issues that impact me opened and fixed on the same day.
I can't thank you enough for your time and the great product.