openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Sutter" <kwsut...@gmail.com>
Subject Re: JNDI lookup in OpenJPA.
Date Tue, 15 May 2007 15:38:06 GMT
Murali,
This is probably a question for the application server (jboss in your case)
rather than the jpa provider (openjpa).  The binding of an
EntityManagerFactory into jndi is an application server (ie. container)
process, not a jpa provider process.  (The same thing goes for your
datasource lookups).

Section 5.8.1 of the JPA spec outlines this requirement on the container:

5.8.1 Application-managed Persistence Contexts
When application-managed persistence contexts are used, the container must
instantiate the entity manager
factory and expose it to the application via JNDI.

I hope this information helps.

Kevin


On 5/15/07, Murali <murali.adiraju@emagia.com> wrote:
>
> Hi,
>
> I am new to OpenJPA technology.
>
> I am having problems while performing JNDI lookup for the bean resources
> to get the EntityManagerFactory instance.
>
> I am trying to perform JNDI lookup operation to fetch the DataSource &
> EntityManagerFactory instances to connect to the DataBase.
>
> Following is the code snippet:
>
> public static EntityManagerFactory  getOpenJPASessionFactory(String
> jndiSessionFactoryName)  throws DaoException {
>     EntityManagerFactory emFactory = null;
>     try {
>        Context ctx = new InitialContext();
>        emFactory = (EntityManagerFactory) ctx.lookup
> (jndiSessionFactoryName);
>     }catch (ClassCastException cce) {
>        throw new DaoException(DaoConstants.OPENJPA_FACTORY_ERROR, cce);
>     } catch (NamingException ne) {
>        throw new DaoException(DaoConstants.OPENJPA_FACTORY_ERROR, ne);
>     }
>     return emFactory;
> }
>
> When i try to get the EntityManager Instance from Factory instance, it
> says "jndiSessionFactoryName" is not bound, because of this i am not able to
> get the Datasource for performing the Database operations.
>
> Following are the environment details:
>
> Application Server: Jboss-4.0.4.GA
> Operating System with version: Redhat Linux 4, with kernel version
> 2.6.9.42 Elsmp
> OpenJPA version: 0.9.7
> JDK version: Jdk 1.5.0_07
> Database: IBM DB2  version 9.1
>
> Is there any interoperability issue of OpenJPA with Jboss-4.0.4.GA?
> Do we have to upgrade to any newer version of Jboss ?
>
> Please help me in this regard.
>
> Thanks in advance.
>
> Waiting for your response.
>
> Regards,
> Murali Krishna Adiraju.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message