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

PCEnhancer Ant task unable to find persistence.xml in default location with explicit classpath definition


    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.0.1
    • Fix Version/s: None
    • Component/s: build / infrastructure
    • Labels:
    • Environment:
      Linux, Apache Ant 1.7.0, Sun JDK 1.6.0_01-b06


      I've noticed some irregular behavior from the PCEnhancer's "openjpac" Ant task: When I specify a custom classpath for the task using an embedded <classpath> element, the task is unable to properly locate my persistence.xml file in the default "META-INF/persistence.xml" location relative to this path. I must explicitly specify the location of the persistence.xml file using the "propertiesFile" attribute of the nested "config" element.

      Here's an outline of the layout of my project files:

      lib/classes/...(compiled class files)...

      The relevant code from build.xml:

      <path id="build.classpath">
      <fileset dir="${basedir}/lib">
      <include name="*/.jar" />
      <exclude name="**/${dist.name}.jar" />
      <taskdef name="openjpac"
      classpathref="build.classpath" />
      <pathelement location="${basedir}/lib/classes" />
      <path refid="build.classpath"/>

      If i modify the openjpac element as follows, the persistence.xml file is picked up:

      <pathelement location="${basedir}/lib/classes" />
      <path refid="build.classpath"/>
      <config propertiesFile="${basedir}/lib/classes/META-INF/persistence.xml"/>

      Here's an additional point of interest: In my persistence.xml file I set <property name="openjpa.Log" value="log4j" /> to enable Log4j logging within OpenJPA. Notice that I have my log4j.properties file in the root of my classpath hierarchy, where it should be automatically found by Log4j on initialization. When I run ant using the second configuration listed above, I see this output:

      [openjpac] log4j:WARN No appenders could be found for logger (openjpa.Runtime).
      [openjpac] log4j:WARN Please initialize the log4j system properly.

      My log4j properties file does contain all required configuration, but it isn't being found by Log4j, just like the PCEnhancer task isn't picking up my persistence.xml from the specified classpath. Perhaps the PCEnhancer task is somehow incorrectly incorporating this classpath, or failing to pass it along on initialization? Perhaps to get this to work properly a new runtime must be created (fork) so the classpath is available to everything uniformly?




            • Assignee:
              hazen Andy Schlaikjer
            • Votes:
              1 Vote for this issue
              1 Start watching this issue


              • Created: