Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jpa eclipse JUnit ClassNotFoundException org.hibernate.collection.internal.PersistentBag_Eclipse_Hibernate_Jpa_Junit_Jboss - Fatal编程技术网

jpa eclipse JUnit ClassNotFoundException org.hibernate.collection.internal.PersistentBag

jpa eclipse JUnit ClassNotFoundException org.hibernate.collection.internal.PersistentBag,eclipse,hibernate,jpa,junit,jboss,Eclipse,Hibernate,Jpa,Junit,Jboss,我很高兴看到以下场景: 课程 @javax.persistence.Entity(name = "attribute_values") public class AttributeValue { @javax.persistence.Id private long id; @javax.persistence.Column private String name; @javax.persistence.Column private String

我很高兴看到以下场景:

课程

@javax.persistence.Entity(name = "attribute_values")
public class AttributeValue {
    @javax.persistence.Id
    private long id;

    @javax.persistence.Column
    private String name;

    @javax.persistence.Column
    private String value;

    //.... Getters and Setters methods

}

@javax.persistence.Entity(name = "attributes")
public class Attribute {
    @javax.persistence.Id
    private long id;

    @javax.persistence.Column
    private String name;

    @OneToMany
    @JoinColumn(name = "product_attribute_id", referencedColumnName = "id")
    private java.util.List<AttributeValue> values = new java.util.ArrayList<AttributeValue>();

    //.... Getters and Setters methods

}

@javax.persistence.Entity(name = "products")
public class Product {
    @javax.persistence.Id
    private long id;

    @javax.persistence.Column
    private String name;

    @OneToMany
    @JoinTable(name = "attributes_by_product",
                            joinColumns ={ @JoinColumn(name = "product_id") },
                            inverseJoinColumns = { @JoinColumn(name = "attribute_id") })
    private java.util.List<Attribute> attributes = new java.util.ArrayList<Attribute>();


    //.... Getters and Setters methods
}

@javax.ejb.Remote
public interfaces ProductServices {
    public Product getProduct(long id);
}

@javax.ejb.Stateless
public class ProductServicesImpl implements ProductServices {

    @javax.persistence.PersistenceContext(unitName = "myPU")
    private javax.persistence.EntityManager entityManager;

    @Override
    public Product getProduct(long id) {
        return this.entityManager.find(Product.class, id);
    }
}
有人知道那里出了什么问题


谢谢大家

我解决了这个问题。我刚刚将Hibernate核心jar添加到我的类路径中。

看起来Hibernate不在类路径中,我修复了这个问题。谢谢Neeraj,我刚刚将hibertanet核心jar添加到我的类路径中。
Caused by: java.lang.ClassNotFoundException: org.hibernate.collection.internal.PersistentBag
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:249)
    at org.jboss.marshalling.AbstractClassResolver.loadClass(AbstractClassResolver.java:135)
    at org.jboss.marshalling.AbstractClassResolver.resolveClass(AbstractClassResolver.java:116)
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadClassDescriptor(RiverUnmarshaller.java:892)
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1204)
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:272)
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:209)
    at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1677)
    at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1593)
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1235)
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:272)
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:209)
    at org.jboss.marshalling.AbstractObjectInput.readObject(AbstractObjectInput.java:37)
    at org.jboss.ejb.client.remoting.MethodInvocationResponseHandler$MethodInvocationResultProducer.getResult(MethodInvocationResponseHandler.java:107)
    at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:270)
    at org.jboss.ejb.client.TransactionInterceptor.handleInvocationResult(TransactionInterceptor.java:47)
    at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:272)
    at org.jboss.ejb.client.ReceiverInterceptor.handleInvocationResult(ReceiverInterceptor.java:132)
    at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:260)
    at org.jboss.ejb.client.EJBClientInvocationContext.awaitResponse(EJBClientInvocationContext.java:399)
    at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:140)
    at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121)
    at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)
    ... 27 more