On Feb 29, 2008, at 4:58 AM, Matt Johnston wrote: > I've downloaded the latest 3.1.5 and tried again with that version. > I am > still getting the same results. I have a quartz job that calls an > EJB3. > That bean will persist an object to the database. It looks like the > transaction is committing, but my data never makes it to the database.
Thanks Matt, I've filed this as http://bugs.caucho.com/view.php?id=2482 I'm fairly certain the issue is in the @PersistenceContext/ EntityManager. I don't think the EntityManager is getting registered properly with the transaction context. -- Scott > > > Here is the code for my bean: > @PersistenceContext(unitName="npguide") > private EntityManager em; > > @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) > public void grab(String url, Date date) { > log.info("starting grab"); > Report report = new Report(); > report.setDate(new Date()); > report.setSection("test section"); > report.setText("this is my test text"); > em.persist(report); > log.info("report: " + report.getId()+" " + report); > } > > The Resin log files show this. > > [06:55:52.307] {NPGuideJobsScheduler_Worker-1} > Transaction[01:b903dcdb] > begin > INFO (ReportGrabberBean.java:147) - starting grab > INFO (ReportGrabberBean.java:153) - report: null > [EMAIL PROTECTED] Feb 29 06:55:52 CST 2008] > [06:55:52.345] {NPGuideJobsScheduler_Worker-1} > Transaction[01:b903dcdb] > committing > > So it says the transaction is committing, but I don't see anything in > the database. > > > Matt > > Scott Ferguson wrote: >> 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 >>> [email protected] >>> http://maillist.caucho.com/mailman/listinfo/resin-interest >> >> >> >> _______________________________________________ >> resin-interest mailing list >> [email protected] >> http://maillist.caucho.com/mailman/listinfo/resin-interest >> >> > > > -- > > Matt Johnston > http://www.lattaoutdoors.com > http://www.gearapalooza.com > > > _______________________________________________ > resin-interest mailing list > [email protected] > http://maillist.caucho.com/mailman/listinfo/resin-interest _______________________________________________ resin-interest mailing list [email protected] http://maillist.caucho.com/mailman/listinfo/resin-interest
