Hi,
I have a private thread running inside an application scoped component that wakes up every
5 secs and does some housekeeping work. It needs access to an EntityManager.
The @In is unreliable the em is always null. So I tried this:
| EntityManagerFactory emf =
Persistence.createEntityManagerFactory("viewDatabase");
| EntityManager em = emf.createEntityManager();
|
but when I tried to use it nothing happened, I figured it wasn't being flushed
automatically as I know seam does a lot for you but when I manually tried to flush() it I
got complaints about not being in a transaction.
I then tried to get a transaction from em.getTransaction() but then I got:
| java.lang.IllegalStateException: JTA EntityManager cannot access a transactions
|
Makes sense from the reading of done on EJB just now, so then I thought I'll try
getting from JNDI as the reading I've done says the persistence context will be
associated with a transaction.
How does one do this? Is this indeed the right thinking (or indeed the right forum for
this or shall I post it in the EJB forum or JBoss forum?) Please advise.
Thanks
Troy
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4079879#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...