openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Murali" <>
Subject Re: JNDI lookup in OpenJPA.
Date Thu, 17 May 2007 05:14:44 GMT
Hi Patrick Linskey,

We are using "Enhancing at Build Time" and modified our Build.xml and included the following
in Build.xml file

<target name="enhance">
   <!-- define the openjpac task; this can be done at the top of the    -->
   <!-- build.xml file, so it will be available for all targets      -->
   <taskdef name="openjpac" classpathref="dao.classpath" classname="org.apache.openjpa.ant.PCEnhancerTask"/>
   <!-- invoke enhancer on all .java files below the model directory -->
     <fileset dir="${src-server.dir}/host">
       <include name="*.java" />

and the following error is getting displayed. Persistence.xml file is available in the META-INF

  [openjpac] <0.9.7-incubating fatal user error> org.apache.openjpa.util.MetaDataException:
MetaDataFactory could not be configured (conf.newMetaDataFactoryInstance() returned null).
This might mean that no configuration properties were found. Ensure that you have a META-INF/persistence.xml
file, that it is available in your classpath, or that the properties file you are using for
configuration is available. If you are using Ant, please see the <properties> or <propertiesFile>
attributes of the task's nested <config> element. This can also occur if your OpenJPA
distribution jars are corrupt, or if your security policy is overly strict.
  [openjpac] at org.apache.openjpa.meta.MetaDataRepository.initializeMetaDataFactory(
  [openjpac] at org.apache.openjpa.meta.MetaDataRepository.endConfiguration(
  [openjpac] at org.apache.openjpa.lib.conf.Configurations.configureInstance(
  [openjpac] at org.apache.openjpa.lib.conf.Configurations.configureInstance(
  [openjpac] at org.apache.openjpa.lib.conf.PluginValue.instantiate(
  [openjpac] at org.apache.openjpa.lib.conf.ObjectValue.instantiate(
  [openjpac] at org.apache.openjpa.conf.OpenJPAConfigurationImpl.newMetaDataRepositoryInstance(
  [openjpac] at org.apache.openjpa.ant.PCEnhancerTask.executeOn(
  [openjpac] at org.apache.openjpa.lib.ant.AbstractTask.execute(
  [openjpac] at
  [openjpac] at
  [openjpac] at
  [openjpac] at
  [openjpac] at
  [openjpac] at
  [openjpac] at
  [openjpac] at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(
  [openjpac] at
  [openjpac] at
  [openjpac] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(

Please help us to resolve the above problem.

Murali & Praveen.

  ----- Original Message ----- 
  From: Murali 
  To: Patrick Linskey ; 
  Cc: Murali Adiraju ; Deven Kalra ; G.S.S. Prabhakar ; Praveen G ; Budigam Srinivas Rao 
  Sent: Thursday, May 17, 2007 8:59 AM
  Subject: Re: JNDI lookup in OpenJPA.

  Hi Patrick Linskey,

  We are not writing the OpenJPA code in EJB. Our Application is basically using Hibernate
code for persistence D/B operations. 
  Since, Hibernate is having LGPL licensing terms we are trying to replace Hibernate with
OpenJPA which is not having any Licensing issues.

  We are able to create EntityManagerFactory & EntityManager instances without going for
JNDI lookup operation.

  We used the following approach:

  EntityManagerFactory emFactory = Persistence.createEntityManagerFactory("puName",System.getProperties());
  EntityManager session = emFactory.createEntityManager();

  But we are facing problems while persisting the DTO object. Following the trace of the exception
that we have encountered:

  2007-05-16 22:05:39,796 ERROR []
The Security Server failed to persist data into the repository database. Refer to server.log
for details.
  <0.9.7-incubating nonfatal user error> org.apache.openjpa.persistence.ArgumentException:
Attempt to cast instance "[id->2;
name->test1; description->test1memberHosts->0policies->0]" to PersistenceCapable
failed.  Ensure that it has been enhanced.
  FailedObject:[id->2; name->test1;
   at org.apache.openjpa.kernel.BrokerImpl.assertPersistenceCapable(
   at org.apache.openjpa.kernel.BrokerImpl.persist(
   at org.apache.openjpa.kernel.BrokerImpl.persist(
   at org.apache.openjpa.kernel.DelegatingBroker.persist(
   at org.apache.openjpa.persistence.EntityManagerImpl.persist(
   at com.receivables.server.mgmt.ConsoleManagement.createHostGroup(
   at org.apache.struts.action.RequestProcessor.processActionPerform(
   at org.apache.struts.action.RequestProcessor.process(
   at org.apache.struts.action.ActionServlet.process(
   at org.apache.struts.action.ActionServlet.doPost(
   at javax.servlet.http.HttpServlet.service(
   at javax.servlet.http.HttpServlet.service(
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(
   at com.receivables.server.mgmt.console.access.AuthorizationFilter.doFilter(
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(
   at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(
   at org.apache.catalina.core.StandardWrapperValve.invoke(
   at org.apache.catalina.core.StandardContextValve.invoke(
   at org.apache.catalina.core.StandardHostValve.invoke(
   at org.apache.catalina.valves.ErrorReportValve.invoke(
   at org.apache.catalina.core.StandardEngineValve.invoke(
   at org.apache.catalina.connector.CoyoteAdapter.service(
   at org.apache.coyote.http11.Http11Processor.process(
   at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(
   at org.apache.tomcat.util.threads.ThreadPool$
  2007-05-16 22:22:38,672 INFO  [com.receivables.server.logger.LoggerUtil] Getting audit logger
from Logger Util

  We are trying to understand the meaning of "Enhancing the DTO object to Persistence capabilities"
as observed in the trace of the exception.

  Can you please help in this regard.

  Thanks in advance.

  Waiting for your response.

  Murali Krishna Adiraju.

  ----- Original Message ----- 
  From: "Patrick Linskey" <>
  To: <>; "Murali" <>
  Sent: Thursday, May 17, 2007 2:00 AM
  Subject: Re: JNDI lookup in OpenJPA.

  > Hi,
  > Are you writing this in an EJB, or some other artifact type?
  > -Patrick
  > On 5/14/07, Murali <> 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
  >> Following are the environment details:
  >> Application Server: Jboss-4.0.4.GA
  >> Operating System with version: Redhat Linux 4, with kernel version 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.
  > -- 
  > Patrick Linskey
  > 202 669 5907
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message