4 Replies Latest reply on Jul 17, 2008 9:13 AM by J-C jc

    JBoss5.0.0.CR1 and EJB3 persistence

    J-C jc Apprentice

      I use EJB3 persistent entities with JBoss 5.0.0.CR1.

      My persistence.xml looks like:

      <persistence-unit name="audittrail">
       <jta-data-source>java:/DemoDS</jta-data-source>
       <properties>
       <property name="hibernate.hbm2ddl.auto" value="create-drop" />
       </properties>
       <!-- ../ is a workaround for http://jira.jboss.com/jira/browse/EJBTHREE-724 -->
       <!--jar-file>../demo-1.0-SNAPSHOT.jar</jar-file-->
       <jar-file>file:/D:/demo/demo.ear/demo-1.0-SNAPSHOT.jar</jar-file>
      
       </persistence-unit>
      


      My jar is included in an ear. When i try to deploy my ear in JBoss5.0.0.CR1, I have:
      vfsfile:... -> org.xml.sax.SAXException
      : cvc-complex-type.2.4.d: Invalid content was found starting with element 'jar-file'. No child element is expected at this point. @ vfsfile:/.../META-INF/pe
      rsistence.xml[17,13]
      
      
      I looks like jar-file is not supported. It should be
      http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd
      
      Any idea of what's going wrong ?
      


        • 1. Re: JBoss5.0.0.CR1 and EJB3 persistence
          jaikiran pai Master

           

          <persistence-unit name="audittrail">
           <jta-data-source>java:/DemoDS</jta-data-source>
           <properties>
           <property name="hibernate.hbm2ddl.auto" value="create-drop" />
           </properties>
           <!-- ../ is a workaround for http://jira.jboss.com/jira/browse/EJBTHREE-724 -->
           <!--jar-file>../demo-1.0-SNAPSHOT.jar</jar-file-->
           <jar-file>file:/D:/demo/demo.ear/demo-1.0-SNAPSHOT.jar</jar-file>
          
           </persistence-unit>


          Re-order the contents to move the jar-file element before the properties element as follows:


          <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="audittrail">
           <jta-data-source>java:/DemoDS</jta-data-source>
          
           <!-- ../ is a workaround for http://jira.jboss.com/jira/browse/EJBTHREE-724 -->
           <!--jar-file>../demo-1.0-SNAPSHOT.jar</jar-file-->
           <jar-file>file:/D:/demo/demo.ear/demo-1.0-SNAPSHOT.jar</jar-file>
          
          <!--Jaikiran: Moved this after the jar-file element -->
          <properties>
           <property name="hibernate.hbm2ddl.auto" value="create-drop" />
           </properties>
           </persistence-unit>
          </persistence>


          • 2. Re: JBoss5.0.0.CR1 and EJB3 persistence
            jaikiran pai Master

             

            "jaikiran" wrote:

            Re-order the contents to move the jar-file element before the properties element



            Having said that, i am not sure whether the xml validation should be strict on the ordering of the child elements of persistence-unit.


            • 3. Re: JBoss5.0.0.CR1 and EJB3 persistence
              jaikiran pai Master

               

              "jaikiran" wrote:

              Having said that, i am not sure whether the xml validation should be strict on the ordering of the child elements of persistence-unit.


              Just looked at the XSD http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd. The elements in the persistence-unit are enclosed within a <xsd:sequence> and so the order IS important. So yes, changing the order in your persistence.xml is the right way to fix this exception.

              • 4. Re: JBoss5.0.0.CR1 and EJB3 persistence
                J-C jc Apprentice

                Thank you. I haven't take care to the order.