[jboss-user] [EJB 3.0 Users] - 5.1 - @PersistenceUnit fails to resolve in Servlet when EJB

genman do-not-reply at jboss.com
Sun Sep 20 14:37:43 EDT 2009

JBoss AS 5.1

Servlet code:

public class Servlet extends HttpServlet {
  |     @PersistenceUnit
  |     private EntityManagerFactory emf;

I created a persistence.xml file and included it a separate EJB .jar file in a .ear file. Things were working fine until I added some EJBs in the persistence.xml containing .jar, and this error started coming up:

  | 11:34:43,802 ERROR [StandardContext] Context [/mlp] startup failed due to previous errors
  | java.lang.IllegalArgumentException: Container org.jboss.web.tomcat.service.TomcatInjectionContainer at 1662fdd failed to resolve persistence unit null
  | 	at org.jboss.injection.PersistenceUnitHandler.addPUDependency(PersistenceUnitHandler.java:135)
  | 	at org.jboss.injection.PersistenceUnitHandler.loadXml(PersistenceUnitHandler.java:75)

Is there some reason the persistence unit is "lost" when EJBs are declared within the same .jar file?

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4256063#4256063

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4256063

More information about the jboss-user mailing list