This is my sole technique of enhancement - at build-time using the openjpa-maven-plugin. Like I said in another posting I may have have a compilation conflict between Maven and Eclipse.

Thanks,

Chris

On 9/28/2013 8:32 AM, Mark Struberg wrote:
If you like to use build time enhancement and use Apache Maven, then I suggest 
to use the openjpa-maven-plugin.

You can find a sample usage of it here:

https://github.com/struberg/lightweightEE/blob/master/backend-api/pom.xml

I've also written a small blog post about how the different JPA strageties and 
enhancement work and some of the pros and cons of each approach [1]. I must 
admit that the deploy time enhancement got better in the meantime, but I still 
prefer build-time enhancement as it gives me consistent behaviour even in my 
tests (which you can use liberty or Apache TomEE for with either Arquillian or 
DeltaSpike CdiCtrl [2])

LieGrue,
strub


[1] http://struberg.wordpress.com/2012/01/08/jpa-enhancement-done-right/
[2] 
http://struberg.wordpress.com/2012/03/27/unit-testing-strategies-for-cdi-based-projects/



----- Original Message -----
From: Leonardo K. Shikida <shik...@gmail.com>
To: users@openjpa.apache.org
Cc: d...@openjpa.apache.org
Sent: Wednesday, 25 September 2013, 17:38
Subject: Re: Entitiy not enhanced

Hi

I could not make the runtime enhancement work for me too, so I am manually
enhancing during build time with a simple script.

     public static void main(String[] args) {

         Collection<File> files = FileUtils.listFiles(new
File(baseClassDir), null, true);
         for(File file:files){
             String[] a = new String[3];
             a[0] = "-d";
             a[1] = baseClassDir;
             a[2] = file.getAbsolutePath();
             org.apache.openjpa.enhance.PCEnhancer.main(a);
         }
     }

I've also noticed some strange behaviour using java 7, specifically, both
IBM and Oracle JVM 7 didn't enhance the source code, but only Oracle
crashed my tomEE+ server when that happened ;-)

Just in case...

good luck

Leo


[]

Leo


On Wed, Sep 25, 2013 at 12:15 PM, Divya K Konoor
<dikon...@in.ibm.com>wrote:



  Hi,

  I tried by manually adding the java agent in my jvm options  -javaagent:/
  apache-openjpa-2.2.2/lib/openjpa-all-2.2.2.jar following examples 5.2 and
  5.3 under section 2.3 at


http://openjpa.apache.org/builds/2.1.1/apache-openjpa/docs/ref_guide_pc_enhance.html#ref_guide_pc_enhance_build
  .

   But even that hasn't helped .I still get the entity not enhanced
problem.

  Regards
  Divya



  From:   Divya K Konoor/India/IBM
  To:    users-h...@openjpa.apache.org, dev-h...@openjpa.apache.org,
  Date:   09/25/2013 07:19 PM
  Subject:        Entitiy not enhanced


  Hi,

  I use a container (Webshphere liberty that internally uses openjpa). I have
  multiple OSGi persistence bundles .Each has its own persistence unit ; all
  of these talk to the same database.The JPA entities bundled within each
  persistence bundle is defined under the <class></class> tag of
the
  persistence.xml. Some of these entities have relationship or dependency on
  the entities bundled with another persistence bundle in which case the
  dependent entities are added in the <class> tag of the former's
  persistence.xml

  I see the following error message when I start my liberty server:

  This configuration disallows runtime optimization, but the following listed
  types were not enhanced at build time or at class load time with a
  javaagent: "

  [err] <openjpa-2.2.1.1-SNAPSHOT-r422266:1431746 fatal user error>
  org.apache.openjpa.persistence.ArgumentException: The type "class
  com.xxx.ProbeConfiguration" has not been enhanced.
  [err]   at org.apache.openjpa.meta.ClassMetaData.resolveMeta
  (ClassMetaData.java:1827)
  [err]   at org.apache.openjpa.meta.ClassMetaData.resolve
  (ClassMetaData.java:1801)
  [err]   at org.apache.openjpa.meta.MetaDataRepository.processBuffer
  (MetaDataRepository.java:826)
  [err]   at org.apache.openjpa.meta.MetaDataRepository.resolveMeta
  (MetaDataRepository.java:723)
  [err]   at org.apache.openjpa.meta.MetaDataRepository.resolve
  (MetaDataRepository.java:647)
  [err]   at
  org.apache.openjpa.meta.MetaDataRepository.getMetaDataInternal
  (MetaDataRepository.java:415)
  [err]   at org.apache.openjpa.meta.MetaDataRepository.getMetaData
  (MetaDataRepository.java:388)
  [err]   at org.apache.openjpa.meta.MetaDataRepository.resolveAll
  (MetaDataRepository.java:1990)
  [err]   at
  org.apache.openjpa.meta.MetaDataRepository.getQueryMetaDataInternal
  (MetaDataRepository.java:1968)
  [err]   at org.apache.openjpa.meta.MetaDataRepository.getQueryMetaData
  (MetaDataRepository.java:1955)
  [err]   at
  org.apache.openjpa.persistence.EntityManagerImpl.createNamedQuery
  (EntityManagerImpl.java:102

  There is a brief mention of this here (but it doesn't explain why):



http://pic.dhe.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=%2Fcom.ibm.websphere.ejbfep.multiplatform.doc%2Finfo%2Fae%2Fae%2Ftejb_jpatroubleshoot.html

  I was under the impression that openjpa does runtime enhancement on all JPA
  entities that have not been enhanced. The above log statement seems to
  indicate that one or more JPA entities have not been enhanced during
  runtime.I saw a brief mention about this at


http://openjpa.apache.org/builds/2.1.1/apache-openjpa/docs/ref_guide_pc_enhance.html#ref_guide_pc_enhance_dynamic

  "If a javaagent is not provided via the command line and OpenJPA is
running
  on the Sun 1.6 SDK or IBM 1.6 JDK (SR8+), OpenJPA will attempt to
  dynamically load the Enhancer that was mentioned in the previous section.
  This support is provided as an ease of use feature and it is not
  recommended for use in a production system. Using this method of
  enhancement has the following caveats:
  The dynamic runtime enhancer is plugged into the JVM during creation of the
  EntityManagerFactory. Any Entity classes that are loaded before the
  EntityManagerFactory is created will not be enhanced. "


  I also noticed the following in the logs:

  openjpa.DynamicEnhancementAgent: false .

  I was expecting it to me openjpa.DynamicEnhancementAgent: true .

  I manually added the following jvm option
  -Dopenjpa.DynamicEnhancementAgent=true after which the logs show
  openjpa.DynamicEnhancementAgent: true but I hit the same entitiy not
  enhanced issue.

  Apart from build time enhancement , is there anything that can be done to
  ensure that all JPA entities are enhanced during runtime.

  Thanks
  Divya



Reply via email to