AS7 Quartz Async + Transactions: could not discover transaction status
lowecg2004 Jul 18, 2011 5:22 PMHello,
I have a transactional asynchronous Quartz task that has starting acting up since migrating to AS7. The application is WAR based and I'm using Seam 2.2.2.Final. The problem I'm having that every time an async process is fired, I see the error message could not discover transaction status
in the logs.
I've had a bit of a dig around and made comparisons with how things were working under AS6 and it looks like there has been a change with how AS7 handles resource requests from non-EE threads. In this case am I right in thinking that the Quartz workers would be non-EE threads
? I came to that conclusion after reading through this discussion:
http://lists.jboss.org/pipermail/jboss-as7-dev/2011-June/002290.html
The error message is produced from org.jboss.seam.contexts.Contexts.flushAndDestroyContexts() but the error originates from Transactional.getUserTransaction(). The following method is failing under AS7 but works under AS6:
protected javax.transaction.UserTransaction getUserTransaction() throws NamingException { InitialContext context = Naming.getInitialContext(); try { return (javax.transaction.UserTransaction) context.lookup("java:comp/UserTransaction"); } catch (NameNotFoundException nnfe) { try { //Embedded JBoss has no java:comp/UserTransaction javax.transaction.UserTransaction ut = (javax.transaction.UserTransaction) context.lookup("UserTransaction"); ut.getStatus(); //for glassfish, which can return an unusable UT return ut; } catch (Exception e) { throw nnfe; } } }
Under AS6 the first lookup fails, the NameNotFoundException exception handler is invoked and the next call to lookup succeeds.
Interestingly, the discussion I linked to above also suggests that the above scenario (i.e. accessing a global resource from a non-EE thread) is handled specially by AS6.
Under AS7 the first lookup fails but does not even generate a NameNotFoundException, it just generates a NamingException (which sort of sounds like JBSEAM-2025?). With that in mind, as a test I modified and built the source shipped with Seam to handle NamingException to force the lookup using the global UserTransaction resource name. Unfortunately that also failed.
Does anyone know of a workaround for this?
Cheers,
Chris.