Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Eclipselink 2.0 + Entity Listeners + Container Managed Transactions

Jehanzeb,
    Hi, For this specific question on the NPE in EJBContext API calls in your entity listeners may I suggest that you post this question to the "WebLogic - EJB" forum on OTN at...
    http://forums.oracle.com/forums/forum.jspa?forumID=580

    For your 10.3.0 EJB platform
question, I am sorry I cannot help you with this without reverting from 10.3.2 to 10.3.0 and investigating further - much as I like to experiment, may get more technical coverage on the WebLogic OTN forum .

    thank you
    /michael

   
jz wrote:
Hi All,

Environment: Weblogic 10.3.0, Eclipselink 2.0, JPA 2.0, EJB 3.0, Container Managed JTA Transactions & EntityManager
Problem:
I am facing a difficulty in following situation. My entities have entity listeners (preupdate, prepersist etc), which get current EJBContext and call methods e.g. isCallerInRole() and getCallerPrincipal() etc. All entitymanager methods e.g. persist(), remove() and query() are working as expected. But problem comes in merge(), when transaction commits and entitymanager is synchronized to DB. In one of the entity listeners i get below mentioned error while trying to access EJBContext. Somehow at that point in EJBContext becomes invalid. Question is why? My understanding is that entity listeners are all called within JTA transaction, and at the time when listeners are executing EJBContext should be valid as it happens in persist(), remove() etc operations.


To drill down further i put a print statement in finally block of ejb method. This print statement should be executed after all entity listeners are executed. But its not the case.

My EJB method is simple:


@Override
public void update(BaseModel obj) {
try {
new BaseDAOImpl().update(obj);
} finally {
System.out.println("update"); // JPA entity listeners are executed after this finally block, why?
}
}

I get following error:

Caused by: java.lang.NullPointerException
        at weblogic.ejb.container.internal.EJBContextManager.getEJBContext(EJBContextManager.java:51)
        at weblogic.ejb.container.deployer.SessionContextProxyImpl.getDelegate(SessionContextProxyImpl.java:31)
        at weblogic.ejb.container.deployer.SessionContextProxyImpl.isCallerInRole(SessionContextProxyImpl.java:81)
        at com.warid.campaign.service.util.WeblogicContextImpl.isCallerInRole(WeblogicContextImpl.java:69)
        at com.warid.campaign.model.listeners.UserOwnershipValidationListener.validateUserOwnership(UserOwnershipValidationListener.java:16)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.eclipse.persistence.internal.security.PrivilegedAccessHelper.invokeMethod(PrivilegedAccessHelper.java:346)
        at org.eclipse.persistence.internal.jpa.metadata.listeners.EntityListener.invokeMethod(EntityListener.java:297)
        at org.eclipse.persistence.internal.jpa.metadata.listeners.EntityListener.invokeMethod(EntityListener.java:318)
        at org.eclipse.persistence.internal.jpa.metadata.listeners.EntityListener.preUpdateWithChanges(EntityListener.java:413)
        at org.eclipse.persistence.descriptors.DescriptorEventManager.notifyListener(DescriptorEventManager.java:676)
        at org.eclipse.persistence.descriptors.DescriptorEventManager.notifyEJB30Listeners(DescriptorEventManager.java:596)
        at org.eclipse.persistence.descriptors.DescriptorEventManager.executeEvent(DescriptorEventManager.java:200)
        at org.eclipse.persistence.internal.queries.DatabaseQueryMechanism.updateObjectForWriteWithChangeSet(DatabaseQueryMechanism.java:1078)
        at org.eclipse.persistence.queries.UpdateObjectQuery.executeCommitWithChangeSet(UpdateObjectQuery.java:84)
        at org.eclipse.persistence.internal.queries.DatabaseQueryMechanism.executeWriteWithChangeSet(DatabaseQueryMechanism.java:286)
        at org.eclipse.persistence.queries.WriteObjectQuery.executeDatabaseQuery(WriteObjectQuery.java:58)
        at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:675)
        at org.eclipse.persistence.queries.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:589)
        at org.eclipse.persistence.queries.ObjectLevelModifyQuery.executeInUnitOfWorkObjectLevelModifyQuery(ObjectLevelModifyQuery.java:109)
        at org.eclipse.persistence.queries.ObjectLevelModifyQuery.executeInUnitOfWork(ObjectLevelModifyQuery.java:86)
        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2857)
        at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1225)
        at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1207)
        at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1167)
        at org.eclipse.persistence.internal.sessions.CommitManager.commitChangedObjectsForClassWithChangeSet(CommitManager.java:233)
        at org.eclipse.persistence.internal.sessions.CommitManager.commitAllObjectsWithChangeSet(CommitManager.java:108)
        at org.eclipse.persistence.internal.sessions.AbstractSession.writeAllObjectsWithChangeSet(AbstractSession.java:3260)
        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabase(UnitOfWorkImpl.java:1403)
        at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitToDatabase(RepeatableWriteUnitOfWork.java:547)
        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithChangeSet(UnitOfWorkImpl.java:1508)
        at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.issueSQLbeforeCompletion(UnitOfWorkImpl.java:3128)
        at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.issueSQLbeforeCompletion(RepeatableWriteUnitOfWork.java:268)
        at org.eclipse.persistence.transaction.AbstractSynchronizationListener.beforeCompletion(AbstractSynchronizationListener.java:157)
        at org.eclipse.persistence.transaction.JTASynchronizationListener.beforeCompletion(JTASynchronizationListener.java:68)
        at weblogic.transaction.internal.ServerSCInfo.doBeforeCompletion(ServerSCInfo.java:1217)
        at weblogic.transaction.internal.ServerSCInfo.callBeforeCompletions(ServerSCInfo.java:1195)
        at weblogic.transaction.internal.ServerSCInfo.startPrePrepareAndChain(ServerSCInfo.java:118)
        at weblogic.transaction.internal.ServerTransactionImpl.localPrePrepareAndChain(ServerTransactionImpl.java:1302)
        at weblogic.transaction.internal.ServerTransactionImpl.globalPrePrepare(ServerTransactionImpl.java:2114)
        at weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransactionImpl.java:263)
        at weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImpl.java:230)
        at weblogic.ejb.container.internal.BaseLocalObject.postInvoke1(BaseLocalObject.java:591)
        ... 64 more

Thanks

Regards,
Jehanzeb Qayyum



_______________________________________________ eclipselink-users mailing list eclipselink-users@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top