2 Replies Latest reply on Nov 12, 2008 4:05 AM by Amin Mohammed-Coleman

    Nullpointer Exception on org.jboss.envers.event.VersionsEven

    Amin Mohammed-Coleman Newbie

      Hi

      I am getting the following snippet of exception:


      java.lang.NullPointerException
       at org.jboss.envers.event.VersionsEventListener.onPreRemoveCollection(VersionsEventListener.java:183)
       at org.hibernate.action.CollectionRemoveAction.preRemove(CollectionRemoveAction.java:115)
       at org.hibernate.action.CollectionRemoveAction.execute(CollectionRemoveAction.java:81)
       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)
      
      


      I have added the following event listeners in my session factory:

       <property name="eventListeners">
       <map>
       <entry key="post-insert" value-ref="enversEventListener"/>
       <entry key="post-update" value-ref="enversEventListener"/>
       <entry key="post-delete" value-ref="enversEventListener"/>
       <entry key="post-collection-recreate" value-ref="enversEventListener"/>
       <entry key="pre-collection-remove" value-ref="enversEventListener"/>
       <entry key="pre-collection-update" value-ref="enversEventListener"/>
      
       </map>
      


      My test case basically creates a contact object with a set of addresses, phone numbers and notes. I perform the following operation for the exception to arise:

      PersonalContact pc = (PersonalContact) ContactFactory.getInstance().createContact(ContactType.personalcontact);
       Contact personalContactCreated = contactApplicationService.createContact(pc);
      
       ((PersonalContact)personalContactCreated).setFirstname("CHANGED NAME");
       contactApplicationService.updateContact(personalContactCreated);
       List<? extends Contact> history = contactApplicationService.showHistory(personalContactCreated.getId(), true);
       System.out.println(history);
       assertNotNull(history);
       assertEquals(2, history.size());
      


      I have implemented the @Versioned according to the documentation online. Any help would be appreciated.