persistence@glassfish.java.net

Re: NullPointerException in persist() method

From: Klaus Unger <UngerKlaus_at_gmx.de>
Date: Tue, 6 Nov 2007 21:57:54 +0100

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