14 Replies Latest reply on Apr 29, 2008 6:02 AM by aloubyansky

    Element order exception

    alesj

      I get this when hacking persistence.xml metadata:

      Caused by: org.jboss.xb.binding.JBossXBRuntimeException: Requested element {http://java.sun.com/xml/ns/persistence}jta-data-source is not allowed in this position in the sequence. The next element should be {http://java.sun.com/xml/ns/persistence}properties
      


      I'm not really understanding where this order is set?

      The test code is in metadata project:
      - http://anonsvn.jboss.org/repos/jbossas/projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jpa/PersistenceMDUnitTestCase.java

      And this are the two metadata classes:
      - http://anonsvn.jboss.org/repos/jbossas/projects/metadata/trunk/src/main/java/org/jboss/metadata/jpa/spec/PersistenceMetaData.java
      - http://anonsvn.jboss.org/repos/jbossas/projects/metadata/trunk/src/main/java/org/jboss/metadata/jpa/spec/PersistenceUnitMetaData.java

        • 1. Re: Element order exception
          alesj

          And the xml content:

          <?xml version="1.0" encoding="UTF-8"?>
          <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence">
           <persistence-unit name="manager">
           <jta-data-source>java:/DefaultDS</jta-data-source>
           <jar-file>persistence.jar</jar-file>
           <properties>
           <property name="hibernate" value="create-drop"/>
           </properties>
           </persistence-unit>
          </persistence>
          


          • 2. Re: Element order exception
            aloubyansky

            Here

            @XmlType(propOrder={"mappingFiles", "jarFiles", "classes", "properties"})
            public class PersistenceUnitMetaData implements Serializable


            The only elements (and their order) this type has are listed in the propOrder. There is no jta-data-source at all

            • 3. Re: Element order exception
              alesj

               

              "alex.loubyansky@jboss.com" wrote:
              Here
              @XmlType(propOrder={"mappingFiles", "jarFiles", "classes", "properties"})
              public class PersistenceUnitMetaData implements Serializable


              The only elements (and their order) this type has are listed in the propOrder. There is no jta-data-source at all

              Aha, don't know what I was thinking. :-)
              I thought you only need to list the ones that are collections of elements.
              Which doesn't make sense.

              OK, getting this one now:
              Caused by: org.jboss.xb.binding.JBossXBRuntimeException: Attribute is not bound: element owner {http://java.sun.com/xml/ns/persistence}property, attribute name
              


              The mapping:
               @XmlElementWrapper(name="properties")
               @JBossXmlMapEntry(name="property")
               @JBossXmlMapKeyAttribute(name="name")
               @JBossXmlMapValueAttribute(name="value")
               public void setProperties(Map<String, String> properties)
               {
               this.properties = properties;
               }
              


              and the same xml as before.

              • 4. Re: Element order exception
                aloubyansky

                The attributes are bound to the target namespace. You would see it if you enabled trace. That's a bug. I am committing the tests and the fix to the xb.

                • 5. Re: Element order exception
                  alesj

                   

                  "alex.loubyansky@jboss.com" wrote:
                  The attributes are bound to the target namespace. You would see it if you enabled trace.

                  You mean this:
                  11:33:23,625 TRACE [BeanHandler] startElement {http://java.sun.com/xml/ns/persistence}property bean=org.jboss.xb.builder.runtime.DefaultMapEntry parent=org.jboss.metadata.jpa.spec.PersistenceUnitMetaData@6460907
                  


                  "alex.loubyansky@jboss.com" wrote:
                  That's a bug. I am committing the tests and the fix to the xb.

                  I copied the Map usage from your test in JBossXB.
                  What's different there, so that it works?

                  • 6. Re: Element order exception
                    aloubyansky

                    Sorry, no, those were not logged. Confused with the @XmlAttribute processing.

                    For the changes see http://jira.jboss.com/jira/browse/JBXB-139. Specifically jbossxb/trunk/src/main/java/org/jboss/xb/builder/JBossXBNoSchemaBuilder.java

                    • 7. Re: Element order exception
                      aloubyansky

                      Is there a need to keep the PersistenceMDUnitTestCase in the metadata project?

                      • 8. Re: Element order exception
                        alesj

                        Where else to put it?
                        As I see it, it has the same value as other jee metadata tests.

                        I want to move away from Hibernate passing me the metadata, e.g. I can use some other EntityManager impl.
                        And then use the right deployers: simplifying parsing, component deployer (PersistenceMD --> PersistenceUnitMDs) and real (PUMD --> BeanMetaData).

                        • 9. Re: Element order exception
                          aloubyansky

                          Thanks, that's what I wanted to clarify.

                          • 10. Re: Element order exception
                            alesj

                            I need new JBossXB in order for PMD to work.
                            What is the plan of releasing new JBossXB version and updating its usage in Metadata?

                            • 11. Re: Element order exception
                              aloubyansky

                              It's "on-demand". I can do it this or next week. Do you need it ASAP?

                              • 12. Re: Element order exception
                                alesj

                                 

                                "alex.loubyansky@jboss.com" wrote:
                                Do you need it ASAP?

                                Not really.
                                I can work on new PMD deployers on jbossxb snapshot, and only commit the stuff once you update the metadata.


                                • 13. Re: Element order exception
                                  aloubyansky

                                  Ok, anyway, I think it won't take long.
                                  The thirdparty change task http://jira.jboss.com/jira/browse/JBMETA-29

                                  • 14. Re: Element order exception
                                    aloubyansky

                                    It's done.