Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » OpenJPA enhancer task works on cmd line, fails in Eclipse 3.5.1
OpenJPA enhancer task works on cmd line, fails in Eclipse 3.5.1 [message #504249] Thu, 17 December 2009 16:05 Go to next message
Eclipse UserFriend
(This is my third try at posting this. The first two never showed up. My attempts were yesterday, several hours apart, so I'm pretty sure I waited long enough.)

I have an app using JDK 1.6, Eclipse 3.5.1, and OpenJPA 1.2.1. OpenJPA has an "enhancer" task that modifies the bytecode of domain classes. My Ant build script to do this works perfectly fine from the command line. When I run it from Eclipse, however, it fails with the build output that follows this.

Following the build output is the relevant portion of my build.xml file. My persistence.xml file is in "src/java/META-INF/persistence.xml", which is covered in the classpath (this is mentioned as one of the possible causes in the error message).

What could I be doing wrong here?

Ant build from Eclipse:
------------
enhance.classpath[<<workspacepath>>\DynamicContent\lib\openjpa-1.2.1.jar; <<workspacepath>>\DynamicContent\lib\geronimo-jpa_3.0_spec-1.0.jar; <<workspacepath>>\DynamicContent\lib\geronimo-jta_1.1_spec-1.1.jar; <<workspacepath>>\DynamicContent\lib\commons-lang-2.4.jar;< <workspacepath>>\DynamicContent\lib\commons-collections-3.2.1.jar; <<workspacepath>>\DynamicContent\lib\serp-1.13.1.jar;<<workspacepath >>\DynamicContent\src\java;<<workspacepath>>\DynamicContent\build\classes]
[java] ProductDerivations: 4
[java] 1. org.apache.openjpa.jdbc.conf.JDBCProductDerivation: OK
[java] 2.
org.apache.openjpa.persistence.PersistenceProductDerivation: OK
[java] 3.
org.apache.openjpa.persistence.jdbc.JDBCPersistenceProductDe rivation: OK
[java] 4. org.apache.openjpa.slice.ProductDerivation: OK
[openjpac] <openjpa-1.2.1-r752877:753278 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.initializeMetaDat aFactory(MetaDataRepository.java:1567)
[openjpac] at
org.apache.openjpa.meta.MetaDataRepository.endConfiguration( MetaDataRepository.java:1558)
[openjpac] at
org.apache.openjpa.lib.conf.Configurations.configureInstance (Configurations.java:505)
[openjpac] at
org.apache.openjpa.lib.conf.Configurations.configureInstance (Configurations.java:430)
[openjpac] at
org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginVa lue.java:103)
[openjpac] at
org.apache.openjpa.conf.MetaDataRepositoryValue.instantiate( MetaDataRepositoryValue.java:68)
[openjpac] at
org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectVa lue.java:83)
[openjpac] at
org.apache.openjpa.conf.OpenJPAConfigurationImpl.newMetaData RepositoryInstance(OpenJPAConfigurationImpl.java:863)
[openjpac] at
org.apache.openjpa.ant.PCEnhancerTask.executeOn(PCEnhancerTa sk.java:88)
[openjpac] at
org.apache.openjpa.lib.ant.AbstractTask.execute(AbstractTask .java:172)
[openjpac] at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.j ava:288)
[openjpac] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[openjpac] at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
[openjpac] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
[openjpac] at java.lang.reflect.Method.invoke(Method.java:585)
[openjpac] at
org.apache.tools.ant.dispatch.DispatchUtils.execute(Dispatch Utils.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.ja va:1337)
[openjpac] at
org.apache.tools.ant.Project.executeTarget(Project.java:1306 )
[openjpac] at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(D efaultExecutor.java:41)
[openjpac] at
org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecuto r.executeTargets(EclipseDefaultExecutor.java:32)
[openjpac] at
org.apache.tools.ant.Project.executeTargets(Project.java:118 9)
[openjpac] at
org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run (InternalAntRunner.java:423)
[openjpac] at
org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.mai n(InternalAntRunner.java:137)
------------

Relevant part of build.xml:
-------------
<project name="DynamicContent" default="build" basedir=".">

<property file="build-dyncontent.properties"/>

<path id="enhance.classpath">
<pathelement location="${openjpa.jar}"/>
<pathelement location="${jpa.jar}"/>
<pathelement location="${jta.jar}"/>
<pathelement location="${commons-lang.jar}"/>
<pathelement location="${commons-collections.jar}"/>
<pathelement location="${serp.jar}"/>
<pathelement location="src/java"/>
<pathelement location="build/classes"/>
</path>

<path id="build.classpath">
<pathelement location="${openjpa.jar}"/>
<pathelement location="${jackson-mapper.jar}"/>
<pathelement location="${jackson-core-asl.jar}"/>
<pathelement location="${jackson-jaxrs.jar}"/>
<pathelement location="${jackson-xc.jar}"/>
<pathelement location="${aspectjrt.jar}"/>
<pathelement location="${aspectjweaver.jar}"/>
<pathelement location="${commons-lang.jar}"/>
<pathelement location="${commons-logging.jar}"/>
<pathelement location="${commons-beanutils.jar}"/>
<pathelement location="${commons-collections.jar}"/>
<pathelement location="${serp.jar}"/>
<pathelement location="${cxf.jar}"/>
<pathelement location="${jaxb-api.jar}"/>
<pathelement location="${jaxb-impl.jar}"/>
<pathelement location="${jsr311-api.jar}"/>
<pathelement location="${spring.jar}"/>
<pathelement location="${cglib.jar}"/>
<pathelement location="${wsdl4j.jar}"/>
<pathelement location="${XmlSchema.jar}"/>
<pathelement location="${jpa.jar}"/>
<pathelement location="build/classes"/>
</path>

<path id="test.classpath">
<pathelement location="${derby.jar}"/>
<pathelement location="${junit.jar}"/>
<pathelement location="${jta.jar}"/>
<pathelement location="build/testclasses"/>
<path refid="build.classpath"/>
</path>

<target name="build"
depends="compile,enhance-classes,assemble-war,assemble-ear" >
</target>

<target name="compile">
<delete dir="build"/>
<mkdir dir="build/classes"/>
<javac destdir="build/classes" debug="true" failonerror="true">
<src path="src/java"/>
<classpath refid="build.classpath"/>
</javac>
</target>

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

<target name="enhance-classes">
<pathconvert property="echo.enhance.classpath" refid="enhance.classpath"/>
<echo
message="enhance.classpath[${echo.enhance.classpath}]"/>
<java
classname="org.apache.openjpa.lib.conf.ProductDerivations">
<classpath refid="enhance.classpath"/>
</java>
<openjpac directory="build/enhancedClasses"
enforcepropertyrestrictions="true">
<classpath refid="enhance.classpath"/>
<fileset dir="src/java">
<include name="**/domain/*.java"/>
</fileset>
</openjpac>
</target>
</project>
-----------

Re: OpenJPA enhancer task works on cmd line, fails in Eclipse 3.5.1 [message #504268 is a reply to message #504249] Thu, 17 December 2009 20:08 Go to previous messageGo to next message
Eclipse UserFriend
David M. Karr wrote:
> (This is my third try at posting this. The first two never showed up.
> My attempts were yesterday, several hours apart, so I'm pretty sure I
> waited long enough.)
>
> I have an app using JDK 1.6, Eclipse 3.5.1, and OpenJPA 1.2.1. OpenJPA
> has an "enhancer" task that modifies the bytecode of domain classes. My
> Ant build script to do this works perfectly fine from the command line.
> When I run it from Eclipse, however, it fails with the build output that
> follows this.
>
> Following the build output is the relevant portion of my build.xml
> file. My persistence.xml file is in
> "src/java/META-INF/persistence.xml", which is covered in the classpath
> (this is mentioned as one of the possible causes in the error message).
>
> What could I be doing wrong here?
>

My guess would be a path problem. Check the launch configuration for
your ant script in Eclipse. Make sure the Working Directory on the JRE
tab points to the correct location.

> Ant build from Eclipse:
> ------------
> enhance.classpath[<<workspacepath>>\DynamicContent\lib\openjpa-1.2.1.jar;
> <<workspacepath>>\DynamicContent\lib\geronimo-jpa_3.0_spec-1.0.jar;
> <<workspacepath>>\DynamicContent\lib\geronimo-jta_1.1_spec-1.1.jar;
> <<workspacepath>>\DynamicContent\lib\commons-lang-2.4.jar;<
> <workspacepath>>\DynamicContent\lib\commons-collections-3.2.1.jar;
> <<workspacepath>>\DynamicContent\lib\serp-1.13.1.jar;<<workspacepath
> >>\DynamicContent\src\java;<<workspacepath>>\DynamicContent\build\classes]
> [java] ProductDerivations: 4
> [java] 1. org.apache.openjpa.jdbc.conf.JDBCProductDerivation: OK
> [java] 2.
> org.apache.openjpa.persistence.PersistenceProductDerivation: OK
> [java] 3.
> org.apache.openjpa.persistence.jdbc.JDBCPersistenceProductDe rivation: OK
> [java] 4. org.apache.openjpa.slice.ProductDerivation: OK
> [openjpac] <openjpa-1.2.1-r752877:753278 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.initializeMetaDat
> aFactory(MetaDataRepository.java:1567)
> [openjpac] at
> org.apache.openjpa.meta.MetaDataRepository.endConfiguration(
> MetaDataRepository.java:1558)
> [openjpac] at
> org.apache.openjpa.lib.conf.Configurations.configureInstance
> (Configurations.java:505)
> [openjpac] at
> org.apache.openjpa.lib.conf.Configurations.configureInstance
> (Configurations.java:430)
> [openjpac] at
> org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginVa lue.java:103)
> [openjpac] at
> org.apache.openjpa.conf.MetaDataRepositoryValue.instantiate(
> MetaDataRepositoryValue.java:68)
> [openjpac] at
> org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectVa lue.java:83)
> [openjpac] at
> org.apache.openjpa.conf.OpenJPAConfigurationImpl.newMetaData
> RepositoryInstance(OpenJPAConfigurationImpl.java:863)
> [openjpac] at
> org.apache.openjpa.ant.PCEnhancerTask.executeOn(PCEnhancerTa sk.java:88)
> [openjpac] at
> org.apache.openjpa.lib.ant.AbstractTask.execute(AbstractTask .java:172)
> [openjpac] at
> org.apache.tools.ant.UnknownElement.execute(UnknownElement.j ava:288)
> [openjpac] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
> [openjpac] at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce
> ssorImpl.java:39)
> [openjpac] at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe
> thodAccessorImpl.java:25)
> [openjpac] at java.lang.reflect.Method.invoke(Method.java:585)
> [openjpac] at
> org.apache.tools.ant.dispatch.DispatchUtils.execute(Dispatch
> Utils.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.ja va:1337)
> [openjpac] at
> org.apache.tools.ant.Project.executeTarget(Project.java:1306 )
> [openjpac] at
> org.apache.tools.ant.helper.DefaultExecutor.executeTargets(D
> efaultExecutor.java:41)
> [openjpac] at
> org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecuto
> r.executeTargets(EclipseDefaultExecutor.java:32)
> [openjpac] at
> org.apache.tools.ant.Project.executeTargets(Project.java:118 9)
> [openjpac] at
> org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run
> (InternalAntRunner.java:423)
> [openjpac] at
> org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.mai
> n(InternalAntRunner.java:137)
> ------------
>
> Relevant part of build.xml:
> -------------
> <project name="DynamicContent" default="build" basedir=".">
>
> <property file="build-dyncontent.properties"/>
>
> <path id="enhance.classpath">
> <pathelement location="${openjpa.jar}"/>
> <pathelement location="${jpa.jar}"/>
> <pathelement location="${jta.jar}"/>
> <pathelement location="${commons-lang.jar}"/>
> <pathelement location="${commons-collections.jar}"/>
> <pathelement location="${serp.jar}"/>
> <pathelement location="src/java"/>
> <pathelement location="build/classes"/>
> </path>
>
> <path id="build.classpath">
> <pathelement location="${openjpa.jar}"/>
> <pathelement location="${jackson-mapper.jar}"/>
> <pathelement location="${jackson-core-asl.jar}"/>
> <pathelement location="${jackson-jaxrs.jar}"/>
> <pathelement location="${jackson-xc.jar}"/>
> <pathelement location="${aspectjrt.jar}"/>
> <pathelement location="${aspectjweaver.jar}"/>
> <pathelement location="${commons-lang.jar}"/>
> <pathelement location="${commons-logging.jar}"/>
> <pathelement location="${commons-beanutils.jar}"/>
> <pathelement location="${commons-collections.jar}"/>
> <pathelement location="${serp.jar}"/>
> <pathelement location="${cxf.jar}"/>
> <pathelement location="${jaxb-api.jar}"/>
> <pathelement location="${jaxb-impl.jar}"/>
> <pathelement location="${jsr311-api.jar}"/>
> <pathelement location="${spring.jar}"/>
> <pathelement location="${cglib.jar}"/>
> <pathelement location="${wsdl4j.jar}"/>
> <pathelement location="${XmlSchema.jar}"/>
> <pathelement location="${jpa.jar}"/>
> <pathelement location="build/classes"/>
> </path>
>
> <path id="test.classpath">
> <pathelement location="${derby.jar}"/>
> <pathelement location="${junit.jar}"/>
> <pathelement location="${jta.jar}"/>
> <pathelement location="build/testclasses"/>
> <path refid="build.classpath"/>
> </path>
>
> <target name="build"
> depends="compile,enhance-classes,assemble-war,assemble-ear" >
> </target>
>
> <target name="compile">
> <delete dir="build"/>
> <mkdir dir="build/classes"/>
> <javac destdir="build/classes" debug="true" failonerror="true">
> <src path="src/java"/>
> <classpath refid="build.classpath"/>
> </javac>
> </target>
>
> <taskdef classpathref="enhance.classpath" name="openjpac"
> classname="org.apache.openjpa.ant.PCEnhancerTask"/>
>
> <target name="enhance-classes">
> <pathconvert property="echo.enhance.classpath"
> refid="enhance.classpath"/>
> <echo
> message="enhance.classpath[${echo.enhance.classpath}]"/>
> <java
> classname="org.apache.openjpa.lib.conf.ProductDerivations">
> <classpath refid="enhance.classpath"/>
> </java>
> <openjpac directory="build/enhancedClasses"
> enforcepropertyrestrictions="true">
> <classpath refid="enhance.classpath"/>
> <fileset dir="src/java">
> <include name="**/domain/*.java"/>
> </fileset>
> </openjpac>
> </target>
> </project>
> -----------
>
>
Re: OpenJPA enhancer task works on cmd line, fails in Eclipse 3.5.1 [message #504271 is a reply to message #504268] Thu, 17 December 2009 20:35 Go to previous message
Eclipse UserFriend
Well, that wasn't it, but that made me look at something that seemed suspicious, so I was able to figure it out. For some reason that I don't understand, the run configuration for the script didn't include the project, so it didn't have any of the classpath of the project. I didn't see any way to add the "project", so I had to manually add all the jars for the project. Once I did that, Ant targets ran fine from Eclipse.
Previous Topic:change order of custom library
Next Topic:Create Servlet Wizard in Eclipse
Goto Forum:
  


Current Time: Sat Mar 15 23:38:55 EDT 2025

Powered by FUDForum. Page generated in 0.03037 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top