Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-302

PCEnhancer needs target classes on classpath


    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 0.9.7
    • Fix Version/s: 2.2.0
    • Component/s: docs
    • Labels:
    • Environment:
    • Patch Info:
      Patch Available


      The documentation (sections, doesn't make it clear that the classes to be enhanced need to be on the class path of the PCEnhancer application or Ant task. In an Eclipse environment, I battled for some hours to get the enhancer to work.

      In my setup, the following appears to be true:

      • The application needs a classpath consisting of the OpenJPA libraries as well as the java compilation destination directory for the compiled entity classes. Here's how I ran the program (as an application) under Ant:

      <target name="enhance2">
      <java classpathref="JPA_PATH" classpath="build/classes" classname="org.apache.openjpa.enhance.PCEnhancer">
      <arg line="-d build/classes -p build/classes/META-INF/persistence.xml build/classes/com/smotricz/testjpa/Exit.class"/>

      • As an Ant task, the taskdef needs the OpenJPA libraries on its classpath, but it does no good to include the compiled classes destination path there. Rather, the openjpa task will accept a nested classpath element, and this classpath must contain both the OpenJPA libraries and the compiled entity classes path. Here's my Ant target for this:

      <target name="enhance">
      <taskdef name="openjpac" classname="org.apache.openjpa.ant.PCEnhancerTask" classpathref="JPA_PATH"/>
      <path id="ENH_PATH">
      <path refid="JPA_PATH"/>
      <path refid="CLASSES_PATH"/>
      <openjpac directory="build/classes">
      <config propertiesFile="build/classes/META-INF/persistence.xml"/>
      <fileset dir="build/classes">
      <include name="*/.class"/>
      <exclude name="**/TestJPA.class"/>
      <classpath refid="ENH_PATH"/>

      Hopefully augmenting the doc with some of this information will save other users some pain.


        1. OPENJPA-302.patch
          4 kB
          Jacob Nowosatka



            • Assignee:
              jtnowosatka Jacob Nowosatka
              smotricz Carl Smotricz
            • Votes:
              0 Vote for this issue
              1 Start watching this issue


              • Created: