Let me try this again from the beginning...

I want to have services (that start with the application, and runs the
length of the application lifetime) so I define a POJO with a @Service
and a method with a @PostConstruct. Everything is going well so far. I
define a persistenceunit in persistence.xml and corresponding jdbc
info in the (resin-)web.xml config. So my service looks like this:

public class InitDBService {

        protected EntityManager em;
        protected EntityManagerFactory emf;

        public void postConstruct() {
                log.log(Level.INFO, "emf=" + emf + " em=" + em);
                if (emptyDB()) insertDefaultData();

> emf=AmberEntityManagerFactory[amber] em=EntityManagerProxy[amber]

So I load up my webapp and away it goes. If I use amber (the native
JPA impl) everything looks fine and the entity manager, and factory is
injected as expected, and the data is queried (and inserted if empty).

Now, if I switch to a hibernate backed persistenceunit (hbm) I get
some kind of exception no matter how I do it.

> emf=null em=EntityManagerTransactionProxy[hbm,null]

I have tried using @TransactionAttributes, the UserTransaction object,
and various other attempts without any success on the hibernate

Now, later in my code, in a servlet, I have the same code and it runs
fine against the @PersistenceContext using the hibernate

I hope this makes a bit more sense and maybe someone can point me in
the right direction to get this working :)

Thanks in advance,

resin-interest mailing list

Reply via email to