I am using Wildfly 8.1 along with EJB Project objects (EJB 3.2) containing objects. When I try to inject Entity Manager into one of my Beans, I get the following:
JBAS011440: Can't find a persistence unit named null in deployment \"EntitiesProject.jar\""}, "JBAS014771: Services with missing/unavailable dependencies" => [ "jboss.deployment.unit.\"EntitiesProject.jar\".weld.weldClassIntrospector is missing [jboss.deployment.unit.\"EntitiesProject.jar\".beanmanager]", "jboss.naming.context.java.comp.EntitiesProject.EntitiesProject.MitarbeiterDAO.HandleDelegate is missing [jboss.naming.context.java.comp.EntitiesProject.EntitiesProject.MitarbeiterDAO]", "jboss.naming.context.java.comp.EntitiesProject.EntitiesProject.MitarbeiterDAO.InstanceName is missing [jboss.naming.context.java.comp.EntitiesProject.EntitiesProject.MitarbeiterDAO]", "jboss.naming.context.java.comp.EntitiesProject.EntitiesProject.MitarbeiterDAO.InAppClientContainer is missing [jboss.naming.context.java.comp.EntitiesProject.EntitiesProject.MitarbeiterDAO]", "jboss.naming.context.java.comp.EntitiesProject.EntitiesProject.MitarbeiterDAO.Validator is missing [jboss.naming.context.java.comp.EntitiesProject.EntitiesProject.MitarbeiterDAO]", "jboss.naming.context.java.comp.EntitiesProject.EntitiesProject.MitarbeiterDAO.ORB is missing [jboss.naming.context.java.comp.EntitiesProject.EntitiesProject.MitarbeiterDAO]", "jboss.naming.context.java.comp.EntitiesProject.EntitiesProject.MitarbeiterDAO.ValidatorFactory is missing [jboss.naming.context.java.comp.EntitiesProject.EntitiesProject.MitarbeiterDAO]" ]
This is my SessionBean, where I am trying to enter an EntityManager:
@Stateless public class MitarbeiterDAO implements MitarbeiterDAORemote { @PersistenceContext private EntityManager em; public int writeMitarbeiterToDB(Mitarbeiter m) { em.persist(m); return m.getId(); } }
I specified the following persistence.xml file, which I placed in "project-name" / ejbModule / META -INF.
<persistence-unit name="mitarbeiter"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <jta-data-source>java:jboss/datasources/MySqlDS</jta-data-source> <properties> <property-name="hibernate.hbm2ddl.auto" value="create-drop"/> </properties> </persistence-unit>
Related issues and solutions
- Cannot find persistence block suggests persistence.xml file included
- An entityManager injection in Wildfly / Jboss indicates that there may be a different directory to which my persistence.xml belongs. I tried this directory but still got the same error message.
- Cannot find persistence block from persistence.xml Although this is not quite the same question, the solution was to add a
<provider> to persistence.xml, but this also does not work for me
Update (see comments):
- I tried using @EntityManager(unitName="mitarbeiter") instead, just @EntityManager - The Bean session shown above is the only place I try to enter EntityManager
Update 2 (see comments for the answer):
persistence.xml is located in the directory Project/ejbModule/META-INF/- This directory is included in the build path.
- Somehow it does not deploy, and other files in the same directory (up to
jar/META-INF/ ). If I copy and paste it manually, it works. Why is this?
Any help and advice is appreciated.
java wildfly entitymanager
Jbartmann
source share