【发布时间】:2011-03-21 07:34:02
【问题描述】:
由于这个问题,我现在陷入了困境。如果我将持久性上下文定义为:
@PersistenceContext(unitName = "persistentUnit")
private EntityManager entityManager;
Glassfish 拒绝启动错误:
SEVERE: Could not resolve a persistence unit corresponding to the persistence-context-ref-name [com.ckd.business.MusicService/entityManager] in the scope of the module called [home]. Please verify your application.
但如果我将声明更改为:
e@PersistenceContext(name = "persistentUnit")
private EntityManager entityManager;
Glassfish 能够部署我的 WAR 文件,但是当我加载页面时,我得到了这个:
java.lang.IllegalStateException: Unable to retrieve EntityManagerFactory for unitName null
什么鬼?!我已根据要求将 persistence.xml 文件保存到 WEB-INF\classes\META-INF 目录,并看到 Glassfish 已正确加载 JPA。但不管我做什么,Glassfish 总是失败。我正在使用 Glassfish 3.1 开源版。
有人知道解决方案或解决方法吗?谢谢。
【问题讨论】: