4 Replies Latest reply on Jan 3, 2013 8:40 AM by jjfraney

    can jboss as7.1 recognize and deploy a JPA-entity-only sub-deployment?

    jjfraney

      In my app, I have a jar file with jpa entities only, and another jar with ejb beans.  The ejb beans references classes in the entities jar.  The deploy fails.  The references to the entities are not resolved.

       

      john@isidore:~/projects/sdp-model/sdp-model-ear/target$ jar tvf sdp-model-ear-2.0.5.4-SNAPSHOT.ear

           0 Wed Jan 02 17:19:48 EST 2013 META-INF/

         123 Wed Jan 02 17:19:46 EST 2013 META-INF/MANIFEST.MF

           0 Wed Jan 02 13:12:06 EST 2013 lib/

         124 Wed Jan 02 17:19:46 EST 2013 META-INF/jboss-deployment-structure.xml

         149 Wed Jan 02 17:19:46 EST 2013 META-INF/jboss-classloading.xml

      172830 Wed Jan 02 13:12:06 EST 2013 lib/jasypt-1.7.1.jar

      129522 Wed Jan 02 13:12:06 EST 2013 lib/usertype.core-3.0.0.GA.jar

      12342 Wed Jan 02 16:01:02 EST 2013 lib/sdp-model-constraints-2.0.5.4-SNAPSHOT.jar

      51479 Wed Jan 02 13:12:06 EST 2013 lib/usertype.spi-3.0.0.GA.jar

      46123 Wed Jan 02 13:12:06 EST 2013 lib/jasypt-hibernate4-1.9.0.jar

      570478 Wed Jan 02 13:12:06 EST 2013 lib/joda-time-2.1.jar

      187495 Wed Jan 02 16:01:02 EST 2013 sdp-model-entities-2.0.5.4-SNAPSHOT.jar

      33012 Wed Jan 02 17:19:46 EST 2013 sdp-model-beans-2.0.5.4-SNAPSHOT.jar

           0 Wed Jan 02 17:19:48 EST 2013 META-INF/maven/

           0 Wed Jan 02 17:19:48 EST 2013 META-INF/maven/xxxxxxxxx/

           0 Wed Jan 02 17:19:48 EST 2013 META-INF/maven/xxxxxxxxx/sdp-model-ear/

        2289 Wed Jan 02 13:09:20 EST 2013 META-INF/maven/xxxxxxxxx/sdp-model-ear/pom.xml

         134 Wed Jan 02 17:19:46 EST 2013 META-INF/maven/xxxxxxxxx/sdp-model-ear/pom.properties

       

      I tried different settings in jboss-deployment-structure.xml and none worked, so, I decided to deploy the same as above WITHOUT the ejb beans module (a deployable named test.ear).  The deploy succeeds, but the log file does not show that sdp-model-entities was deployed or even seen.  This tells me that jboss does not recognize the sdp-model-entities.jar sub-deployment.  Why?

       

      john@isidore:~/projects/sdp-model/sdp-model-ear/target$ jar tvf test.ear

           0 Wed Jan 02 19:47:02 EST 2013 META-INF/

          71 Wed Jan 02 19:47:02 EST 2013 META-INF/MANIFEST.MF

         124 Wed Jan 02 17:19:46 EST 2013 META-INF/jboss-deployment-structure.xml

           0 Wed Jan 02 17:19:48 EST 2013 META-INF/maven/

           0 Wed Jan 02 17:19:48 EST 2013 META-INF/maven/xxxxxxxxx/

           0 Wed Jan 02 17:19:48 EST 2013 META-INF/maven/xxxxxxxxx/sdp-model-ear/

        2289 Wed Jan 02 13:09:20 EST 2013 META-INF/maven/xxxxxxxxx/sdp-model-ear/pom.xml

         134 Wed Jan 02 17:19:46 EST 2013 META-INF/maven/xxxxxxxxx/sdp-model-ear/pom.properties

         149 Wed Jan 02 17:19:46 EST 2013 META-INF/jboss-classloading.xml

           0 Wed Jan 02 13:12:06 EST 2013 lib/

      172830 Wed Jan 02 13:12:06 EST 2013 lib/jasypt-1.7.1.jar

      129522 Wed Jan 02 13:12:06 EST 2013 lib/usertype.core-3.0.0.GA.jar

      12342 Wed Jan 02 16:01:02 EST 2013 lib/sdp-model-constraints-2.0.5.4-SNAPSHOT.jar

      51479 Wed Jan 02 13:12:06 EST 2013 lib/usertype.spi-3.0.0.GA.jar

      46123 Wed Jan 02 13:12:06 EST 2013 lib/jasypt-hibernate4-1.9.0.jar

      570478 Wed Jan 02 13:12:06 EST 2013 lib/joda-time-2.1.jar

      187495 Wed Jan 02 16:01:02 EST 2013 sdp-model-entities-2.0.5.4-SNAPSHOT.jar

       

       

      Attached is a log file from this attempt.

       

      The sdp-model-entities has jpa entity classes (java classes marked with @Entity), no javax.ejb annotations, no @PersistenceContext, and a persistence.xml file.

       

      Thanks,

      John

        • 1. Re: can jboss as7.1 recognize and deploy a JPA-entity-only sub-deployment?
          jaikiran

          Move the entities jar to .ear/lib folder and it'll be available in the classpath of all subdeployments of that .ear.

          • 2. Re: can jboss as7.1 recognize and deploy a JPA-entity-only sub-deployment?
            nickarls

            According to the docs

             

            The persistence.xml contains the persistence unit configuration (e.g. datasource name) and as described in the JPA 2.0 spec (section 8.2), the jar file or directory whose META-INF directory contains the persistence.xml file is termed the root of the persistence unit. In Java EE environments, the root of a persistence unit must be one of the following (quoted directly from the JPA 2.0 specification):

            • an EJB-JAR file
            • the WEB-INF/classes directory of a WAR file
            • a jar file in the WEB-INF/lib directory of a WAR file
            • a jar file in the EAR library directory
            • an application client jar file

             

            One would think that if you have beans.jar and entities.jar both in the EAR lib and a persistence.xml in the beans.jar/META-INF/persistence.xml, they would be picked up (without need for jboss-specific xml files)

            1 of 1 people found this helpful
            • 3. Re: can jboss as7.1 recognize and deploy a JPA-entity-only sub-deployment?
              nickarls

              (I need to start refreshing my page opened with "open i new tab" before replying) ;-)

              • 4. Re: can jboss as7.1 recognize and deploy a JPA-entity-only sub-deployment?
                jjfraney

                You are both right, Jaikiran most concise. Thanks to Nicklas for pointing out the error of my base assumption: that deployment structures in jboss as6, or earlier, may would be permitted in as7.  He is right to put my attention on the spec.  The note in the section 8.2 is spot on, and gives the back-story to Jaikiran's contribution.

                 

                NOTE: Java Persistence 1.0 supported use of a jar file in the root of the EAR as the root of a

                persistence unit. This use is no longer supported. Portable applications should use the EAR

                library directory for this case instead. See [9].

                 

                 

                Thanks to both.