Return-Path: Delivered-To: apmail-openjpa-users-archive@locus.apache.org Received: (qmail 86159 invoked from network); 12 Jul 2007 18:23:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Jul 2007 18:23:34 -0000 Received: (qmail 93675 invoked by uid 500); 12 Jul 2007 18:23:37 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 93662 invoked by uid 500); 12 Jul 2007 18:23:37 -0000 Mailing-List: contact users-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@openjpa.apache.org Delivered-To: mailing list users@openjpa.apache.org Received: (qmail 93653 invoked by uid 99); 12 Jul 2007 18:23:37 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Jul 2007 11:23:36 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Jul 2007 11:23:33 -0700 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1I93Jo-0004ZT-TN for users@openjpa.apache.org; Thu, 12 Jul 2007 11:23:12 -0700 Message-ID: <11565895.post@talk.nabble.com> Date: Thu, 12 Jul 2007 11:23:12 -0700 (PDT) From: Janap To: users@openjpa.apache.org Subject: Re: Runtime Enhancement in Eclipse In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: janapureddy@gmail.com References: <11503057.post@talk.nabble.com> <7262f25e0707090817m5472a34btc86535e1e8c207a6@mail.gmail.com> <11504139.post@talk.nabble.com> <7262f25e0707090840q3eaa3077j954b7ad7d81a0f8e@mail.gmail.com> <11504394.post@talk.nabble.com> <6C6A0915-9597-449B-B4E3-396703F4C391@SUN.com> <11537016.post@talk.nabble.com> <7262f25e0707111040l2d9272c4nb60e16de8eeabf0c@mail.gmail.com> <11548186.post@talk.nabble.com> <11564182.post@talk.nabble.com> X-Virus-Checked: Checked by ClamAV on apache.org HI Craig, Thank you for the tip. But its surprising that when I generate Entity classes using the JPA Eclipse Plugin(from Europa) the default type it assigns is BigDecimal. Changing for one class is no problem but when I generate classes for a complete database , it might require some refactoring I believe. Jan Craig L Russell wrote: > > Hi Janap, > > I'd recommend you stay far away from BigDecimal fields for primary > keys, even if your provider supports them. > > The BigDecimal class has a strange notion of equality that makes it > unsuitable for primary keys. That is, given BigDecimal instances A > and B, the following can be true: > > (0 == A .compareTo B) true > (A .equals B) false > > This means that using BigDecimal instances as keys in Maps is > impossible. Well, really hard. > > The JPA spec requires support for float and double types but strongly > discourages their use. BigDecimal isn't even required due to these > problems. > > Craig > > On Jul 12, 2007, at 9:56 AM, Janap wrote: > >> >> Whoa....Enhancement works finally. I gave up the javaagent,fiddled >> around >> with the Enhancer Task which all said the same thing ..... >> >> [openjpac] 141 INFO [main] openjpa.MetaData - Found 1 classes with >> metadata in 0 milliseconds. >> [openjpac] 141 INFO [main] openjpa.MetaData - The class >> "test.Scale" >> listed in the openjpa.MetaDataFactory configuration property could >> not be >> loaded; ignoring. >> >> i compiled it with the PCEnhancer java class. In Eclipse it is just >> a click >> away. >> >> One more observation - I now am using the JPA Eclipse Plugin to >> generate >> Entity classes and then enhance them. During this process, the >> enhancer once >> complained that I cannot use "BigDecimal" as primary key. >> The enhancement worked after I converted it to "long". Any ideas? >> >> >> >> >> >> Janap wrote: >>> >>> I have tried both the combinations Marc. I believe it might be a >>> problem >>> with my class. I have to post the source tomorrow since I dont >>> carry my >>> work to home :-) The classes are entity classes which I have reverse >>> engineered using the Hibernate Tools plugin for Eclipse. They are >>> EJB 3.0 >>> compatible and work fine with hibernate. >>> >>> I appreciate the help, >>> best wishes and good night >>> Jan >>> >>> >>> Patrick Linskey-2 wrote: >>>> >>>> Can you post the source to the Scale class? >>>> >>>> -Patrick >>>> >>>> On 7/11/07, Janap wrote: >>>>> >>>>> Thx for the info Craig...got that step working. Didnt have time for >>>>> research >>>>> for the past2 days,but now Im back with another problem. >>>>> >>>>> My web project structure is as follows.. >>>>> >>>>> /build/classes/test/Scale.class >>>>> >>>>> /src/test/Scale.java >>>>> >>>>> /web/WEB-INF/classes/META-INF/persistence.xml >>>>> /web/WEB-INF/classes/META-INF/orm.xml >>>>> >>>>> /web/WEB-INF/lib >>>>> >>>>> Following is my persistence.xml >>>>> >>>>> >>>> version="1.0"> >>>>> >>>> transaction-type="RESOURCE_LOCAL"> >>>>> >>>>> org.apache.openjpa.persistence.PersistenceProviderImpl >>>>> >>>>> orm.xml >>>>> test.Scale >>>>> >>>>> >>>>> >>>> value="oracle.jdbc.driver.OracleDriver"/> >>>>> >>>> value="myuser"/> >>>>> >>>> value="mypwd"/> >>>>> >>>> value="DefaultLevel=TRACE,Tool=TRACE"/> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> For runtime enhancement is start Tomcat within Eclipse with the >>>>> following VM >>>>> arguments : >>>>> >>>>> -javaagent:C:\Programme\Eclipse\workspace\JPAWebTest\web\WEB-INF >>>>> \lib\openjpa-all-0.9.6-incubating.jar=addDefaultConstructor=false >>>>> ,properties=C:\Programme\Eclipse\workspace\JPAWebTest\web\WEB-INF >>>>> \classes\META-INF\persistence.xml,-scanDevPath=true, >>>>> directory=C:\Programme\Eclipse\workspace\JPAWebTest\build >>>>> \classes,-tmpClassLoader=false >>>>> >>>>> >>>>> My Tomcat starts properly with the following log : >>>>> >>>>> 15 TRACE [main] openjpa.Runtime - Setting the following >>>>> properties >>>>> from >>>>> "file:/C:/Programme/Eclipse/workspace/JPAWebTest/web/WEB-INF/ >>>>> classes/META-INF/persistence.xml" >>>>> into configuration: {openjpa.ConnectionUserName=myuser, >>>>> openjpa.ConnectionPassword=mypwd, >>>>> openjpa.Log=DefaultLevel=TRACE,Tool=TRACE, >>>>> openjpa.MetaDataFactory=Resources=orm.xml, Types=test.Scale, >>>>> javax.persistence.provider=org.apache.openjpa.persistence.Persisten >>>>> ceProviderImpl, >>>>> openjpa.ConnectionURL=myurl, >>>>> openjpa.ConnectionDriverName=oracle.jdbc.driver.OracleDriver} >>>>> 186 INFO [main] openjpa.MetaData - Found 1 classes with >>>>> metadata in 0 >>>>> milliseconds. >>>>> >>>>> >>>>> Then as I try to run this servlet code : >>>>> >>>>> EntityManagerFactory emf = >>>>> Persistence.createEntityManagerFactory("myPersistence"); >>>>> >>>>> EntityManager em = emf.createEntityManager(); >>>>> em.getTransaction().begin(); >>>>> >>>>> Scale tab = new Scale(5); >>>>> em.persist(tab); >>>>> em.getTransaction().commit(); >>>>> em.close(); >>>>> emf.close(); >>>>> >>>>> I run into an exception which I believe because my class is not >>>>> somehow >>>>> enhanced : >>>>> >>>>> 62 TRACE [http-8090-Processor24] openjpa.MetaData - Using >>>>> metadata >>>>> factory >>>>> "org.apache.openjpa.persistence.jdbc.PersistenceMappingFactory@1b0b >>>>> dc8". >>>>> 93 INFO [http-8090-Processor24] openjpa.jdbc.JDBC - Using >>>>> dictionary >>>>> class "org.apache.openjpa.jdbc.sql.OracleDictionary". >>>>> 202 INFO [http-8090-Processor24] openjpa.MetaData - Found 1 >>>>> classes >>>>> with >>>>> metadata in 16 milliseconds. >>>>> 95452 TRACE [http-8090-Processor24] openjpa.Enhance - "test/ >>>>> Scale" >>>>> requires runtime enhancement: true >>>>> 95561 WARN [http-8090-Processor24] openjpa.Enhance - An >>>>> exception was >>>>> thrown while attempting to perform class file transformation on >>>>> "test/Scale": >>>>> java.lang.IllegalArgumentException: >>>>> java.lang.ClassNotFoundException: >>>>> test.Scale >>>>> at serp.util.Strings.toClass(Strings.java:211) >>>>> at serp.util.Strings.toClass(Strings.java:140) >>>>> at serp.bytecode.BCClass.getType(BCClass.java:565) >>>>> at >>>>> org.apache.openjpa.enhance.PCEnhancer.(PCEnhancer.java:187) >>>>> at >>>>> org.apache.openjpa.enhance.PCClassFileTransformer.transform >>>>> (PCClassFileTransformer.java:124) >>>>> at >>>>> sun.instrument.TransformerManager.transform >>>>> (TransformerManager.java:122) >>>>> at >>>>> sun.instrument.InstrumentationImpl.transform >>>>> (InstrumentationImpl.java:155) >>>>> at java.lang.ClassLoader.defineClass1(Native Method) >>>>> at java.lang.ClassLoader.defineClass(ClassLoader.java:620) >>>>> >>>>> >>>>> I tried out different combinations but was not >>>>> successful...probably >>>>> someone >>>>> could find the flaw.. >>>>> >>>>> best wishes >>>>> Jan >>>>> >>>>> >>>>> >>>>> Hi, >>>>> >>>>> This is from the Java SE 6 documentation. It explains "all": >>>>> Command-Line Interface >>>>> >>>>> On implementations with a command-line interface, an agent is >>>>> started >>>>> by adding this option to the command-line: >>>>> >>>>> -javaagent:jarpath[=options] >>>>> jarpath is the path to the agent JAR file. options is the agent >>>>> options. This switch may be used multiple times on the same >>>>> command- >>>>> line, thus creating multiple agents. More than one agent may use >>>>> the >>>>> same jarpath. An agent JAR file must conform to the JAR file >>>>> specification. >>>>> The manifest of the agent JAR file must contain the attribute >>>>> Premain- >>>>> Class. The value of this attribute is the name of the agent class. >>>>> The agent class must implement a public static premain method >>>>> similar >>>>> in principle to the main application entry point. After the Java >>>>> Virtual Machine (JVM) has initialized, each premain method will be >>>>> called in the order the agents were specified, then the real >>>>> application main method will be called. Each premain method must >>>>> return in order for the startup sequence to proceed. >>>>> The premain method has one of two possible signatures. The JVM >>>>> first >>>>> attempts to invoke the following method on the agent class: >>>>> public static void premain(String agentArgs, Instrumentation inst); >>>>> If the agent class does not implement this method then the JVM will >>>>> attempt to invoke: >>>>> >>>>> public static void premain(String agentArgs); >>>>> The agent class may also have an agentmain method for use when the >>>>> agent is started after VM startup. When the agent is started >>>>> using a >>>>> command-line option, the agentmain method is not invoked. >>>>> >>>>> The agent class will be loaded by the system class loader (see >>>>> ClassLoader.getSystemClassLoader). This is the class loader which >>>>> typically loads the class containing the application main >>>>> method. The >>>>> premain methods will be run under the same security and classloader >>>>> rules as the application main method. There are no modeling >>>>> restrictions on what the agent premain method may do. Anything >>>>> application main can do, including creating threads, is legal from >>>>> premain. >>>>> >>>>> Each agent is passed its agent options via the agentArgs parameter. >>>>> The agent options are passed as a single string, any additional >>>>> parsing should be performed by the agent itself. >>>>> >>>>> If the agent cannot be resolved (for example, because the agent >>>>> class >>>>> cannot be loaded, or because the agent class does not have an >>>>> appropriate premain method), the JVM will abort. If a premain >>>>> method >>>>> throws an uncaught exception, the JVM will abort. >>>>> >>>>> >>>>> >>>>> Craig >>>>> >>>>> >>>>> >>>>> -- >>>>> View this message in context: >>>>> http://www.nabble.com/Runtime-Enhancement-in-Eclipse- >>>>> tf4049770.html#a11537016 >>>>> Sent from the OpenJPA Users mailing list archive at Nabble.com. >>>>> >>>>> >>>> >>>> >>>> -- >>>> Patrick Linskey >>>> 202 669 5907 >>>> >>>> >>> >>> >> >> -- >> View this message in context: http://www.nabble.com/Runtime- >> Enhancement-in-Eclipse-tf4049770.html#a11564182 >> Sent from the OpenJPA Users mailing list archive at Nabble.com. >> > > Craig Russell > Architect, Sun Java Enterprise System http://java.sun.com/products/jdo > 408 276-5638 mailto:Craig.Russell@sun.com > P.S. A good JDO? O, Gasp! > > > > -- View this message in context: http://www.nabble.com/Runtime-Enhancement-in-Eclipse-tf4049770.html#a11565895 Sent from the OpenJPA Users mailing list archive at Nabble.com.