Is anyone successfully using OpenJPA with Glassfish?
I m trying to use OpenJPA 2.1 with Glassfish 3.1 Open Source. I ve followed the instructions to integrate the two here -> http://weblogs.java.net/blog/ss141213/archive/2006/07/using_openjpa_a.html
我在Eclipse Indigo有一个非常简单的EJB项目,其内容如下:
- com.rares.test.Person - @Entity
- com.rares.test.PersonManager - interface
- com.rares.test.PersonDao - @Stateless
However, when I try to deploy I get a ClassNotFoundException on my Person @Entity. The complaint seems to be the Person parm on a create method that s being implemented in my PersonDao (see all code below).
我在尝试同一项目时,没有具体说明一个供应商,而项目则进行罚款(可能坚持一个个人@Entity to a PERSON table in MySql)。 我认为,如果我没有具体说明提供者,那么我会使用EclipseLink(如果我错了,请更正我)。 这使我相信,我把开放JPA与玻璃鱼混为一谈。
Stack Trace
Caused by: java.lang.IllegalArgumentException: java.lang.ClassNotFoundException: com.rares.test.Person
at serp.util.Strings.toClass(Strings.java:164)
at serp.util.Strings.toClass(Strings.java:108)
at serp.bytecode.BCClass.getType(BCClass.java:566)
at org.apache.openjpa.enhance.PCEnhancer.<init>(PCEnhancer.java:283)
at org.apache.openjpa.enhance.PCEnhancer.<init>(PCEnhancer.java:254)
at org.apache.openjpa.enhance.PCClassFileTransformer.transform0(PCClassFileTransformer.java:144)
at org.apache.openjpa.enhance.PCClassFileTransformer.transform(PCClassFileTransformer.java:124)
at org.apache.openjpa.persistence.PersistenceProviderImpl$ClassTransformerImpl.transform(PersistenceProviderImpl.java:294)
at org.glassfish.persistence.jpa.ServerProviderContainerContractInfo$1.transform(ServerProviderContainerContractInfo.java:98)
at com.sun.enterprise.loader.ASURLClassLoader.findClass(ASURLClassLoader.java:742)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
at java.lang.Class.privateGetPublicMethods(Class.java:2547)
at java.lang.Class.getMethods(Class.java:1410)
at com.sun.enterprise.deployment.EjbDescriptor.addAllInterfaceMethodsIn(EjbDescriptor.java:2327)
at com.sun.enterprise.deployment.EjbDescriptor.getLocalRemoteBusinessMethodDescriptors(EjbDescriptor.java:2290)
... 40 more
com.rares.test.Person
@Entity
@Table (name="PERSON")
public class Person implements Serializable {
private static final long serialVersionUID = 3707476467775531463L;
@Id
@GeneratedValue (strategy=GenerationType.IDENTITY)
@Column private Long id;
@Column private String name;
com.rares.test.PersonManager
public interface PersonManager {
void create (com.rares.test.Person p);
}
com.rares.test.PersonDao
@Stateless
public class PersonDao implements PersonManager {
@PersistenceContext (unitName="RarePersistUnit")
protected EntityManager mgr;
@Override
public void create(com.rares.test.Person p) {
mgr.persist(p);
}
}
persistence.xml
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="RarePersistUnit">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<jta-data-source>jdbc/RaresMySql</jta-data-source>
<class>com.rares.test.Person</class>
<properties>
</properties>
</persistence-unit>
</persistence>