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

Report persistence.xml missing when trying to enhance openJPA entity from eclipse

    XMLWordPrintableJSON

Details

    Description

      I try to enhance the entity in my project with OpenJPA, and get the result as followed.

      But in fact it DOES existed for when I deploy the project the OpenJPA can visit the persistence.xml and read the JDBC connection.

      Please be free to contact if any more info required and thanks in advance.

      Wilson Chen

      Detailed followed------------------------------------------------

      enhance:
      [echo] ${enhance.cp}
      [openjpac] <openjpa-2.1.0-r422266:1071316 fatal user error> org.apache.openjpa.util.MetaDataException: MetaDataFactory could not be configured (conf.newMetaDataFactoryInstance() returned null). This might mean that no configuration properties were found. Ensure that you have a META-INF/persistence.xml file, that it is available in your classpath, or that the properties file you are using for configuration is available. If you are using Ant, please see the <properties> or <propertiesFile> attributes of the task's nested <config> element. This can also occur if your OpenJPA distribution jars are corrupt, or if your security policy is overly strict.
      [openjpac] at org.apache.openjpa.meta.MetaDataRepository.initializeMetaDataFactory(MetaDataRepository.java:1904)
      [openjpac] at org.apache.openjpa.meta.MetaDataRepository.endConfiguration(MetaDataRepository.java:1885)
      [openjpac] at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:518)
      [openjpac] at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:443)
      [openjpac] at org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:104)
      [openjpac] at org.apache.openjpa.conf.MetaDataRepositoryValue.instantiate(MetaDataRepositoryValue.java:68)
      [openjpac] at org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:83)
      [openjpac] at org.apache.openjpa.conf.OpenJPAConfigurationImpl.newMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:949)
      [openjpac] at org.apache.openjpa.ant.PCEnhancerTask.executeOn(PCEnhancerTask.java:88)
      [openjpac] at org.apache.openjpa.lib.ant.AbstractTask.execute(AbstractTask.java:171)
      [openjpac] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
      [openjpac] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      [openjpac] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      [openjpac] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      [openjpac] at java.lang.reflect.Method.invoke(Unknown Source)
      [openjpac] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
      [openjpac] at org.apache.tools.ant.Task.perform(Task.java:348)
      [openjpac] at org.apache.tools.ant.Target.execute(Target.java:357)
      [openjpac] at org.apache.tools.ant.Target.performTasks(Target.java:385)
      [openjpac] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
      [openjpac] at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
      [openjpac] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
      [openjpac] at org.eclipse.ant.internal.core.ant.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
      [openjpac] at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
      [openjpac] at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunner.java:662)
      [openjpac] at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunner.java:495)
      [openjpac] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      [openjpac] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      [openjpac] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      [openjpac] at java.lang.reflect.Method.invoke(Unknown Source)
      [openjpac] at org.eclipse.ant.core.AntRunner.run(AntRunner.java:378)
      [openjpac] at org.eclipse.ant.internal.launching.launchConfigurations.AntLaunchDelegate.runInSameVM(AntLaunchDelegate.java:321)
      [openjpac] at org.eclipse.ant.internal.launching.launchConfigurations.AntLaunchDelegate.launch(AntLaunchDelegate.java:274)
      [openjpac] at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:853)
      [openjpac] at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:702)
      [openjpac] at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:695)
      [openjpac] at org.eclipse.core.externaltools.internal.model.ExternalToolBuilder.launchBuild(ExternalToolBuilder.java:181)
      [openjpac] at org.eclipse.core.externaltools.internal.model.ExternalToolBuilder.doBuildBasedOnScope(ExternalToolBuilder.java:169)
      [openjpac] at org.eclipse.core.externaltools.internal.model.ExternalToolBuilder.build(ExternalToolBuilder.java:88)
      [openjpac] at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:629)
      [openjpac] at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
      [openjpac] at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:172)
      [openjpac] at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:203)
      [openjpac] at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:255)
      [openjpac] at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
      [openjpac] at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:258)
      [openjpac] at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:311)
      [openjpac] at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:343)
      [openjpac] at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:144)
      [openjpac] at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:242)
      [openjpac] at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

      BUILD FAILED
      ...\BpcApiTestWeb\src\enhance.xml:50: <openjpa-2.1.0-r422266:1071316 fatal user error> org.apache.openjpa.util.MetaDataException: MetaDataFactory could not be configured (conf.newMetaDataFactoryInstance() returned null). This might mean that no configuration properties were found. Ensure that you have a META-INF/persistence.xml file, that it is available in your classpath, or that the properties file you are using for configuration is available. If you are using Ant, please see the <properties> or <propertiesFile> attributes of the task's nested <config> element. This can also occur if your OpenJPA distribution jars are corrupt, or if your security policy is overly strict.

      And that is the enhance file I used.

      <project name="jpa_enhance_builder">

      <target name="openjpa.libs.check" unless="openjpa.libs">
      <fail message="Please set -Dopenjpa.libs in your builder configuration!" />
      </target>
      <target name="build.dir.check" unless="build.dir">
      <fail message="Please set -Dbuild.dir in your builder configuration!" />
      </target>

      <target name="enhance" depends="openjpa.libs.check, build.dir.check">

      <path id="enhance.cp">
      <pathelement location="${basedir}${file.separator}${build.dir}"/>

      <fileset dir="${basedir}${file.separator}${openjpa.libs}">
      <include name="*/.jar"/>
      </fileset>
      </path>
      <echo message="${enhance.cp}"/>

      <taskdef name="openjpac" classname="org.apache.openjpa.ant.PCEnhancerTask">
      <classpath refid="enhance.cp"/>
      </taskdef>

      <openjpac>
      <!--
      <classpath refid="openjpa.path.id"/>
      -->
      <classpath>
      <fileset dir="D:\I031900\workspace\BpcApiTestWeb\lib\META-INF\persistence.xml" />
      </classpath>
      </openjpac>
      </target>
      </project>

      Attachments

        Activity

          People

            Unassigned Unassigned
            hangchen222@gmail.com hangchen222
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: