4 Replies Latest reply on Jun 28, 2007 12:02 PM by marcos_aps

    Problems with the <jar-file> element in the persistence.xml

    marcos_aps

      - JBoss 4.2.0GA

      Hello, everybody!
      I'm having problems with the <jar-file> element of my persistence deployment
      descriptor (persistence.xml). I have deployed my EJB jar file to the directory
      C:\jboss-4.2.0.GA\server\default\deploy and I have placed a jar file that also
      has entity beans to be analysed in the directory
      C:\jboss-4.2.0.GA\server\default\lib. This file is referenced in the
      persitence.xml file. But the problem is that I keep getting error messages when
      I'm deploying my EJB jar file to the directory deploy. The persistence provider
      can't find the jar file specified in the <jar-file> element. This was my
      persistence.xml file the first time I tested it:

      <?xml version="1.0" encoding="UTF-8"?>
      <persistence version="1.0" 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">
      <persistence-unit name="laboratorio-informatica">
      <jta-data-source>java:/LaboratorioInformaticaDS</jta-data-source>
      <mapping-file>META-INF/orm.xml</mapping-file>
      <jar-file>urca.jar</jar-file>
      </persistence-unit>


      and I got this error message when deploying:
      java.lang.RuntimeException: error trying to scan <jar-file>: file:/C:/jboss-4.2.0.GA/bin/urca.jar

      So, I kept modifying the <jar-file> element and got these results:

      <jar-file>lib/urca.jar</jar-file>
      java.lang.RuntimeException: error trying to scan <jar-file>: file:/C:/jboss-4.2.0.GA/bin/lib/urca.jar

      <jar-file>/lib/urca.jar</jar-file>
      java.lang.RuntimeException: error trying to scan <jar-file>: file:/C:/lib/urca.jar

      <jar-file>../lib/urca.jar</jar-file>
      java.lang.RuntimeException: error trying to scan <jar-file>: file:/C:/jboss-4.2.0.GA/server/default/deploy/lib/urca.jar

      <jar-file>../server/default/lib/urca.jar</jar-file>
      java.lang.RuntimeException: error trying to scan <jar-file>: file:/C:/jboss-4.2.0.GA/server/default/deploy/server/default/lib/urca.jar

      So, I couldn't in any way tell the persistence provider to look the file at the
      directory C:\jboss-4.2.0.GA\server\default\lib.

      Please, what do I have to specify in the <jar-file> element to solve this problem?

      Thank you.

      Marcos

        • 1. Re: Problems with the <jar-file> element in the persistence.
          tobias

          Please check the DTDs in the docs directory of the distribution. Also you do not want to put any such things as EJBs into any lib directory.

          • 2. Re: Problems with the <jar-file> element in the persistence.
            marcos_aps

             

            "Tobias" wrote:
            Please check the DTDs in the docs directory of the distribution. Also you do not want to put any such things as EJBs into any lib directory.


            This file (urca.jar) is not an EJB jar file. I place my EJB jar files in the deploy directory. But the urca.jar file has some entity beans that are common to all my applications, so I thought the best place for it was in the lib directory. I don't want to specify an absolute path in the <jar-file> element and make my application non portable. What do you suggest me?

            Marcos


            • 3. Re: Problems with the <jar-file> element in the persistence.
              rob.stryker

              An entity bean is a type of enterprise java bean. I don't believe that should go in the lib folders.

              • 4. Re: Problems with the <jar-file> element in the persistence.
                marcos_aps

                 

                "rob.stryker@jboss.com" wrote:
                An entity bean is a type of enterprise java bean. I don't believe that should go in the lib folders.


                This file (urca.jar) doesn't have only entity beans. It also has utility classes that could be used in all applications. So, where do you suggest me to place it instead of the lib directory? A place where I can point to it in the <jar-file> element. Is there a way to a jar file located in the lib directory from the <jar-file> element? That was the initial point of this discussion. If there's no way, I would be satisfied with another properly place to put the jar file that allowed me to reference it from the <jar-file>.

                Marcos