2 Replies Latest reply on Feb 21, 2017 8:06 AM by hdost

    Unable to find XML mapping file in classpath: orm.xml

    arnieaustin

      I am trying to get the orm.xml file recognized. It is stored in my projects' EJB-sub project /ejbModule/META-INF but it ends up in the WAR in WEB-INF/lib.

      Even so, i still get the error message:

      13:13:09,328 INFO [Configuration] Reading mappings from resource: orm.xml
      13:13:09,328 WARN [ServiceController] Problem starting service persistence.units:ear=DPSLicenseInquiry.ear,jar=DPSLicenseInquiryEJB.jar,unitName=PmgrDpsDrivers
      javax.persistence.PersistenceException: [PersistenceUnit: PmgrDpsDrivers] Unable to find XML mapping file in classpath: orm.xml


      WHY? Isn't WEB-INF/lib on the path? Where is the file governing the construction of the WAR and EAR while in Eclipse/JBoss IDE2.x? There's nothing in the build folders!

      The 2nd and possibly related error is:

      [ServiceController] Problem starting service jboss.j2ee:service=EJB3,module=DPSLicenseInquiryEJB.jar
      java.lang.RuntimeException: Field javax.persistence.EntityManager us.tx.state.oag.DPSLicenseInquiry.business.DpsDriversList.DpsLicenseDatabase @PersistenceUnit in error: EMPTY STRING unitName and there is more than one scoped persistence unit at oag.jboss.ejb3.injection.PersistenceContextHandler.loadFieldDependencies(PersistenceContextHandler.java:358)


      I don't see what the problem is:

      <persistence xmlns="http://java.sun.com/xml/ns/persistence"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
       version="1.0">
      
       <persistence-unit name="userDatabase">
       <provider>org.hibernate.ejb.HibernatePersistence</provider>
       <jta-data-source>java:/DPSLicenseInquiryDatasource</jta-data-source>
       <properties>
       <property name="hibernate.hbm2ddl.auto" value="create"/>
       <property name="hibernate.cache.use_query_cache" value="true"/>
       <property name="hibernate.show_sql" value="true"/>
       </properties>
       </persistence-unit>
      
       <persistence-unit name="PmgrDpsDrivers">
       <provider>org.hibernate.ejb.HibernatePersistence</provider>
       <jta-data-source>java:/dpsLicensedDrivers</jta-data-source>
       <mapping-file>orm.xml</mapping-file>
       <class>us.tx.state.oag.DPSLicenseInquiry.business.DpsDriver</class>
       <properties>
       <property name="hibernate.dialect" value="org.hibernate.dialect.SybaseDialect"/>
       </properties>
       </persistence-unit>
      
      </persistence>


      Another example had me add an entry to the components file:

      <components>
       <component name="DpsLicenseDatabase"
       class="org.jboss.seam.core.ManagedPersistenceContext">
       <property name="persistenceUnitJndiName">java:/EntityManagerFactories/PmgrDpsDrivers</property>
       </component>
      </components>