title: Jersey REST date @XmlAttribute causing an illegal argument exception
body: <p>I have a Jersey REST web service which takes in a POSTed XML string. I have entities for each element of the XML to split them up into objects.
  When I pass a Date parameter e.g. inspectionDate="12/02/2012" I get the following error.</p>
  
  <pre><code>SEVERE: Servlet.service() for servlet [Jersey REST Service] in context with path [] threw exception
      java.lang.IllegalArgumentException: 12/02/2012
          at com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl$Parser.parseAndSetYear(Unknown Source)
          at com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl$Parser.parse(Unknown Source)
          at com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl.&lt;init&gt;(Unknown Source)
          at com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl.newXMLGregorianCalendar(Unknown Source)
          at com.sun.xml.bind.DatatypeConverterImpl._parseDateTime(DatatypeConverterImpl.java:400)
          at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$5.parse(RuntimeBuiltinLeafInfoImpl.java:271)
          at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$5.parse(RuntimeBuiltinLeafInfoImpl.java:273)
          at com.sun.xml.bind.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.parse(TransducedAccessor.java:241)
          at com.sun.xml.bind.v2.runtime.unmarshaller.StructureLoader.startElement(StructureLoader.java:201)
          at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:481)
          at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:459)
          at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:148)
          at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
          at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
          at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
          at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
          at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
          at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
          at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
          at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
          at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
          at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
          at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
          at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:211)
          at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:184)
          at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(Unknown Source)
          at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(Unknown Source)
          at com.sun.jersey.core.provider.jaxb.AbstractRootElementProvider.readFrom(AbstractRootElementProvider.java:124)
          at com.sun.jersey.core.provider.jaxb.AbstractRootElementProvider.readFrom(AbstractRootElementProvider.java:97)
          at com.sun.jersey.spi.container.ContainerRequest.getEntity(ContainerRequest.java:393)
          at com.sun.jersey.server.impl.model.method.dispatch.EntityParamDispatchProvider$EntityInjectable.getValue(EntityParamDispatchProvider.java:139)
          at com.sun.jersey.server.impl.inject.InjectableValuesProvider.getInjectableValues(InjectableValuesProvider.java:43)
          at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$EntityParamInInvoker.getParams(AbstractResourceMethodDispatchProvider.java:126)
          at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:173)
          at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:67)
          at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:163)
          at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:111)
          at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:71)
          at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:111)
          at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:63)
          at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:654)
          at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:612)
          at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:603)
          at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:309)
          at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:425)
          at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:590)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
          at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
          at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
          at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
          at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
          at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
          at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
          at java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>Here is my XML string:</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='UTF-8' standalone='yes' ?&gt;
      &lt;user userName="Test.Test" userID="43"&gt;
        &lt;client&gt;
          &lt;site&gt;
            &lt;building&gt;
              &lt;location&gt;
                &lt;asset assetID="293"&gt;
                  &lt;inspection assetID="293" inspectionDate="12/02/2012" inspectionRef="inspection_ref_89158"&gt;
                   &lt;comments&gt;Test&lt;/comments&gt;
                    &lt;assessedBy&gt;Natasha Allsopp&lt;/assessedBy&gt;
                    &lt;assessed&gt;false&lt;/assessed&gt;
                    &lt;notAssessedReason&gt;Access Hatch Padlocked&lt;notAssessedReason&gt;
                    &lt;acceptable&gt;true&lt;/acceptable&gt;
                    &lt;remedialActionRequired&gt;false&lt;/remedialActionRequired&gt;
                    &lt;remedialActionID&gt;0&lt;/remedialActionID&gt;
                    &lt;flowTemperature&gt;0.0&lt;/flowTemperature&gt;
                    &lt;returnTemperature&gt;0.0&lt;/returnTemperature&gt;
                    &lt;temperature1MinHot&gt;0.0&lt;/temperature1MinHot&gt;
                    &lt;temperature2MinCold&gt;0.0&lt;/temperature2MinCold&gt;
                    &lt;showerHeadsPresent&gt;4&lt;/showerHeadsPresent&gt;
                    &lt;showerHeadsCleaned&gt;0&lt;/showerHeadsCleaned&gt;
                    &lt;showersNotCleanedReason&gt;&lt;/showersNotCleanedReason&gt;
                    &lt;storedWaterTemperature&gt;0.0&lt;/storedWaterTemperature&gt;
                    &lt;incomingMainsTemperature&gt;0.0&lt;/incomingMainsTemperature&gt;
                    &lt;anyLeaks&gt;false&lt;/anyLeaks&gt;
                    &lt;sludgePresent&gt;None&lt;/sludgePresent&gt;
                    &lt;corrosionPresent&gt;None&lt;/corrosionPresent&gt;
                    &lt;flotsamPresent&gt;None&lt;/flotsamPresent&gt;
                    &lt;turnoverCheck&gt;Good&lt;/turnoverCheck&gt;
                    &lt;conditionofTank&gt;Good&lt;/conditionofTank&gt;
                    &lt;goodFittingLidPresent&gt;false&lt;/goodFittingLidPresent&gt;
                    &lt;lidVented&gt;false&lt;/lidVented&gt;
                    &lt;ventScreened&gt;false&lt;/ventScreened&gt;
                    &lt;overflowPresent&gt;false&lt;/overflowPresent&gt;
                    &lt;insectScreen&gt;false&lt;/insectScreen&gt;
                  &lt;/inspection&gt;
                &lt;/asset&gt;
              &lt;/location&gt;
            &lt;/building&gt;
          &lt;/site&gt;
        &lt;/client&gt;
      &lt;/user&gt;
  </code></pre>
  
  <p>And here is a snippet of my entity class:</p>
  
  <pre><code>@XmlAccessorType(XmlAccessType.FIELD)
  @XmlType(name = "", propOrder = {"inspectionDate"})
  
  public class Inspection {
  
      @XmlAttribute
      protected Date inspectionDate;
  
      @XmlAttribute
      protected String inspectionRef;
  
          public Date getInspectionDate() {
          return inspectionDate;
      }
  
      public void setInspectionDate(Date inspectionDate) {
          this.inspectionDate = inspectionDate;
      }
  }
  </code></pre>
  
  <p>If I use the following XMLJavaAdapter:</p>
  
  <pre><code>public class DateAdapter extends XmlAdapter&lt;String, Date&gt; {
  
      private SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
  
      @Override
      public String marshal(Date v) throws Exception {
          return dateFormat.format(v);
      }
  
      @Override
      public Date unmarshal(String v) throws Exception {
          return dateFormat.parse(v);
      }
  
  }
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>SEVERE: Servlet.service() for servlet [Jersey REST Service] in context with path [] threw exception [com.sun.jersey.api.container.MappableContainerException: java.io.IOException: Error unmarshalling JAXB object of type "class dao.jpa.User".] with root cause
  com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
  There are two properties named "inspectionDate" 
      this problem is related to the following location:
          at public java.util.Date dao.jpa.Inspection.getInspectionDate()
          at dao.jpa.Inspection
          at protected dao.jpa.Inspection dao.jpa.Asset.inspection
          at dao.jpa.Asset
          at protected dao.jpa.Asset dao.jpa.Location.asset
          at dao.jpa.Location
          at protected dao.jpa.Location dao.jpa.Building.location
          at dao.jpa.Building
          at protected dao.jpa.Building dao.jpa.Site.building
          at dao.jpa.Site
          at protected dao.jpa.Site dao.jpa.Client.site
          at dao.jpa.Client
          at protected dao.jpa.Client dao.jpa.User.client
          at dao.jpa.User
      this problem is related to the following location:
          at protected java.util.Date dao.jpa.Inspection.inspectionDate
          at dao.jpa.Inspection
          at protected dao.jpa.Inspection dao.jpa.Asset.inspection
          at dao.jpa.Asset
          at protected dao.jpa.Asset dao.jpa.Location.asset
          at dao.jpa.Location
          at protected dao.jpa.Location dao.jpa.Building.location
          at dao.jpa.Building
          at protected dao.jpa.Building dao.jpa.Site.building
          at dao.jpa.Site
          at protected dao.jpa.Site dao.jpa.Client.site
          at dao.jpa.Client
          at protected dao.jpa.Client dao.jpa.User.client
          at dao.jpa.User
  Class has two properties of the same name "inspectionDate"
      this problem is related to the following location:
          at public java.util.Date dao.jpa.Inspection.getInspectionDate()
          at dao.jpa.Inspection
          at protected dao.jpa.Inspection dao.jpa.Asset.inspection
          at dao.jpa.Asset
          at protected dao.jpa.Asset dao.jpa.Location.asset
          at dao.jpa.Location
          at protected dao.jpa.Location dao.jpa.Building.location
          at dao.jpa.Building
          at protected dao.jpa.Building dao.jpa.Site.building
          at dao.jpa.Site
          at protected dao.jpa.Site dao.jpa.Client.site
          at dao.jpa.Client
          at protected dao.jpa.Client dao.jpa.User.client
          at dao.jpa.User
      this problem is related to the following location:
          at protected java.util.Date dao.jpa.Inspection.inspectionDate
          at dao.jpa.Inspection
          at protected dao.jpa.Inspection dao.jpa.Asset.inspection
          at dao.jpa.Asset
          at protected dao.jpa.Asset dao.jpa.Location.asset
          at dao.jpa.Location
          at protected dao.jpa.Location dao.jpa.Building.location
          at dao.jpa.Building
          at protected dao.jpa.Building dao.jpa.Site.building
          at dao.jpa.Site
          at protected dao.jpa.Site dao.jpa.Client.site
          at dao.jpa.Client
          at protected dao.jpa.Client dao.jpa.User.client
          at dao.jpa.User
  
      at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:102)
      at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:472)
      at com.sun.xml.bind.v2.runtime.JAXBContextImpl.&lt;init&gt;(JAXBContextImpl.java:302)
      at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1140)
      at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:154)
      at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:121)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at javax.xml.bind.ContextFinder.newInstance(Unknown Source)
      at javax.xml.bind.ContextFinder.newInstance(Unknown Source)
      at javax.xml.bind.ContextFinder.find(Unknown Source)
      at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
      at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
      at com.sun.jersey.core.provider.jaxb.AbstractJAXBProvider.getStoredJAXBContext(AbstractJAXBProvider.java:199)
      at com.sun.jersey.core.provider.jaxb.AbstractJAXBProvider.getJAXBContext(AbstractJAXBProvider.java:177)
      at com.sun.jersey.core.provider.jaxb.AbstractJAXBProvider.getUnmarshaller(AbstractJAXBProvider.java:131)
      at com.sun.jersey.core.provider.jaxb.AbstractJAXBProvider.getUnmarshaller(AbstractJAXBProvider.java:104)
      at com.sun.jersey.core.provider.jaxb.AbstractRootElementProvider.readFrom(AbstractRootElementProvider.java:97)
      at com.sun.jersey.spi.container.ContainerRequest.getEntity(ContainerRequest.java:393)
      at com.sun.jersey.server.impl.model.method.dispatch.EntityParamDispatchProvider$EntityInjectable.getValue(EntityParamDispatchProvider.java:139)
      at com.sun.jersey.server.impl.inject.InjectableValuesProvider.getInjectableValues(InjectableValuesProvider.java:43)
      at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$EntityParamInInvoker.getParams(AbstractResourceMethodDispatchProvider.java:126)
      at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:173)
      at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:67)
      at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:163)
      at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:111)
      at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:71)
      at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:111)
      at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:63)
      at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:654)
      at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:612)
      at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:603)
      at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:309)
      at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:425)
      at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:590)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>If anyone has any ideas, please let me know.</p>