Author: rmannibucau
Date: Sat Oct  4 17:53:09 2014
New Revision: 1629431

URL: http://svn.apache.org/r1629431
Log:
TOMEE-1379 ensure to commit with app loader

Modified:
    
tomee/tomee/branches/tomee-1.7.x/container/openejb-core/src/main/java/org/apache/openejb/core/timer/EjbTimerServiceImpl.java

Modified: 
tomee/tomee/branches/tomee-1.7.x/container/openejb-core/src/main/java/org/apache/openejb/core/timer/EjbTimerServiceImpl.java
URL: 
http://svn.apache.org/viewvc/tomee/tomee/branches/tomee-1.7.x/container/openejb-core/src/main/java/org/apache/openejb/core/timer/EjbTimerServiceImpl.java?rev=1629431&r1=1629430&r2=1629431&view=diff
==============================================================================
--- 
tomee/tomee/branches/tomee-1.7.x/container/openejb-core/src/main/java/org/apache/openejb/core/timer/EjbTimerServiceImpl.java
 (original)
+++ 
tomee/tomee/branches/tomee-1.7.x/container/openejb-core/src/main/java/org/apache/openejb/core/timer/EjbTimerServiceImpl.java
 Sat Oct  4 17:53:09 2014
@@ -758,6 +758,8 @@ public class EjbTimerServiceImpl impleme
      */
     @SuppressWarnings("ReturnInsideFinallyBlock")
     public void ejbTimeout(final TimerData timerData) {
+        final Thread thread = Thread.currentThread();
+        final ClassLoader loader = thread.getContextClassLoader(); // 
container loader
         try {
             Timer timer = getTimer(timerData.getId());
             // quartz can be backed by some advanced config (jdbc for instance)
@@ -793,6 +795,10 @@ public class EjbTimerServiceImpl impleme
                         return;
                     }
 
+                    // if app registered Synchronization we need it for 
commit()/rollback()
+                    // so forcing it and not relying on container for it
+                    thread.setContextClassLoader(deployment.getClassLoader() 
!= null ? deployment.getClassLoader() : loader);
+
                     SetAccessible.on(ejbTimeout);
                     container.invoke(deployment.getDeploymentID(),
                         InterfaceType.TIMEOUT,
@@ -849,6 +855,8 @@ public class EjbTimerServiceImpl impleme
             log.warning("Error occured while calling ejbTimeout", e);
             throw e;
         } finally {
+            thread.setContextClassLoader(loader);
+
             // clean up the timer store
             //TODO shall we do all this via Quartz listener ???
             if (timerData.getType() == TimerType.SingleAction) {


Reply via email to