You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by David Beer <da...@googlemail.com> on 2009/10/06 14:16:55 UTC

Problem enhancing class with reference to enum

Hi All

I have a class that references another class, which is an enum. When
trying to enhance the class that referes to the enum It is failing
saying it can't find the class referenced. I am not looking to persist
the enum, I am only looking to persist the enum value.

So my class looks like the following:

@Entity
public class IM implements Serializable {

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private long id;
    private IMType imType; //references the enum

    /**
     * @return the id
     */
    public long getId() {
        return id;
    }

    /**
     * @return the imType
     */
    public IMType getImType() {
        return imType;
    }

    /**
     * @param imType the imType to set
     */
    public void setImType(IMType imType) {
        this.imType = imType;
    }
}

public enum IMType {AIM, GOOGLETALK, ICQ, MSN, YAHOO}

My ant build task is as follows;

<target name="enhance">
        <taskdef name="openjpac"
classname="org.apache.openjpa.ant.PCEnhancerTask"> <classpath>
                <fileset dir="${lib.dir}">
                    <include  name="*.jar"/>
                </fileset>
            </classpath>
        </taskdef>
        <echo message="openjpa enhancer started"/>
        <openjpac>
            <config propertiesFile="openjpa-dev.xml"/>
            <!--<config
propertiesFile="${classes.dir}/META-INF/persistence.xml"/>-->
<classpath> <pathelement location="${classes.dir}"/>
                <pathelement path="${lib.dir}"/>
            </classpath>
            <fileset dir="${classes.dir}">
                <include name="**/*.class"/>                
            </fileset>

        </openjpac>
        <echo message="openjpa enhancer finished"/>
</target>

I get the the following error when trying to enhance IM.class

enhance:
openjpa enhancer started
java.lang.IllegalArgumentException: java.lang.ClassNotFoundException:
pcm.jpa.IMType at serp.util.Strings.toClass(Strings.java:164)
        at serp.util.Strings.toClass(Strings.java:108)
        at
org.apache.openjpa.lib.meta.ClassArgParser.parseTypes(ClassArgParser.java:164)
at org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4477) at
org.apache.openjpa.ant.PCEnhancerTask.executeOn(PCEnhancerTask.java:89)
at
org.apache.openjpa.lib.ant.AbstractTask.execute(AbstractTask.java:172)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor51.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616) at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348) at
org.apache.tools.ant.Target.execute(Target.java:357) at
org.apache.tools.ant.Target.performTasks(Target.java:385) at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337) at
org.apache.tools.ant.Project.executeTarget(Project.java:1306) at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1189) at
org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:278)
at
org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:497)
at
org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:151)
java.lang.IllegalArgumentException: java.lang.ClassNotFoundException:
pcm.jpa.IMType at serp.util.Strings.toClass(Strings.java:164) at
serp.util.Strings.toClass(Strings.java:108) at
org.apache.openjpa.lib.meta.ClassArgParser.parseTypes(ClassArgParser.java:164)
at org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4477) at
org.apache.openjpa.ant.PCEnhancerTask.executeOn(PCEnhancerTask.java:89)
at
org.apache.openjpa.lib.ant.AbstractTask.execute(AbstractTask.java:172)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor51.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616) at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348) at
org.apache.tools.ant.Target.execute(Target.java:357) at
org.apache.tools.ant.Target.performTasks(Target.java:385) at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337) at
org.apache.tools.ant.Project.executeTarget(Project.java:1306) at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1189) at
org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:278)
at
org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:497)
at
org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:151)
BUILD FAILED (total time: 0 seconds)

Any Suggestions.


Re: Problem enhancing class with reference to enum

Posted by Daryl Stultz <da...@6degrees.com>.
On Tue, Oct 6, 2009 at 11:54 AM, David Beer <da...@googlemail.com>wrote:

> Excellent this works great thanks. Do you know if this error with the
> ant task will be fixed in 1.2.x or if it will only be fixed in the
> openjpa 2.0 release?
>
>
I think this is the fix:
https://issues.apache.org/jira/browse/OPENJPA-1121

-- 
Daryl Stultz
_____________________________________
6 Degrees Software and Consulting, Inc.
http://www.6degrees.com
mailto:daryl@6degrees.com

Re: Problem enhancing class with reference to enum

Posted by David Beer <da...@googlemail.com>.
On Tue, 6 Oct 2009 09:57:22 -0400
Daryl Stultz <da...@6degrees.com> wrote:

> On Tue, Oct 6, 2009 at 8:57 AM, David Beer
> <da...@googlemail.com>wrote:
> 
> >
> > OK, How do I go about doing that?
> >
> 
> You could try something like this:
> 
> <target name="EnhanceJPA">
> <java classname="org.apache.openjpa.enhance.PCEnhancer">
> <classpath>
> <pathelement path="${classes}"/>
> <pathelement path="/path/to/required.jar"/>
> <fileset dir="/path/to/openjpa_jars">
> <include name="**/*.jar"/>
> </fileset>
> </classpath>
> </java>
> </target>
> 

Excellent this works great thanks. Do you know if this error with the
ant task will be fixed in 1.2.x or if it will only be fixed in the
openjpa 2.0 release?

Thanks

David

Re: Problem enhancing class with reference to enum

Posted by Daryl Stultz <da...@6degrees.com>.
On Tue, Oct 6, 2009 at 8:57 AM, David Beer <da...@googlemail.com>wrote:

>
> OK, How do I go about doing that?
>

You could try something like this:

<target name="EnhanceJPA">
<java classname="org.apache.openjpa.enhance.PCEnhancer">
<classpath>
<pathelement path="${classes}"/>
<pathelement path="/path/to/required.jar"/>
<fileset dir="/path/to/openjpa_jars">
<include name="**/*.jar"/>
</fileset>
</classpath>
</java>
</target>

-- 
Daryl Stultz
_____________________________________
6 Degrees Software and Consulting, Inc.
http://www.6degrees.com
mailto:daryl@6degrees.com

Re: Problem enhancing class with reference to enum

Posted by David Beer <da...@googlemail.com>.
On Tue, 6 Oct 2009 08:52:49 -0400
Daryl Stultz <da...@6degrees.com> wrote:

> On Tue, Oct 6, 2009 at 8:16 AM, David Beer
> <da...@googlemail.com>wrote:
> 
> > Hi All
> >
> > I have a class that references another class, which is an enum.
> 
> 
> The Ant task is broken for the version of OpenJPA you are running
> (1.2.1?) when enums are referenced. I had to switch to the command
> line version (though still launched from Ant).
> 

OK, How do I go about doing that?

Re: Problem enhancing class with reference to enum

Posted by Daryl Stultz <da...@6degrees.com>.
On Tue, Oct 6, 2009 at 8:16 AM, David Beer <da...@googlemail.com>wrote:

> Hi All
>
> I have a class that references another class, which is an enum.


The Ant task is broken for the version of OpenJPA you are running (1.2.1?)
when enums are referenced. I had to switch to the command line version
(though still launched from Ant).

-- 
Daryl Stultz
_____________________________________
6 Degrees Software and Consulting, Inc.
http://www.6degrees.com
mailto:daryl@6degrees.com