Glassfish 3.1.2 “Could not resolve a persistence unit corresponding to the persistence-context-ref-name”

a 夏天 提交于 2019-12-06 12:59:41

If busctrl.jar isn't a "deployed" component (containing EJBs) then move it into lib/busctrl.jar within the EAR file where it'll be visible on the classpath of the war file.

If it does contain EJBs, then some surgery needs to occur:

  • move EJBs definitions (implementations) into jar file(s) to be placed at the root level of the EAR file (/busEjb.jar).

  • move remote EJB declarations into their own JAR file to be placed in the EAR library (/lib/busEjbClient.jar).

  • move JPA entities & persistence.xml file into their own JAR file to be placed in the EAR library (/lib/busModel.jar).


Nothing in my review of the topic suggests that what you did in your original post shouldn't work in Glassfish, or other app servers. The class loader hierarchy should have made the persistence.xml file available.

That said, most discussions tend toward the best-practice of placing the persistence.xml file and entity classes into a separate library. I suspect this has to do with both the class loader hierarchy (possibly not a problem in this case) and with the internal search tooling to locate the persistence.xml file - which would be implemented by EclipseLink in this case. This discussion on EclipseLink may be relevant.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!