You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by "andrea.martano@litemailer.com" <an...@litemailer.com> on 2008/01/24 14:09:14 UTC

Can't get PCEnahncer to work

Hi All,

It's a couple of days I'm hitting my head against a wall!
why do I get this message when invoking PCEnhancer both from
command line and as an ant task?

Exception in thread "main"
java.lang.IllegalArgumentException:
java.lang.ClassNotFoundException: model.Visitor
        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:4328)
        at
org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4291)
        at
org.apache.openjpa.enhance.PCEnhancer.main(PCEnhancer.java:4263)
..... ......

>From what I can see the class model.Visitor is found, so I
can't understand what SERP complains for.

I build some other web apps using Springframework 2.5, the
Tomcat load time weaver and they work. Now I wanted to use
enhanced classes but I'm still.

Anyone can help me?

Thanks,

AM

Here follows my command line

export
CLASSPATH=./openjpa-1.0.1.jar:./lib/geronimo-jpa_3.0_spec-1.0.jar:./lib/geronimo-jta_1.1_spec-1.1.jar:./lib/geronimo-jms_1.1_spec-
1.0.1.jar:./lib/serp-1.13.1.jar:./lib/commons-collections-3.2.jar:./lib/commons-lang-2.1.jar:./lib/commons-logging-1.0.4.jar:./lib/common
s-pool-1.3.jar:$HOME/NetBeansProjects/TestApp2Model/src


java org.apache.openjpa.enhance.PCEnhancer \
-p
/home/java/NetBeansProjects/TestApp2Model/src/META-INF/persistence.xml
\
-d /home/java/NetBeansProjects/TestApp2Model/src/enhanced \
/home/java/NetBeansProjects/TestApp2Model/src/**/*.java

........................................................................

this is my ant target used inNetBeans 6.0

<target name="-pre-compile">
        
    <property name="jpa-home"
value="${user.home}/NetBeansProjects/java-libraries/apache-openjpa-1.0.1"/>
    
    <path id="jpa.classpath">
        <pathelement path="${jpa-home}/openjpa-1.0.1.jar"/>
        <fileset dir="${jpa-home}/lib">
            <include name="*.jar"/>
        </fileset>
    </path>
    
    <taskdef name="openjpac"
classname="org.apache.openjpa.ant.PCEnhancerTask">
        <classpath refid="jpa.classpath"/>
    </taskdef>
    
    <openjpac directory="${basedir}/src/enhanced">
        
        <config
propertiesFile="${basedir}/src/META-INF/persistence.xml"/>
        <fileset dir="${basedir}/src">
            <include name="model/*.java"/>
        </fileset>
    </openjpac>
    
    </target>
..................................................

this is the class source

package model;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Andrea Martano
 */
@Entity
@Table(name = "visitors")
@NamedQueries({
@NamedQuery(name = "findAllVisitors", query = "SELECT v FROM
Visitor v ORDER BY v.id")
})
public class Visitor implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @Column(name = "firstname")
    private String firstname;
    @Column(name = "lastname")
    private String lastname;
    @Column(name = "email")
    private String email;
    
    public Visitor() {}
    
    public Visitor(String firstname, String lastname, String
email) {
        setFirstname(firstname);
        setLastname(lastname);
        setEmail(email);
    }
    
    public void setId(Long id) {
        this.id = id;
    }

    
    public Long getId() {
        return id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (getId() != null ? getId().hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the
case the id fields are not set
        if (!(object instanceof Visitor)) {
            return false;
        }
        Visitor other = (Visitor) object;
        if ((this.getId() == null && other.getId() != null)
|| (this.getId() != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.Visitor[id=" + getId() + "]";
    }

    public String getFirstname() {
        return firstname;
    }

    public void setFirstname(String firstname) {
        this.firstname = firstname;
    }

    public String getLastname() {
        return lastname;
    }

    public void setLastname(String lastname) {
        this.lastname = lastname;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

}



Re: Help selecting version column

Posted by Jeff Melching <jm...@us.ibm.com>.
I have to do this for several entities, some of which have to have things 
eagerly loaded.  I am trying to save a little bandwidth and db processing. 
 I have an extremely complicated data model to deal with.



From:
"Patrick Linskey" <pl...@gmail.com>
To:
users@openjpa.apache.org
Date:
01/24/2008 10:49 AM
Subject:
Re: Help selecting version column



Hi,

Why are you trying to do this? Definitely it looks like this is a bug
in OpenJPA, but generally-speaking it's very cheap to pull back the
rest of the rows in a given record (i.e., select a frmo AnEntity a
where a.id = ?1).

-Patrick

On Jan 24, 2008 7:38 AM, Jeff Melching <jm...@us.ibm.com> wrote:
> I am trying to select only the version column of an entity to see if it
> was changed.
>
> If I run the following JPQL where verId is the version field of my 
entity:
>
> select a.verId from AnEntity a where a.id = ?1;
>
> The generated sql is:
>
> SELECT  FROM AN_ENTITY t0 WHERE t0.ID = ?
>
> Obviously, this is invalid sql syntax as the columns to select are
> missing.  I am using a DB2 dictionary.



-- 
Patrick Linskey
202 669 5907



Re: Help selecting version column

Posted by Patrick Linskey <pl...@gmail.com>.
Hi,

Why are you trying to do this? Definitely it looks like this is a bug
in OpenJPA, but generally-speaking it's very cheap to pull back the
rest of the rows in a given record (i.e., select a frmo AnEntity a
where a.id = ?1).

-Patrick

On Jan 24, 2008 7:38 AM, Jeff Melching <jm...@us.ibm.com> wrote:
> I am trying to select only the version column of an entity to see if it
> was changed.
>
> If I run the following JPQL where verId is the version field of my entity:
>
> select a.verId from AnEntity a where a.id = ?1;
>
> The generated sql is:
>
> SELECT  FROM AN_ENTITY t0 WHERE t0.ID = ?
>
> Obviously, this is invalid sql syntax as the columns to select are
> missing.  I am using a DB2 dictionary.



-- 
Patrick Linskey
202 669 5907

Help selecting version column

Posted by Jeff Melching <jm...@us.ibm.com>.
I am trying to select only the version column of an entity to see if it 
was changed. 

If I run the following JPQL where verId is the version field of my entity:

select a.verId from AnEntity a where a.id = ?1;

The generated sql is: 

SELECT  FROM AN_ENTITY t0 WHERE t0.ID = ? 

Obviously, this is invalid sql syntax as the columns to select are 
missing.  I am using a DB2 dictionary.