users@glassfish.java.net

Re: EnitiyManager won't inject

From: Garth Keesler <garthk_at_gdcjk.com>
Date: Mon, 14 Jan 2008 09:55:03 -0600

Garth Keesler wrote:
> Garth Keesler wrote:
>> I am new to Glassfish/NetBeans having switched from being new to
>> Geronimo/Eclipse. So far I much prefer this combo. However, I have
>> been working thru various code samples and using O'Reilly's EJB 3.0
>> book on two different platforms: Ubuntu 7.10/Postgres and XP/SQL
>> Server with the same result. No EntityManager ever gets injected in
>> the session bean that attempts to manipulate the persisted entity
>> bean. I have tested both jdbc connections is simple SE programs so I
>> know the connections are valid. Also, I generate the entity beans
>> from the schema so that also verifies the connection (I think).
>>
> ....
>
> A bit more info. The following line in the local session bean causes a
> null exception. When I put a bit of diagnostic code in front of this
> line, em is always null.
>
> return em.find(OESPkg.Vendors.class, id);
>
> I'm not sure what to change to cause the EntityManager to inject (I
> thought it was automagic) so any pointers would be greatly appreciated.
>
> Thanx,
> Garth
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>
> .
>
Sorry to keep replying to myself but...

This may have more to do with the way I run the test than any error in
the code. I do a Clean and Build and the an Undeploy and Deploy and then
just right-click on the JUnit test bean and tell it to run. Maybe my
real question ought to be:

How do I run a JUnit test in the Glassfish environment?

Thanx,
Garth