On Mar 31, 2009, at 12:51 PM, Scott Hernandez wrote:

> 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:

I've added a bug report for this at http://bugs.caucho.com/view.php?id=3429

I didn't quite understand the situation.  The environment might not be  
properly setup at the @PostConstruct time for some reason.

-- Scott

>
>
> @Service
> public class InitDBService {
>
>       @PersistenceContext
>       protected EntityManager em;
>       
>       @PersistenceUnit
>       protected EntityManagerFactory emf;
>
>       @PostConstruct
>       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
> persistenceunit.
>
> Now, later in my code, in a servlet, I have the same code and it runs
> fine against the @PersistenceContext using the hibernate
> persistenceunit.
>
> 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,
> Scott
>
>
> _______________________________________________
> 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