persistence@glassfish.java.net

Re: out of container JPA + EJB 3.0 + JNDI testing

From: Craig L Russell <Craig.Russell_at_SUN.com>
Date: Tue, 01 May 2007 23:20:59 -0700

Hi Sud,

Generally, when running outside a container, you don't have access to
resources normally managed by the container and made available via
JNDI lookup.

For datasources, this means that you need to define the JDBC
properties and connection pooling properties directly to your jpa
provider. The documentation shows which properties you need to set in
the persistence.xml or in the properties map you pass to the EMF
Persistence.createEntityManagerFactory method.

Craig

On May 1, 2007, at 3:51 PM, sud wrote:

> I have a EJB 3.0 application that uses JPA and exposes CRUD
> operations to a database. The jta-data-source in persistence.xml
> refers to a JDBC resource defined in JNDI.
>
> I'd like to use TestNG to run unit tests for this application. I
> believe I need to setup out of container tests. Since the EJBs are
> POJOs I can easily run test cases for them. But I don't know how to
> setup and access the JDBC resource defined in JNDI from out-side
> the container. I would appreciate any pointers.
>
> Thanks
> -sud
>
> Ahhh...imagining that irresistible "new car" smell?
> Check out new cars at Yahoo! Autos.

Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell_at_sun.com
P.S. A good JDO? O, Gasp!