14 Replies Latest reply on Jan 15, 2010 7:40 AM by jaikiran

    Issue specifying the <jar-file> in persistence.xml in JBOSS 5 on linux system

      Hello,

       

      My application deploys without any errors in JBOSS 5.1.0GA on a windows system but it fails when deployed in JBOSS 5.1.0GA on Red Hat 5.1.

      This is my ear file structure:

       

      myapp.ear
      +- lib/
      | +- extejbmodule.jar
      | +- ...
      +- META-INF/
      | +- persistence.xml
      | +- ...
      +- myseammodule.jar
      +- mywebmodule.war
      +- ...

       

      Right now the myseammodule.jar also contains the JPA entity mappings and I added the <jar-file> tag to my persistence.xml to have this jar scanned for mappings. The persistence.xml looks like this:

       

      <?xml version="1.0" encoding="UTF-8"?>
      <!-- Persistence deployment descriptor for prod profile -->
      <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="myapppu">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <jta-data-source>java:/jdbc/myAppDS</jta-data-source>
            <jar-file>myapp.ear/myseammodule.jar</jar-file>
            <properties>
               <property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect"/>
               <property name="hibernate.hbm2ddl.auto" value="none"/>
               <property name="hibernate.show_sql" value="true"/>
               <property name="hibernate.jdbc.batch_size" value="20"/>
               <property name="jboss.entity.manager.factory.jndi.name" value="java:/myappEntityManagerFactory"/>
            </properties>
         </persistence-unit>
          
      </persistence>
      
      

       

      When the ear is deployed on JBOSS 5.1.0GA on a linux system (Red Hat 5.1) the server throws an error:

       

          2010-01-11 09:31:38,554 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] (HDScanner) Error installing to Start: name=persistence.unit:unitName=myapp.ear/#myapppu state=Create
          java.lang.RuntimeException: could not find relative path: myapp.ear/myseammodule.jar
               at org.jboss.jpa.deployment.PersistenceUnitDeployment.getRelativeURL(PersistenceUnitDeployment.java:208)
               at org.jboss.jpa.deployment.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:267)
               at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)


      ...


      DEPLOYMENTS IN ERROR:
            Deployment "<UNKNOWN jboss.j2ee:ear=myapp.ear,jar=myapp.ear,name=Server,service=EJB3>" is in error due to the following reason(s): ** UNRESOLVED Demands 'persistence.unit:unitName=myapp.ear/#myapppu' **
            Deployment "persistence.unit:unitName=myapp.ear/#myapppu" is in error due to the following reason(s): java.lang.RuntimeException: could not find child 'myapp.ear\myapppu.jar' on 'DelegatingHandler@1179491551[path= context=file:/usr/local/jboss-5.1.0.GA/server/default/tmp/a3p5u2o-ls1ivl-g4bbjti5-1-g4bcqt45-as/myapp.ear real=vfszip:/usr/local/jboss-5.1.0.GA/server/default/tmp/a3p5u2o-ls1ivl-g4bbjti5-1-g4bcqt45-as/myapp.ear]'    

       

      One note, the Server bean is from extejbmodule.jar (I'm not sure if this is important).

       

      Any ideas why this configuration doesn't work on the linux system?

       

      Thank you,

      Dragos

        • 1. Re: Issue specifying the <jar-file> in persistence.xml in JBOSS 5 on linux system
          peterj

          I think that the issue has to do with the application.xml file. Look at this part of the error message:

           

          dbobes wrote

           

          java.lang.RuntimeException: could not find child 'myapp.ear\myapppu.jar'

          Note the '\' instead of a '/'.

          • 2. Re: Issue specifying the <jar-file> in persistence.xml in JBOSS 5 on linux system

            Hi Peter,

             

            Thank you for your quick reply.

            That backslash "\" is a mistake made by me when I was editing the post trying to anonymize the application names. In the log file the entry has a forward slash:

             

                java.lang.RuntimeException: could not find child 'myapp.ear/myapppu.jar'

             

             

            Sorry for the confusion.

             

            Dragos

            • 3. Re: Issue specifying the <jar-file> in persistence.xml in JBOSS 5 on linux system
              peterj

              Try removing the "myapp.ear/" from the <jar-file> entry. That entry should specify a location relative to the base directory of the persistence unit, which is one directory level higher than the location of the persistence.xml file.

               

              If that does not work, you might have to place the persistence.xml file into the myseamapp.jar (that is where I have always placed it; I never tried just putting it into the EAR file).

              • 4. Re: Issue specifying the <jar-file> in persistence.xml in JBOSS 5 on linux system

                I need to put the persistence.xml in ear's META-INF so I can extend the scope of the persistence unit to the entire ear because I am using it in the externalejbmodule.jar (see Persistence unit issues when migrating to JBOSS 5.1.0).

                 

                I removed the name of the ear from the path ('<jar-file>myejbmodule.jar</jar-file>') and now it works fine on linux but it fails on windows.

                These are the windows log entries:

                 

                11:55:02,097 DEBUG [AbstractInjectionValueMetaData] persistence.unit:unitName=myapp.ear/#myapppu: Contextual injection usage (class -> classloader): interface org.jboss.jpa.spi.XPCResolver -> BaseClassLoader@bd4dc2{vfsfile:/C:/work/tools/jboss-5.1.0.GA/server/default/conf/jboss-service.xml} defined by AbstractPropertyMetaData@117065b{name=XPCResolver value=AbstractInjectionValueMetaData@a27851{value=null injectionType=BY_CLASS propertyMetaData=XPCResolver}}
                11:55:02,113 INFO  [PersistenceUnitDeployment] Starting persistence unit persistence.unit:unitName=myapp.ear/#myapppu
                11:55:02,113 ERROR [AbstractKernelController] Error installing to Start: name=persistence.unit:unitName=myapp.ear/#myapppu state=Create
                java.lang.RuntimeException: could not find relative path: myejbmodule.jar
                    at org.jboss.jpa.deployment.PersistenceUnitDeployment.getRelativeURL(PersistenceUnitDeployment.java:208)
                    at org.jboss.jpa.deployment.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:267)
                    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                
                ...
                
                DEPLOYMENTS IN ERROR:
                  Deployment "<UNKNOWN jboss.j2ee:ear=myapp.ear,jar=myapp.ear,name=Server,service=EJB3>" is in error due to the following reason(s): ** UNRESOLVED Demands 'persistence.unit:unitName=myapp.ear/#myapppu' **
                  Deployment "persistence.unit:unitName=myapp.ear/#myapppu" is in error due to the following reason(s): java.lang.RuntimeException: could not find child 'myejbmodule.jar' on 'FileHandler@24117815[path= context=file:/C:/work/tools/jboss-5.1.0.GA/server/default/deploy/ real=file:/C:/work/tools/jboss-5.1.0.GA/server/default/deploy/]'
                
                

                 

                Is there a way to have this configuration work on both environments?

                • 5. Re: Issue specifying the <jar-file> in persistence.xml in JBOSS 5 on linux system

                  After a lot of trial and error I discovered that it deploys without errors if I remove the seam module from application.xml.

                  So in persistence.xml I have:

                   

                  ....
                  <jar-file>myapp.ear/myejbmodule.jar</jar-file>
                  ...

                   

                  In application.xml:

                   

                  <?xml version="1.0" encoding="UTF-8"?>
                  <application xmlns="http://java.sun.com/xml/ns/javaee" 
                               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                               xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd"
                               version="5">
                      <display-name>myapp</display-name>
                      <module>
                        <web>
                           <web-uri>myapp.war</web-uri>
                           <context-root>/myapp</context-root>
                        </web>
                     </module>
                     <module>
                        <ejb>myejbmodule.jar</ejb>
                     </module>
                  
                     <!-- Seam and EL
                     <module>
                         <ejb>jboss-seam.jar</ejb>
                     </module>     -->
                  </application>
                  

                   

                  Has anyone else ran into this issue before? I uploaded two ear files, one with the seam module defined that doesn't deploy on linux and the other one without the seam module that deploys without any errors.The ear requires a dummy data source named "jdbc/myappDS".

                   

                  Thanks,

                  Dragos

                  • 6. Re: Issue specifying the <jar-file> in persistence.xml in JBOSS 5 on linux system
                    jaikiran

                    dbobes wrote:

                     

                    After a lot of trial and error I discovered that it deploys without errors if I remove the seam module from application.xml.

                    So in persistence.xml I have:

                     

                    ....
                    <jar-file>myapp.ear/myejbmodule.jar</jar-file>
                    ...

                     

                    Where exactly is myejbmodule.jar located? From your first post, i don't see it being present. Is it the same as the one in .ear/lib/extejbmodule.jar? In general if the jar is present at the root of the ear, then the jar-file element should be:

                     

                    <jar-file>myejbmodule.jar</jar-file>
                    
                    • 7. Re: Issue specifying the <jar-file> in persistence.xml in JBOSS 5 on linux system

                      It is in the root of the ear file. In fact in my examples myseammodule.jar = myejbmodule.jar but I lost track of the name I used during my trials.

                      If I specify directly the jar file it works fine on the linux system but it doesn't work in windows anymore.

                       

                      ....
                      <jar-file>myejbmodule.jar</jar-file>
                      ...

                       

                      You can use the first file I uploded in the previous reply (myapp.ear_without_seam_lib.zip) to test this issue. Just modify the persistence.xml and you'll see that jboss on windows doesn't like this path specification.

                      • 8. Re: Issue specifying the <jar-file> in persistence.xml in JBOSS 5 on linux system
                        jaikiran

                        I don't have access to a Windows system. Could you please upload the entire server.log and boot.log from the windows system where this exception occurs?

                        • 9. Re: Issue specifying the <jar-file> in persistence.xml in JBOSS 5 on linux system

                          I uploaded the server.log and boot.log when the <jar-file> tag was specified without the ear information.

                           

                          <jar-file>myejbmodule.jar</jar-file>
                          
                          • 10. Re: Issue specifying the <jar-file> in persistence.xml in JBOSS 5 on linux system
                            jaikiran

                            Looking at the logs, i see what's happening. Although i don't have an good explanation on why this is happening, that too only on Windows OS. For some reason, the baseDir from where the relative jar is being searched for is being resolved to an incorrect location (it's being resolved to the "deploy" folder instead of "deploy/myapp.ear"). Before looking into this in more detail, can you try either of the following and see if that fixes the issue:

                             

                            1) (Preferred approach) Upgrade to JBoss AS 6.0.0.M1

                             

                            OR

                             

                            2) Use the latest EJB3 plugin http://www.jboss.org/ejb3/ejb3plugin.html against JBoss AS 5.1.0.GA. I am not much optimistic that this might fix the issue, but give it a try.

                             

                            Let us know how it goes (preferably with logs).

                            • 11. Re: Issue specifying the <jar-file> in persistence.xml in JBOSS 5 on linux system

                              1) (Preferred approach) Upgrade to JBoss AS 6.0.0.M1

                               

                              OR

                               

                              2) Use the latest EJB3 plugin http://www.jboss.org/ejb3/ejb3plugin.htm against JBoss AS 5.1.0.GA. I am not much optimistic that this might fix the issue, but give it a try.

                              None of the above worked. I uploaded the log files for JBOSS 6.0.0.M1.

                              • 12. Re: Issue specifying the <jar-file> in persistence.xml in JBOSS 5 on linux system
                                jaikiran

                                With the sample application you provided, i am able to reproduce this issue even on my linux machine. I'll look into this to see what is causing the problem.

                                • 13. Re: Issue specifying the <jar-file> in persistence.xml in JBOSS 5 on linux system

                                  Is there a way to turn off this new JBOSS 5 scoping?

                                  I've ran into a third issue where the main seam module cannot lookup a bean from the external module even if the jndi is correct (the external module is not defined in application.xml).

                                  • 14. Re: Issue specifying the <jar-file> in persistence.xml in JBOSS 5 on linux system
                                    jaikiran

                                    jaikiran wrote:

                                     

                                    I'll look into this to see what is causing the problem.

                                    Well, the spec does not allow the persistence.xml to be in the .ear/META-INF although the JBoss implementation does pickup that file from this location. Allowing the persistence.xml to reside in the META-INF of the .ear, causes the jar-file resolution issue that you are running into.

                                     

                                    According to the spec, to scope the persistence unit to all components in the .ear, you will have to package the persistence.xml in:

                                     

                                    • META-INF of a jar file in the root of the EAR
                                    or
                                    • META-INF of a jar file in the EAR library directory