Hello, > We are trying to understand the meaning of "Enhancing the DTO object to Persistence capabilities" as observed in the trace of the exception. OpenJPA needs to "enhance" the Java classes to be stored in a database. Enhancement means modification of original Java class bytecode with special instructions. The classes can be enhanced in following ways:
1. Build-time: After the Java class has been compiled, run $ java org.apache.openjpa.enhance.PCEnhancer -properties <path to persistence.xml> The enhancer program supports several other options (refer http://incubator.apache.org/openjpa/docs/latest/manual/manual.html#ref_g uide_pc_enhance) This will overwrite the bytecodes of the Java classes (you can simply notice them by growing size of *.class files or disassemble through javap or jad to see what code/methods have been added to the original). The same enhancer can be invoked through an Ant task to integrate the enhancement step in build/package/deploy process. 2. Runtime: Invoke Java runtime of your OpenJPA application with -javaagent as follows $ java -agent /path/to/openjpa.jar com.acme.MyOpenJPAApplication -javaagent works only with Java 1.5 or later. Also recommended that you enumerate all the persistent Java classes in <class> in persistence.xml e.g. <persisetnce-unit name="..."> <class>com.acme.MyPOJO1</class> <class>com.acme.MyPOJO2</class> ...... </persietnec-unit> Pinaki Poddar _______________________________________________________________________ Notice: This email message, together with any attachments, may contain information of BEA Systems, Inc., its subsidiaries and affiliated entities, that may be confidential, proprietary, copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it. -----Original Message----- From: Murali [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 16, 2007 10:30 PM To: Patrick Linskey; open-jpa-dev@incubator.apache.org Cc: Murali Adiraju; Deven Kalra; G.S.S. Prabhakar; Praveen G; Budigam Srinivas Rao 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 "[EMAIL PROTECTED]>2; name->test1; description->test1memberHosts->0policies->0]" to PersistenceCapable failed. Ensure that it has been enhanced. FailedObject: [EMAIL PROTECTED]>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(EntityManagerIm pl.java:541) at com.receivables.server.dao.host.hibernate.HostGroupDAOImpl.create(HostGr oupDAOImpl.java:113) at com.receivables.server.host.HostGroupManager.createHostGroup(HostGroupMa nager.java:87) at com.receivables.server.mgmt.ConsoleManagement.createHostGroup(ConsoleMan agement.java:243) at com.receivables.server.mgmt.console.host.HostGroupAddAction.execute(Host GroupAddAction.java:92) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestPr ocessor.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(Applica tionFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt erChain.java:173) at com.receivables.server.mgmt.console.access.AuthorizationFilter.doFilter( AuthorizationFilter.java:70) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica tionFilterChain.java:202) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt erChain.java:173) at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilte r.java:96) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica tionFilterChain.java:202) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt erChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv e.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValv e.java:178) at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAs sociationValve.java:175) at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.j ava: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:1 48) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:86 9) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.proc essConnection(Http11BaseProtocol.java:664) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint .java:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollow erWorkerThread.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" <[EMAIL PROTECTED]> To: <open-jpa-dev@incubator.apache.org>; "Murali" <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> 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 > Notice: This email message, together with any attachments, may contain information of BEA Systems, Inc., its subsidiaries and affiliated entities, that may be confidential, proprietary, copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it.