4 Replies Latest reply on Jan 18, 2017 2:43 PM by Сергей Коваленко

    wildfly 9, deploy, resource path

    Сергей Коваленко Newbie

      I have src/main/resources/META-INF/*.hbm.xml in my gradle.build file

      sourceSets.main.output.resourcesDir = sourceSets.main.output.classesDir

      wher I run it: gradle run, it works,

      but when I try deploy it to wildfly 9, I get error: java.lang.IllegalArgumentException: Unknown entity: my.mapping.myobj

      For gradle run "java.class.path" contains this path

      ***/build/classes/main

      But for wildfly "java.class.path" contains only this path

      /home/***/servers/wildfly-9.0.1.Final/jboss-modules.jar

      I'm create jboss-deployment-structure.xml

      <jboss-deployment-structure> <deployment> <dependencies> </dependencies> <resources> <resource-root path="."/> </resources> </deployment> </jboss-deployment-structure>

      And put it in war /WEB-INF/, but I have same problem. How to fix it? Thanks

        • 1. Re: wildfly 9, deploy, resource path
          Anup Dey Apprentice

          Hi,

           

          double check persistence.xml and the datasource, everything must be well configured and compatible

          check that there is no unqualified entity name duplication (same entity name but different package)

           

          For org.hibernate.MappingException: Unknown entity:my.mapping.myobj

           

          If user is using only Hibernate API not JPA API in application then check hibernate.cfg.xml file

          It seems user didn't have configure mapping for the object my.mapping.myobj.

          The configuration file hibernate.cfg.xml should contain the mapping to the resource <EntityTest.hbm.xml.

           

          In hibernate.cfg.xml user need to configure:

           

          <mapping resource=".../EntityTest.hbm.xml"/>

           

          In persistence.xml, transaction-type must be set to RESOURCE_LOCAL (default being JTA). Furthermore, the datasource is non JTA, use of

           

          <non-jta-data-source>java:/repository_hibernate</non-jta-data-source>

           

          In case you want to use JTA it should have to:

           

          either use Container Managed Transaction (CMT) session bean.

          or manually use the UserTransaction (jndi look up).

           

          Check whether table name, database name are properly mapped or  not in all Entity classes. Also check Hibernate with DB related jars whether it is compatible or not.

          1 of 1 people found this helpful
          • 2. Re: wildfly 9, deploy, resource path
            Сергей Коваленко Newbie

            My suggestions must be right, but my project is mostly annotation-based and I'm also using springboot, so I don't have hibernate.cfg.xml or persistence.xml.

            But I bumped into special case which can not be covered with annotations and this is the reason why I use EntityTest.hbm.xml mapping (it's all about multimaps mapping, see https://hibernate.atlassian.net/browse/HHH-4417).

            My project successfully starts with embedded tomcat by gradle run (so there is no problem with hibernate or JPA), but when I try to run on wildfly, I have unknown entity exception.

             

            Well, all in all, I think there is a problem on the wildfly side (wildfly don't see resourses path).

            • 3. Re: wildfly 9, deploy, resource path
              Anup Dey Apprentice

              Hi,

               

              - Which version of Hibernate you're using?

              - How are you using Hibernate? Are you packing your own hibernate jars in your application or are you using the specific version of Hibernate bundled/shipped with the specific wildfly 9 release?

              • 4. Re: wildfly 9, deploy, resource path
                Сергей Коваленко Newbie

                - hibernate 4.3.1-Final

                - spring boot is responsible for dependencies in our application, so hibernate is  already packed in our application.

                Now our problem is temporary solved by using embedded tomcat.