Quartz version 1.6 has introduced a runtime dependency on the javax.comp.UserTransaction class due to static class method UserTransactionHelper.setUserTxLocation(String) being invoked whenever StdSchedulerFactory instantiates a Scheduler. This change to StdSchedulerFactory.java was for
QUARTZ-339.
In a non-application server environment, trying to use Quartz leads to the following stacktrace: -
Exception in thread "main" java.lang.NoClassDefFoundError: javax/transaction/UserTransaction
at org.quartz.impl.StdSchedulerFactory.instantiate(StdSchedulerFactory.java:1104)
at org.quartz.impl.StdSchedulerFactory.getScheduler(StdSchedulerFactory.java:1355)
The workaround is to add jta.jar to the classpath; however avoiding use of the UserTransactionHelper class when JTA is not used would prevent this runtime dependency for non-JTA environments, as is the case with Quartz 1.5.x
Could StdSchedulerJobFactory.java line 1104 be amended as follows :-
old: -
UserTransactionHelper.setUserTxLocation(userTXLocation);
new: -
if (userTXLocation != null) {
UserTransactionHelper.setUserTxLocation(userTXLocation);
}
Otherwise the UserTransactionHelper class is intialized even if the property org.quartz.scheduler.wrapJobExecutionInUserTransaction is false.