newbie problem with "enhancement" using Idea 8 and OpenJPA

3 messages Options
Embed this post
Permalink
Larry White

newbie problem with "enhancement" using Idea 8 and OpenJPA

Reply Threaded More More options
Print post
Permalink
Hi,

I'm working on my first OpenJPA app using the plugin for Intellij Idea 8.
I'm getting the error:

<openjpa-1.2.1-r752877:753278 nonfatal user error>
org.apache.openjpa.persistence.ArgumentException: Attempt to cast instance
"com.deathrayresearch.server.model.product.Product@1c7e2da" to
PersistenceCapable failed.  Ensure that it has been enhanced.

I don't know enough about the technology or the plug-in to know even
generally what's going wrong. My understanding is that the plugin performs
the enhancement during each build, but I'm not seeing any errors during the
build process to indicate that it failed.

FWIW, I have not created a table for "Product", under the assumption that it
would be generated from the entity class definition.

My entity class and persistence.xml are below.

Thanks for your help

-----------------------------------------------------
package com.deathrayresearch.server.model.product;
import javax.persistence.*;
import java.io.Serializable;

@Entity
public class Product implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long id;

    @Basic
@Column(nullable = false, length = 30)
    private String name;

    @Basic
@Column(nullable = true, length = 30)
    private String description;

    public Product() {
    }

    public Product(String description, String name) {
        this.description = description;
        this.name = name;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}

--------------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">

    <persistence-unit name="worldview">

 <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
        <properties>
            <property name="openjpa.ConnectionURL"
value="jdbc:postgresql:worldview"/>
            <property name="openjpa.ConnectionDriverName"
value="org.postgresql.Driver"/>
            <property name="openjpa.ConnectionUserName" value="postgres"/>
            <property name="openjpa.ConnectionPassword" value="foobar"/>
            <property name="openjpa.Log" value="DefaultLevel=TRACE,
Tool=INFO"/>
        </properties>
    </persistence-unit>
Rick Curtis

Re: newbie problem with "enhancement" using Idea 8 and OpenJPA

Reply Threaded More More options
Print post
Permalink
Larry -

I haven't used Intellij before so please excuse me if it seems that I'm
fumbling through the dark here...

Do you see any information logged during the build process or prior to
running your application that has the following key "openjpa.Enhance"? Is
there any text that our enhancer ran, but didn't do any work (Search for
"enhance") ? What JPA operation were you invoking when you encounter the
exception above (ie : em.persist() ) ? Hopefully this gets us going in the
right direction.

Since you are new to OpenJPA, take a look at a blog post [1] I wrote a while
back which talks about the enhancement process.

[1]
http://webspherepersistence.blogspot.com/2009/02/openjpa-enhancement.html

Thanks,
Rick

On Tue, Oct 27, 2009 at 2:40 PM, Larry White <[hidden email]> wrote:

> Hi,
>
> I'm working on my first OpenJPA app using the plugin for Intellij Idea 8.
> I'm getting the error:
>
> <openjpa-1.2.1-r752877:753278 nonfatal user error>
> org.apache.openjpa.persistence.ArgumentException: Attempt to cast instance
> "com.deathrayresearch.server.model.product.Product@1c7e2da" to
> PersistenceCapable failed.  Ensure that it has been enhanced.
>
> I don't know enough about the technology or the plug-in to know even
> generally what's going wrong. My understanding is that the plugin performs
> the enhancement during each build, but I'm not seeing any errors during the
> build process to indicate that it failed.
>
> FWIW, I have not created a table for "Product", under the assumption that
> it
> would be generated from the entity class definition.
>
> My entity class and persistence.xml are below.
>
> Thanks for your help
>
> -----------------------------------------------------
> package com.deathrayresearch.server.model.product;
> import javax.persistence.*;
> import java.io.Serializable;
>
> @Entity
> public class Product implements Serializable {
>
>    @Id
>    @GeneratedValue(strategy = GenerationType.IDENTITY)
>    private long id;
>
>    @Basic
> @Column(nullable = false, length = 30)
>    private String name;
>
>    @Basic
> @Column(nullable = true, length = 30)
>    private String description;
>
>    public Product() {
>    }
>
>    public Product(String description, String name) {
>        this.description = description;
>        this.name = name;
>    }
>
>    public long getId() {
>        return id;
>    }
>
>    public void setId(long id) {
>        this.id = id;
>    }
>
>    public String getDescription() {
>        return description;
>    }
>
>    public void setDescription(String description) {
>        this.description = description;
>    }
>
>    public String getName() {
>        return name;
>    }
>
>    public void setName(String name) {
>        this.name = name;
>    }
> }
>
> --------------------------------------------------
>
> <?xml version="1.0" encoding="UTF-8"?>
> <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
>
>    <persistence-unit name="worldview">
>
>
>  <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
>        <properties>
>            <property name="openjpa.ConnectionURL"
> value="jdbc:postgresql:worldview"/>
>            <property name="openjpa.ConnectionDriverName"
> value="org.postgresql.Driver"/>
>            <property name="openjpa.ConnectionUserName" value="postgres"/>
>            <property name="openjpa.ConnectionPassword" value="foobar"/>
>            <property name="openjpa.Log" value="DefaultLevel=TRACE,
> Tool=INFO"/>
>        </properties>
>    </persistence-unit>
>
Larry White

Re: newbie problem with "enhancement" using Idea 8 and OpenJPA

Reply Threaded More More options
Print post
Permalink
On Tue, Oct 27, 2009 at 4:02 PM, Rick Curtis <[hidden email]> wrote:

> Larry -
>
> I haven't used Intellij before so please excuse me if it seems that I'm
> fumbling through the dark here...
>
> Do you see any information logged during the build process or prior to
> running your application that has the following key "openjpa.Enhance"? Is
> there any text that our enhancer ran, but didn't do any work (Search for
> "enhance") ?


I'm not seeing any reference to "enhance" in the build stage.  The only JPA
reference I've seen is text that says "Validating Persistence Module" or
something to that effect.



> What JPA operation were you invoking when you encounter the
> exception above (ie : em.persist() ) ? Hopefully this gets us going in the
> right direction.
>
> Yes, em.persist();


> Since you are new to OpenJPA, take a look at a blog post [1] I wrote a
> while
> back which talks about the enhancement process.
>
> [1]
> http://webspherepersistence.blogspot.com/2009/02/openjpa-enhancement.html
>
> Thanks,
> Rick
>
> On Tue, Oct 27, 2009 at 2:40 PM, Larry White <[hidden email]> wrote:
>
> > Hi,
> >
> > I'm working on my first OpenJPA app using the plugin for Intellij Idea 8.
> > I'm getting the error:
> >
> > <openjpa-1.2.1-r752877:753278 nonfatal user error>
> > org.apache.openjpa.persistence.ArgumentException: Attempt to cast
> instance
> > "com.deathrayresearch.server.model.product.Product@1c7e2da" to
> > PersistenceCapable failed.  Ensure that it has been enhanced.
> >
> > I don't know enough about the technology or the plug-in to know even
> > generally what's going wrong. My understanding is that the plugin
> performs
> > the enhancement during each build, but I'm not seeing any errors during
> the
> > build process to indicate that it failed.
> >
> > FWIW, I have not created a table for "Product", under the assumption that
> > it
> > would be generated from the entity class definition.
> >
> > My entity class and persistence.xml are below.
> >
> > Thanks for your help
> >
> > -----------------------------------------------------
> > package com.deathrayresearch.server.model.product;
> > import javax.persistence.*;
> > import java.io.Serializable;
> >
> > @Entity
> > public class Product implements Serializable {
> >
> >    @Id
> >    @GeneratedValue(strategy = GenerationType.IDENTITY)
> >    private long id;
> >
> >    @Basic
> > @Column(nullable = false, length = 30)
> >    private String name;
> >
> >    @Basic
> > @Column(nullable = true, length = 30)
> >    private String description;
> >
> >    public Product() {
> >    }
> >
> >    public Product(String description, String name) {
> >        this.description = description;
> >        this.name = name;
> >    }
> >
> >    public long getId() {
> >        return id;
> >    }
> >
> >    public void setId(long id) {
> >        this.id = id;
> >    }
> >
> >    public String getDescription() {
> >        return description;
> >    }
> >
> >    public void setDescription(String description) {
> >        this.description = description;
> >    }
> >
> >    public String getName() {
> >        return name;
> >    }
> >
> >    public void setName(String name) {
> >        this.name = name;
> >    }
> > }
> >
> > --------------------------------------------------
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <persistence xmlns="http://java.sun.com/xml/ns/persistence"
> version="1.0">
> >
> >    <persistence-unit name="worldview">
> >
> >
> >
>  <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
> >        <properties>
> >            <property name="openjpa.ConnectionURL"
> > value="jdbc:postgresql:worldview"/>
> >            <property name="openjpa.ConnectionDriverName"
> > value="org.postgresql.Driver"/>
> >            <property name="openjpa.ConnectionUserName" value="postgres"/>
> >            <property name="openjpa.ConnectionPassword" value="foobar"/>
> >            <property name="openjpa.Log" value="DefaultLevel=TRACE,
> > Tool=INFO"/>
> >        </properties>
> >    </persistence-unit>
> >
>