我想注入一個EM到一個Servlet中,持久化單元在EJB JAR中聲明。我有一個帶有EJB JAR和WAR的EAR。
的問題是,我得到這個錯誤:在Servlet中注入EntityManager?
Could not resolve a persistence unit corresponding to the persistence-context-ref-name [cvu.JpaServlet/em] in the scope of the module called
如果我把persistence.xml中它工作正常的戰爭,但我不想這樣做。
我可以從EJB JAR中聲明的PersistenceUnit(persistence.xml)獲取EntityManager嗎?
是的我知道,但我只是想測試它:)我會用ejb jar在war的classpath中嘗試這個東西.. Servlet確實看到了SessionBeans,爲什麼他看不到持久單元! –