5 Replies Latest reply on Mar 20, 2013 7:39 AM by smarlow

    jar-file problem in persistence.xml

    anikulin

      Hi

       

      I'm trying to add jar-file with annotated entity files to my persistence.xml in another jar. My current persistence.xml is in META-INF folder and looks like these:

       

      <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_2_0.xsd"

          version="2.0">

          <persistence-unit name="indicators_service"

              transaction-type="RESOURCE_LOCAL">

              <provider>org.hibernate.ejb.HibernatePersistence</provider>

              <jta-data-source>java:/PostgreDB/indicators_service</jta-data-source>

              <jar-file>models.jar</jar-file>

              <class>com.magick.models.IndicatorContainer</class>

              <class>com.magick.models.Indicator</class>

              <class>com.magick.models.Type</class>

              <properties>

                  <property name="hibernate.show_sql" value="false" />

                  <property name="hibernate.format_sql" value="false" />

                  <property name="hibernate.connection.useUnicode" value="true" />

                  <property name="hibernate.connection.characterEncoding"

                      value="UTF-8" />

                  <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />

                  <property name="hibernate.hbm2ddl.auto" value="update" />

                  <property name="hibernate.transaction.jta.platform"

                      value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform" />

              </properties>

          </persistence-unit>

      </persistence>

       

       

      But wheni try to deploy this jar on AS7 i have such exception:
      18:57:26,794 WARN  [org.hibernate.ejb.packaging.FileZippedJarVisitor] (MSC service thread 1-1) HHH015010: Unable to find file (ignored): file:models.jar: java.io.FileNotFoundException: models.jar (The system cannot find the file specified)

       

      And in trace logs i can see the following:

       

      18:57:24,929 DEBUG [org.hibernate.ejb.Ejb3Configuration] (MSC service thread 1-3) Processing PersistenceUnitInfo [

      ...

      Jar files URLs [

              vfs:/D:/Programming/switchyard-as7-0.5/bin/content/models-0.0.1-SNAPSHOT.jar]
      ...

      ]

       

      18:57:26,771 TRACE [org.hibernate.ejb.Ejb3Configuration] (MSC service thread 1-1) PersistenceMetadata(version=2.0) [
      ...

      jarFiles[

              models-0.0.1-SNAPSHOT.jar

          ]
      ...
      ]

       

       

      I've places this model.jar into META-INF folder of the main jar and into META-INF/lib folder but this didn't give any progre

       

      Can you help me where should i place my model.jar for it to be visible from my main jar?
      And is it possible to specify a reference to a jar-file that is in as7/modules folder in persistence.xml

       

      Thanks, Anton

        • 1. Re: jar-file problem in persistence.xml
          th.janssen

          Hi Anton,

           

          you need to define the dependency to modules.jar and place both jars in the deployment directory. One option to do this is to add a Dependencies entry in the MANIFEST.MF of your main jar. Here you can find more detailed information about class loading: https://docs.jboss.org/author/display/AS7/Class+Loading+in+AS7

           

          Another option would be to add all jars as modules to an ear. That is what we are doing in our application...

           

          You might also check the name of your jar file. You are referencing modules.jar but it looks like the file name contains the version number (models-0.0.1-SNAPSHOT.jar).

           

          Regards,

          Thorben

          • 2. Re: jar-file problem in persistence.xml
            anikulin

            Thanks Thorben

             

            models.jar is defined as module in modules folder, and main jar has a dependency to it. So models.jar is in classpath, but i can't reach  it in persistence.xml.

             

            I've tried to do what you said - to add models.jar to deployments folder and specify it in manifest. I added to Manifest Dependencies models or models.jar, but it alsi didn't help. It can't find it a

             

            I know that i can do this with ear file, but is it possible to add depency on some other jar in persistence.xml using only jars?

            • 3. Re: jar-file problem in persistence.xml
              nickarls

              The JPA 2 spec has 6-7 examples in it (mostly conserning EARs) and in some cases there are ../lib references which would indicate physical relevance, don't know how the JBoss Modules works with that...

              • 4. Re: jar-file problem in persistence.xml
                th.janssen

                Can you please post the log, the MANIFEST.MF of your main.jar and the names of the jars in the deployments folder.

                • 5. Re: jar-file problem in persistence.xml
                  smarlow

                  Also, don't forget to enable TRACE logging (org.jboss.as.jpa), to see if the output helps you at all. 

                   

                  Also, separate deployments cannot currently share persistence units (each deployment is isolated in VFS).  Sub-deployments in an Ear, can see each other, not that we are talking about an EAR deployment here.