Hi Pinaki,

  Thanks for the reply.

1. I am using the default so the classes are overwritten. I can tell that
because, after the enhancer runs successfully the first time, I can see that
the class files get larger. There aren't any other versions of that class in
the classpath. Here's my project structure:

/java
  /bean/core/     (.java files and orm.xml files)
  /bean/system/
  /bean/workflow/
  /driver
  /META-INF/persistence.xml
/webroot
  /WEB-INF
    /classes      (where the class files are generated and
META-INF/persistence.xml is copied when building)
    /lib
      mysql-connector-java-5.1.6-bin.jar
      openjpa-all-2.0.0-beta3.jar
    web.xml

2. The log didn't help me a lot. This is what I got:

$ ant enhance
Buildfile: build.xml

enhance:
 [openjpac] 94  openjpa  INFO   [main] openjpa.Tool - No targets were given. 
Ru
nning on all classes in your persistent classes list, or all metadata files
in c
lasspath directories if you have not listed your persistent classes.  Use
-help
to display tool usage information.
 [openjpac] 94  openjpa  TRACE  [main] openjpa.Tool - Enhancer running on
type "
bean.system.User".
 [openjpac] java.lang.IllegalArgumentException:
java.lang.ClassNotFoundException
: bean.system.User
 [openjpac]     at serp.util.Strings.toClass(Strings.java:164)
 [openjpac]     at serp.util.Strings.toClass(Strings.java:108)
 [openjpac]     at serp.bytecode.BCClass.getType(BCClass.java:566)
 [openjpac]     at
org.apache.openjpa.enhance.PCEnhancer.<init>(PCEnhancer.java:
256)
 [openjpac]     at
org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:465
3)
 [openjpac]     at
org.apache.openjpa.ant.PCEnhancerTask.executeOn(PCEnhancerTas
k.java:89)
 [openjpac]     at
org.apache.openjpa.lib.ant.AbstractTask.execute(AbstractTask.
java:171)
 [openjpac]     at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.ja
va:288)
 [openjpac]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
 [openjpac]     at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcces
sorImpl.java:39)
 [openjpac]     at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet
hodAccessorImpl.java:25)
 [openjpac]     at java.lang.reflect.Method.invoke(Method.java:597)
 [openjpac]     at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchU
tils.java:105)
 [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.jav
a:1329)
 [openjpac]     at
org.apache.tools.ant.Project.executeTarget(Project.java:1298)

 [openjpac]     at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(De
faultExecutor.java:41)
 [openjpac]     at
org.apache.tools.ant.Project.executeTargets(Project.java:1181
)
 [openjpac]     at org.apache.tools.ant.Main.runBuild(Main.java:698)
 [openjpac]     at org.apache.tools.ant.Main.startAnt(Main.java:199)
 [openjpac]     at
org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
 [openjpac]     at
org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)

BUILD FAILED
c:\Documents and Settings\rsantos\workspace_jpa\openjpa\build.xml:32:
java.lang.
IllegalArgumentException: java.lang.ClassNotFoundException: bean.system.User

Total time: 0 seconds

Just a note: if I try to run the enhancer with no classes in
webroot/WEB-INF/classes, I get a different message: "Found no class to
enhance".

3. The only jars I have in the project are the openjpa and mysql connector
jars.

 
Is there anything wrong with my class/mapping? My bean.system.User class:

package bean.system;

import java.io.Serializable;

public class User {
    private String userId;
    private String name;

    public User() {
    }

    protected User(String userId, String name) {
        this.userId = userId;
        this.name = name;
    }

    public static User createUser(String userId, String name) {
        return new User(userId, name);
    }

    public static class UserId implements Serializable {
        static {
            // register persistent class in JVM
            try {
                Class.forName("bean.system.User");
            } catch (Exception e) {
            }
        }

        public String userId;

        public UserId(String userId) {
            this.userId = userId;
        }

        public UserId() {
            this.userId = "";
        }

        public String toString() {
            return userId;
        }

        public boolean equals(Object object) {
            return object instanceof UserId
                && ((UserId) object).userId.equals(userId);
        }

        public int hashCode() {
            return userId.hashCode();
        }
    }

    public String getName() {
        return name;
    }

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

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

}

The orm.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"; 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
        xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm 
orm_2_0.xsd"
version="2.0">
    <package>
        bean.system
    </package>
    <access>
        FIELD
    </access>

    <entity class="bean.system.User">
        <table name="users"/>
        <id-class class="bean.system.User$UserId"/>
        <attributes>
            <id name="userId" />
            <basic name="name"/>
        </attributes>
        </entity>
        
</entity-mappings>


  Thanks in advance,

  Rute

-- 
View this message in context: 
http://openjpa.208410.n2.nabble.com/ClassNotFoundException-in-PCEnhancerTask-when-class-has-already-been-enhanced-tp5010582p5014297.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to