openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Murali" <murali.adir...@emagia.com>
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 -->
   <openjpac>
     <fileset dir="${src-server.dir}/host">
       <include name="*.java" />
     </fileset>
   </openjpac>
 </target>

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

  [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(MetaDataRepository.java:1480)
  [openjpac] at org.apache.openjpa.meta.MetaDataRepository.endConfiguration(MetaDataRepository.java:1473)
  [openjpac] at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:450)
  [openjpac] at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:375)
  [openjpac] at org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:102)
  [openjpac] at org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:79)
  [openjpac] at org.apache.openjpa.conf.OpenJPAConfigurationImpl.newMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:831)
  [openjpac] at org.apache.openjpa.ant.PCEnhancerTask.executeOn(PCEnhancerTask.java:88)
  [openjpac] at org.apache.openjpa.lib.ant.AbstractTask.execute(AbstractTask.java:169)
  [openjpac] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
  [openjpac] at org.apache.tools.ant.Task.perform(Task.java:364)
  [openjpac] at org.apache.tools.ant.Target.execute(Target.java:341)
  [openjpac] at org.apache.tools.ant.Target.performTasks(Target.java:369)
  [openjpac] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
  [openjpac] at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
  [openjpac] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
  [openjpac] at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
  [openjpac] at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
  [openjpac] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
  [openjpac] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)

Please help us to resolve the above problem.

Thanks,
Murali & Praveen.



  ----- Original Message ----- 
  From: Murali 
  To: Patrick Linskey ; open-jpa-dev@incubator.apache.org 
  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 [com.receivables.server.dao.host.hibernate.HostGroupDAOImpl]
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 "com.receivables.server.dao.host.HostGroupDTO@1ca61ca6[id->2;
name->test1; description->test1memberHosts->0policies->0]" to PersistenceCapable
failed.  Ensure that it has been enhanced.
  FailedObject: com.receivables.server.dao.host.HostGroupDTO@1ca61ca6[id->2; name->test1;
description->test1memberHosts->0policies->0]
   at org.apache.openjpa.kernel.BrokerImpl.assertPersistenceCapable(BrokerImpl.java:4271)
   at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2373)
   at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2233)
   at org.apache.openjpa.kernel.DelegatingBroker.persist(DelegatingBroker.java:1010)
   at org.apache.openjpa.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:541)
   at com.receivables.server.dao.host.hibernate.HostGroupDAOImpl.create(HostGroupDAOImpl.java:113)
   at com.receivables.server.host.HostGroupManager.createHostGroup(HostGroupManager.java:87)
   at com.receivables.server.mgmt.ConsoleManagement.createHostGroup(ConsoleManagement.java:243)
   at com.receivables.server.mgmt.console.host.HostGroupAddAction.execute(HostGroupAddAction.java:92)
   at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
   at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
   at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
   at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at com.receivables.server.mgmt.console.access.AuthorizationFilter.doFilter(AuthorizationFilter.java:70)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
   at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
   at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
   at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
   at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
   at java.lang.Thread.run(Thread.java:803)
  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.

  Regards,
  Murali Krishna Adiraju.


  ----- Original Message ----- 
  From: "Patrick Linskey" <plinskey@gmail.com>
  To: <open-jpa-dev@incubator.apache.org>; "Murali" <murali.adiraju@emagia.com>
  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 <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.
  >>
  > 
  > 
  > -- 
  > Patrick Linskey
  > 202 669 5907
  > 
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message