Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.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 EJB3实体类的单独jar_Jpa_Deployment_Ejb 3.0_Classnotfoundexception_Glassfish 2.x - Fatal编程技术网

Jpa EJB3实体类的单独jar

Jpa EJB3实体类的单独jar,jpa,deployment,ejb-3.0,classnotfoundexception,glassfish-2.x,Jpa,Deployment,Ejb 3.0,Classnotfoundexception,Glassfish 2.x,当我从EJB模块中分离EJB3实体(用@Entity注释)并将它们放在一个单独的jar文件中时,Persistence.xml文件应该放在哪里,在EJB模块中还是在entities.jar中?我应该如何部署entities.jar文件?它不是EJB模块,因为它没有任何EJB,只有JPA实体 我使用的是Glassfish,我所做的是,将entities.jar放在/lib/applibs目录中,在部署EJB模块时,我声明它使用该库 但部署失败,原因是: Internal Exception: ja

当我从EJB模块中分离EJB3实体(用@Entity注释)并将它们放在一个单独的jar文件中时,Persistence.xml文件应该放在哪里,在EJB模块中还是在entities.jar中?我应该如何部署entities.jar文件?它不是EJB模块,因为它没有任何EJB,只有JPA实体

我使用的是Glassfish,我所做的是,将entities.jar放在/lib/applibs目录中,在部署EJB模块时,我声明它使用该库

但部署失败,原因是:

Internal Exception: java.lang.ClassNotFoundException: com.pedra.Role
javax.persistence.PersistenceException: Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.1 (Build b31g-fcs (10/19/2009))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
Exception Description: predeploy for PersistenceUnit [SignonPU] failed.
Internal Exception: Exception [TOPLINK-30007] (Oracle TopLink Essentials - 2.1 (Build b31g-fcs (10/19/2009))): oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while loading class: com.pedra.Role to check whether it implements @Entity, @Embeddable, or @MappedSuperclass.
Internal Exception: java.lang.ClassNotFoundException: com.pedra.Role

那么,为什么在entities.jar库中找不到这个类呢?

在persistence.xml中,可以包含包含实体的jar,如下所示。您可以通过指定相对或绝对路径来包含jar。您可以将它与其他库一起包含在应用程序EAR中,并提及相对路径,这是推荐的

somejar.jar


配置文件应该在EJB模块的META-INF中。

它看起来应该可以正常工作

我想说:

  • 检查entity.jar是否实际位于lib/applibs中
  • 检查部署EJB模块时是否正确指定了entity.jar
  • 重建你的罐子
  • 听起来很有趣,通过管理控制台取消部署ejb模块,重新启动Glassfish,然后再次部署模块
我删除了类名列表,并按照您的建议包含了jar的名称,但我得到了相同的错误。这很有趣,因为它就像glassfish找到了jar,在jar中找到了带注释的类,然后声称找不到该类。