On Feb 21, 2008, at 7:18 PM, majohnst wrote:

>
> I am trying to create a Quartz job that saves some data to my  
> database. The
> quartz process is working correctly and my jobs runs, I can just  
> never get
> the data committed to my database.
>
> In my job, I call an EJB3 that accesses my EntityManager.  The  
> method in my
> EJB is marked with  
> @TransactionAttribute(TransactionAttributeType.REQUIRED)
> and I can access the UserTransaction by injecting it into my bean by  
> @In
> protected UserTransaction ut;

If you turn on level="fine" or "finer" logging, you'll see when  
transactions are started and completed.

> When I call my method, the UserTransaction says that it is active. I  
> then
> persist my object to the EntityManager. When the quartz job is done,  
> the new
> data was never committed to the database. So I tried to manually  
> commit the
> usertransaction at the end of my method by using ut.commit(), but  
> then I get
> an error:
> "Can't commit outside of a transaction.  Either the  
> UserTransaction.begin()
> is missing or the transaction has already been committed or rolled  
> back."

The logging message would show whether the issue is the transactions  
not begin/committing(), or if the EntityManager is failing to register  
with the transaction (or commit or similar).

>
> So how can I manage transactions in an EJB3 outside of a webpage  
> request?

There's no difference between a webpage request and something like a  
quartz job with the exception of the context classloader.  The  
transactions should be starting the same in both cases.

-- Scott

>
> -- 
> View this message in context: 
> http://www.nabble.com/Transactions-and-Quartz-tp15626725p15626725.html
> Sent from the Resin mailing list archive at Nabble.com.
>
>
>
> _______________________________________________
> resin-interest mailing list
> resin-interest@caucho.com
> http://maillist.caucho.com/mailman/listinfo/resin-interest



_______________________________________________
resin-interest mailing list
resin-interest@caucho.com
http://maillist.caucho.com/mailman/listinfo/resin-interest

Reply via email to