| NullPointerException in DescriptorEventManager.notifyListener [message #650698] |
Wed, 26 January 2011 02:17  |
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 #651169 is a reply to message #651044] |
Fri, 28 January 2011 02:11   |
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.01616 seconds