persistence@glassfish.java.net

Re: NullPointerException in persist() method

From: Thomas Ilsche <ThomasIlsche_at_gmx.de>
Date: Tue, 6 Nov 2007 22:56:54 +0100

Mariana,

sorry I did not know that. If I can not get my injection problem solved, I'll
post again on the list.

- Klaus

> Klaus,
>
> Changing from a resource injection to
> Persistence.createEntityManagerFactory means no JTA transactions, no
> persistence context propagation, and no LAZY loading (unless you do static
> weaving of your entities). So it's not an equal replacement.
>
> Also, if injection isn't working, GlassFish won't be able to pass Java EE
> compliance testing. So it's something with your setup that isn't quite
> right.
>
> Regards,
> -marina
>
> Klaus Unger wrote:
> > Hi,
> >
> > this is not a qualified response. I am also only a new user to
> > glassfish/toplink. Resource injection usually doesn't work for me in
> > toplink aswell.
> >
> > You might want to use:
> >
> > EntityManagerFactory emf =
> > Persistence.createEntityManagerFactory("persistenceunit-name");
> > em = emf.createEntityManager();
> >
> > - Klaus
> >
> > On Tuesday 06 November 2007 21:47:41 edu53 wrote:
> >>Hi,
> >>I'm new using JPA (GlassFish V2 Server, TopLinks, NetBeans IDE) and have
> >>the following problem:
> >>In a managed bean that uses resource injection, i.e
> >>
> >>@PersistentContext
> >>private EntityManager em;
> >>
> >>When calling em.persist(entity) always get a
> >>java.lang.NullPointerException, no matter what entity trying to persist.
> >>I'm not sure if resource injection is working.
> >>
> >>
> >>Somebody can help ?
> >>Thanks in advance