Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » NullPointerException in DescriptorEventManager.notifyListener(NullPointerException in DescriptorEventManager.notifyListener)
NullPointerException in DescriptorEventManager.notifyListener [message #650698] Wed, 26 January 2011 02:17 Go to next message
Steffen Ewert is currently offline Steffen Ewert
Messages: 6
Registered: January 2011
Junior Member
Hi all,

I have add a "entitiy-listener" in the orm.xml like following:

<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings version="1.0" xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd">
  <persistence-unit-metadata>
    <persistence-unit-defaults>
      <entity-listeners>
        <entity-listener class="con.jpa.transactions.JPAListener" >
        </entity-listener>
      </entity-listeners>
    </persistence-unit-defaults>
  </persistence-unit-metadata>
</entity-mappings>


The listener class is very simple:

  /** This method will be called if a object was loaded from the database.
   * @param obj the loaded object
   */
  @SuppressWarnings("unused")
  @PostLoad
  private void onPostLoad(Object obj) {
    if (obj instanceof TransactionalObject) {
      ((TransactionalObject) obj).setTransactionalState(TransactionalState.PERSIST);
    }
  }

  /** This method does nothing.
   * @param obj ignored
   */
  @SuppressWarnings("unused")
  @PostPersist
  private void onPostPersist(Object obj) {
    if (obj instanceof TransactionalObject) {
      ((TransactionalObject) obj).setTransactionalState(TransactionalState.PERSIST);
    }
  }

  /** This method does nothing.
   * @param obj ignored
   */
  @SuppressWarnings("unused")
  @PreRemove
  private void onPreRemove(Object obj) {
    if (obj instanceof TransactionalObject) {
      ((TransactionalObject) obj).setTransactionalState(TransactionalState.REMOVED);
    }
  }


In the productive environment I get some times (1-2 times per month) the following NullPointerException:

java.lang.NullPointerException
        at org.eclipse.persistence.descriptors.DescriptorEventManager.notifyListener(DescriptorEventManager.java:662)
        at org.eclipse.persistence.descriptors.DescriptorEventManager.notifyListeners(DescriptorEventManager.java:701)
        at org.eclipse.persistence.descriptors.DescriptorEventManager.executeEvent(DescriptorEventManager.java:199)
        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.executeDeferredEvents(UnitOfWorkImpl.java:1846)
        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.cloneAndRegisterObject(UnitOfWorkImpl.java:1027)
        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.cloneAndRegisterObject(UnitOfWorkImpl.java:914)
        at org.eclipse.persistence.internal.sessions.UnitOfWorkIdentityMapAccessor.getAndCloneCacheKeyFromParent(UnitOfWorkIdentityMapAccessor.java:181)
        at org.eclipse.persistence.internal.sessions.UnitOfWorkIdentityMapAccessor.getFromIdentityMap(UnitOfWorkIdentityMapAccessor.java:120)
        at org.eclipse.persistence.internal.sessions.IdentityMapAccessor.getFromIdentityMap(IdentityMapAccessor.java:367)
        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.registerExistingObject(UnitOfWorkImpl.java:3939)
        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.registerExistingObject(UnitOfWorkImpl.java:3897)
        at org.eclipse.persistence.mappings.CollectionMapping.buildElementClone(CollectionMapping.java:243)
        at org.eclipse.persistence.internal.queries.ContainerPolicy.addNextValueFromIteratorInto(ContainerPolicy.java:209)
        at org.eclipse.persistence.mappings.CollectionMapping.buildCloneForPartObject(CollectionMapping.java:195)
        at org.eclipse.persistence.internal.indirection.UnitOfWorkQueryValueHolder.buildCloneFor(UnitOfWorkQueryValueHolder.java:51)
        at org.eclipse.persistence.internal.indirection.UnitOfWorkValueHolder.instantiateImpl(UnitOfWorkValueHolder.java:160)
        at org.eclipse.persistence.internal.indirection.UnitOfWorkValueHolder.instantiate(UnitOfWorkValueHolder.java:220)
        at org.eclipse.persistence.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:83)
        at org.eclipse.persistence.indirection.IndirectList.buildDelegate(IndirectList.java:237)
        at org.eclipse.persistence.indirection.IndirectList.getDelegate(IndirectList.java:398)
        at org.eclipse.persistence.indirection.IndirectList.toArray(IndirectList.java:741)
        at java.util.Vector.<init>(Vector.java:147)
...
... here starts the stack trace of my stuff
...


I use JPA with the latest EclipseLink Release (2.1.2). I had the same exception also with 2.1.0.

Has anybody the same error? Is anybody wrong? Or is it a bug?

Thanks and regards,
Steffen
Re: NullPointerException in DescriptorEventManager.notifyListener [message #651044 is a reply to message #650698] Thu, 27 January 2011 09:52 Go to previous messageGo to next message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Very odd. The error seems to indicate that you have a null in your eventListeners collection. Not sure how this could occur, once you get the error, do you get it all the time, or only once?

Are you doing something odd with events, adding/remove events on the fly? Are you accessing the persistence unit before it has been initialized?



James : Wiki : Book : Blog : Twitter
Re: NullPointerException in DescriptorEventManager.notifyListener [message #651169 is a reply to message #651044] Fri, 28 January 2011 02:11 Go to previous messageGo to next message
Steffen Ewert is currently offline Steffen Ewert
Messages: 6
Registered: January 2011
Junior Member
Hi James,

thanks for your reply.

The error comes only sometimes (very occasionally). After the error occurred all is running fine again (until the error occurred again after some weeks). That means also that eclipseLink is already initialised and works fine if the error occurred.

The only thing I do is register the listener inside the orm.xml (see my first post). I do not deregister the listener inside of my code. I have search the listener class inside of my project and I have found it only in the orm.xml and the listener's class file by self (and in some jar's).

That what I will try now is to catch and log all exceptions inside of listener methods. May be there is anything wrong (but I don't believe it). I'm also thinking to add some logs in the listener methods, but I must check if the performance is good enough, because the system is already productive and the error is so occasionally that I cannot reproduce it in the test environment ...

[Updated on: Fri, 28 January 2011 02:12]

Report message to a moderator

Re: NullPointerException in DescriptorEventManager.notifyListener [message #664481 is a reply to message #650698] Sat, 09 April 2011 09:25 Go to previous message
Steffen Ewert is currently offline Steffen Ewert
Messages: 6
Registered: January 2011
Junior Member
Hi,

the error occurred last week after two month again. My added catch blocks inside the of the methods of the EntityListener implementation class has catched no Exceptions or Errors Sad

Anybody has a other idea?

Thanks,
Steffen
Previous Topic:UnitOfWork.beginEarlyTransaction not having expected effect
Next Topic:EntityManager can't find entities with URLClassLoader
Goto Forum:
  


Current Time: Thu Apr 17 05:36:04 EDT 2014

Powered by FUDForum. Page generated in 0.03994 seconds