4 Replies Latest reply on Jun 2, 2010 1:08 PM by aloubyansky

    Mapping xsd:dateTime to XMLGregorianCalendar

    jaikiran

      I am trying to map a xsd:dateTime to the (default) javax.xml.datatype.XMLGregorianCalendar in my binding class:

       

      @XmlType(name = "timerType", propOrder =
      {"descriptionGroup", "schedule", "start", "end", "timeoutMethod", "persistent", "timezone", "info"})
      public class TimerMetaData extends IdMetaDataImplWithDescriptionGroup implements Serializable
      {
      
         private ScheduleMetaData schedule;
      
         private XMLGregorianCalendar start;
      
      ...
      

       

       

      However, JBossXB throws this error for the binding class:

       

      Caused by: org.jboss.xb.binding.JBossXBRuntimeException: Property order is not specified for type javax.xml.datatype.XMLGregorianCalendar bound to a sequence. Property order can be specified using @XmlType.propOrder or @XmlAccessorOrder. List of properties: valid second hour minute fractionalSecond timezone eonAndYear millisecond month year XMLSchemaType day eon
      at org.jboss.metadata.ejb.spec.TimerMetaData.start
      at org.jboss.metadata.ejb.spec.SessionBean31MetaData.timer
      at org.jboss.metadata.ejb.spec.EjbJar31MetaData.enterpriseBeans
      at org.jboss.metadata.ejb.spec.EjbJar31MetaData
          at org.jboss.xb.builder.JBossXBNoSchemaBuilder.rethrowWithLocation(JBossXBNoSchemaBuilder.java:2018)
          at org.jboss.xb.builder.JBossXBNoSchemaBuilder.createRootElementBinding(JBossXBNoSchemaBuilder.java:346)
          at org.jboss.xb.builder.JBossXBNoSchemaBuilder.createRootElements(JBossXBNoSchemaBuilder.java:321)
          at org.jboss.xb.builder.JBossXBNoSchemaBuilder.build(JBossXBNoSchemaBuilder.java:232)
          at org.jboss.xb.builder.JBossXBBuilder.build(JBossXBBuilder.java:291)
          at org.jboss.xb.builder.JBossXBBuilder.build(JBossXBBuilder.java:181)
          at org.jboss.xb.builder.JBossXBBuilder.build(JBossXBBuilder.java:160)
          at org.jboss.xb.binding.resolver.AbstractMutableSchemaResolver.resolve(AbstractMutableSchemaResolver.java:313)
          at org.jboss.xb.binding.sunday.unmarshalling.SundayContentHandler.startElement(SundayContentHandler.java:277)
          at org.jboss.xb.binding.parser.sax.SaxJBossXBParser$DelegatingContentHandler.startElement(SaxJBossXBParser.java:401)
          at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
          at org.apache.xerces.xinclude.XIncludeHandler.startElement(Unknown Source)
          at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
          at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
          at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
          at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
          at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
          at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
          at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
          at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
          at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
          at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:173)
          ... 29 more

       

       

      Why do I have to explicitly specify a prop order on an element which I don't define (i.e. the javax.xml.datatype.XMLGregorianCalendar)? Any way to get around this?

        • 1. Re: Mapping xsd:dateTime to XMLGregorianCalendar
          jaikiran

          jaikiran pai wrote:

           


          Why do I have to explicitly specify a prop order on an element which I don't define (i.e. the javax.xml.datatype.XMLGregorianCalendar)?

          Assuming that I do have to explicitly specify the prop order, I don't see a way how I can do that although the message states:

           

          Property order can be specified using @XmlType.propOrder or @XmlAccessorOrder.

           

          Those annotations cannot be applied to fields/methods.

          • 2. Re: Mapping xsd:dateTime to XMLGregorianCalendar
            aloubyansky

            No, it's not that you have to provide the property order. It's bound as any JavaBean, you have to bind it to dateTime instead.

            Java types that are by default bound to dateTime by XB are java.util.Date.class and java.util.Calendar.class including its subclasses. So, a workaround would be to use XmlAdapter to transform XMLGregorianCalendar to java.util.Calendar.

            But, yes, this should be recognized by default.

            • 3. Re: Mapping xsd:dateTime to XMLGregorianCalendar
              jaikiran

              Alexey Loubyansky wrote:

               

              So, a workaround would be to use XmlAdapter to transform XMLGregorianCalendar to java.util.Calendar.

               

              Thanks. I'll give that a try.

               

              Alexey Loubyansky wrote:

               


              But, yes, this should be recognized by default.

              Would you want me to create a JBossXB JIRA for this?

              • 4. Re: Mapping xsd:dateTime to XMLGregorianCalendar
                aloubyansky

                Yes, sure. Thanks.