5 Replies Latest reply on Apr 6, 2006 2:59 AM by andy

    Unexpected scan path for <jar-file> in persistence.xml

    Chris Howe-Jones Newbie

      I am running JBoss AS 4.0.4RC1 and am deploying EJB3 ear files.

      I am trying to specify a jar file that I want scanned for Entity beans in one of my persistence.xml files using the <jar-file> element.

      I have discovered that the App Server scans the jboss-4.0.4RC1/bin directory for these named jar files!!

      This is not what I expected. Surely my additional entity beans don't have to be deployed in the bin directory!! Shouldn't this path include the deploy directory?

      Is there a way I can specify in my persistence.xml that I want to scan the deploy directory or do I have to live with deploying jars to the bin directory until the netxt release?

        • 1. Re: Unexpected scan path for <jar-file> in persistence.xml
          Chris Howe-Jones Newbie

          I have worked out how to solve this one. You need to make the URL to the jar file a relative URL by adding '../' in front of the jar name. So:

          <jar-file>myjar.jar</jar-file>


          becomes :

          <jar-file>../myjar.jar</jar-file>


          JBoss AS then searches in the deploy directory for the jar.

          • 2. Re: Unexpected scan path for <jar-file> in persistence.xml
            Emmanuel Bernard Master

            open a jira issue, I'm not sure this is expected

            • 3. Re: Unexpected scan path for <jar-file> in persistence.xml
              andy Newbie

              I encountered exactly the same problem. thanks for the hint.

              but my jar with entities is packed inside an ear. I tried:
              <jar-file>../mc.ear/entities.jar</jar-file>
              but it doesn't work.

              It works if I deploy mc.ear unpacked.
              any hint?

              • 4. Re: Unexpected scan path for <jar-file> in persistence.xml
                Chris Howe-Jones Newbie

                My jar is also in an ear. What I forgot to mention is that you need to add the jar into the application.xml description as a jar modue. So in my example I would have something like this in the application.xml:

                <application>
                 <display-name>MyApp</display-name>
                 <module>
                 <ejb>myapp.jar</ejb>
                 </module>
                 <module>
                 <java>myjar.jar</java>
                 </module>
                </application>
                


                And the following in the persistence.xml in the myapp.jar:

                <persistence>
                 <persistence-unit name="myunit">
                 <provider>org.hibernate.ejb.HibernatePersistence</provider>
                 <jta-data-source>java:/MYDS</jta-data-source>
                 <jar-file>../myjar.jar</jar-file>
                 </persistence-unit>
                </persistence>
                


                • 5. Re: Unexpected scan path for <jar-file> in persistence.xml
                  andy Newbie

                  still can't get it to work.

                  I have an ear (mc.ear) for my application. Inside there are:
                  - entities.jar with entities classes and persistence.xml including 1 PUnit
                  - business.jar with SBs and POJOs
                  - web.war
                  all 3 packages are listed in application.xml as modules:

                  <?xml version="1.0" encoding="UTF-8"?>
                  <application>
                   <display-name>mc</display-name>
                   <module>
                   <java>entities.jar</java>
                   </module>
                   <module>
                   <ejb>business.jar</ejb>
                   </module>
                   <module>
                   <web>
                   <web-uri>web.war</web-uri>
                   <context-root>mc</context-root>
                   </web>
                   </module>
                  </application>

                  everything is ok.

                  now I want to deploy an additional persistence unit by creating an jar (entities2.jar) with only this persistence.xml in it:
                  <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="mcora">
                   <jta-data-source>java:/mcDS</jta-data-source>
                   <jar-file>../entities.jar</jar-file>
                   <properties>
                   <property name="hibernate.hbm2ddl.auto" value="update"/>
                   <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9Dialect"/>
                   <property name="hibernate.show_sql" value="false"/>
                   <property name="hibernate.cache.provider_class" value="org.jboss.ejb3.entity.TreeCacheProviderHook"/>
                   <property name="hibernate.treecache.mbean.object_name" value="jboss.cache:service=EJB3EntityTreeCache"/>
                  
                   <property name="jboss.entity.manager.jndi.name" value="java:/EntityManagers/mcora"/>
                   <property name="jboss.entity.manager.factory.jndi.name" value="java:/EntityManagerFactories/mcora"/>
                   </properties>
                   </persistence-unit>
                  
                  </persistence>


                  this gives me:
                  java.lang.RuntimeException: error trying to scan <jar-file>: file:/Z:/mc/jboss/jboss-4.0.4.CR2/server/default/deploy/entities.jar

                  I tried your hint and packed entities2.jar in another ear with application.xml:

                  <?xml version="1.0" encoding="UTF-8"?>
                  <application>
                   <display-name>mcora</display-name>
                  
                   <module>
                   <java>entities.jar</java>
                   </module>
                   <module>
                   <ejb>entities2.jar</ejb>
                   </module>
                  
                  </application>
                  


                  but this results in:
                  org.jboss.deployment.DeploymentException: Failed to find module file: entities.jar

                  I guess I get you wrong?!