Application Server 7
  1. Application Server 7
  2. AS7-1369

persistence.xml in EAR/META-INF folder with <jar-file>

    Details

    • Type: Bug Bug
    • Status: Closed Closed (View Workflow)
    • Priority: Major Major
    • Resolution: Out of Date Out of Date
    • Affects Version/s: 7.1.1.Final
    • Fix Version/s: None
    • Component/s: JPA / Hibernate
    • Labels:
      None
    • Similar Issues:
      Show 10 results 

      Description

      adding persistence.xml in META-INF dir of an ear like this
      ?xml version="1.0" encoding="UTF-8"?>
      <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="mypersistencunit">
      ...
      <jar-file>lib/myjpa.jar</jar-file>

      result in exception:
      Caused by: java.lang.RuntimeException: error trying to scan <jar-file>: vfs:/c:/JBoss/jboss-as-7.0.0.Final/bin/content/lib/myjpa.jar

        Activity

        Hide
        Scott Marlow
        added a comment -

        Text from JPA 2.0 section 8.2:

        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.

        It would be helpful if the JPA deployer gave a warning/error for this.

        Show
        Scott Marlow
        added a comment - Text from JPA 2.0 section 8.2: 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. It would be helpful if the JPA deployer gave a warning/error for this.
        Hide
        wiktorowski maximilien
        added a comment - - edited

        Hi Scott,

        I'm already using EAR library directory.
        My structure is as follow:

        myear.ear
          META-INF/
            persistence.xml
          lib/
            myjpa.jar
        

        The problem is that the jpa deployer seems to search the jar in c:/JBoss/jboss-as-7.0.0.Final/bin/content/lib/myjpa.jar instead of myear.ear/lib/myjpa.jar

        Show
        wiktorowski maximilien
        added a comment - - edited Hi Scott, I'm already using EAR library directory. My structure is as follow: myear.ear META-INF/ persistence.xml lib/ myjpa.jar The problem is that the jpa deployer seems to search the jar in c:/JBoss/jboss-as-7.0.0.Final/bin/content/lib/myjpa.jar instead of myear.ear/lib/myjpa.jar
        Hide
        Scott Marlow
        added a comment -

        Its best to ask questions in the user forum.

        Check the JPA documentation here for the valid persistence.xml locations (myjpa.jar could contain the META-INF/persistence.xml).

        Show
        Scott Marlow
        added a comment - Its best to ask questions in the user forum . Check the JPA documentation here for the valid persistence.xml locations (myjpa.jar could contain the META-INF/persistence.xml).
        Hide
        wiktorowski maximilien
        added a comment - - edited

        In our case the same myjpa.jar is used in several packaging so persistence.xml can't be embedded on it.

        What we've done is create another persistence.jar in the ear/lib directory and it works well.

        myear.ear
          lib/
            myjpa.jar
            persistence.jar
              META-INF/
                persistence.xml
        

        At first i thought ear/META-INF was a valid location but looking at your link about JPA 2.0 specification it appears it's not. So you can reject the bug

        Best regards,

        PS : JPA deployer should ignore ear/META-INF/persistence.xml and warn user it's a bad configuration

        Show
        wiktorowski maximilien
        added a comment - - edited In our case the same myjpa.jar is used in several packaging so persistence.xml can't be embedded on it. What we've done is create another persistence.jar in the ear/lib directory and it works well. myear.ear lib/ myjpa.jar persistence.jar META-INF/ persistence.xml At first i thought ear/META-INF was a valid location but looking at your link about JPA 2.0 specification it appears it's not. So you can reject the bug Best regards, PS : JPA deployer should ignore ear/META-INF/persistence.xml and warn user it's a bad configuration
        Hide
        Scott Marlow
        added a comment -

        It would probably be enough to log a warning about ear/META-INF/persistence.xml.

        Show
        Scott Marlow
        added a comment - It would probably be enough to log a warning about ear/META-INF/persistence.xml.
        Hide
        Bartosz Baranowski
        added a comment -

        Switched to RHT since it violates JPA deployment root and some tests use this exploit.

        Show
        Bartosz Baranowski
        added a comment - Switched to RHT since it violates JPA deployment root and some tests use this exploit.
        Show
        Bartosz Baranowski
        added a comment - This has been fixed with: https://github.com/jbossas/jboss-as/commit/38815193011fba624170a7d938118ee630b6ccb2

          People

          • Assignee:
            Bartosz Baranowski
            Reporter:
            wiktorowski maximilien
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: