title: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of java class
body: <p>I will get an XML response which has to map to Java object. These Java classes are generated from the xsd file. During the conversion, I am getting the exception. </p>
  
  <p><code>com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `com.test.Shop` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('1234')</code></p>
  
  <p>I have tried various scenarios(restTemplate postForObject/exchange, JacksonXmlModule, ObjectMapper, JAXBContext Unmarshaller) to map the response but still not able to fix this. Can someone please help me to figure out what is happening wrong here.</p>
  
  <p>1234 is the shopId. Belo are the Java files of RespDetail and Shop</p>
  
  <p>Below are the xsd generated java files and exception</p>
  
  <p>RespDetail.java</p>
  
  <pre><code>@XmlAccessorType(XmlAccessType.FIELD)
  @XmlType(name = "", propOrder = {
      "shop",
  })
  @XmlRootElement(name = "respDetail")
  public class RespDetail {
      protected List&lt;Shop&gt; shop; 
      public List&lt;Shop&gt; getShop() {
          if (shop == null) {
              shop = new ArrayList&lt;Shop&gt;();
          }
          return this.shop;
      }   
  }
  </code></pre>
  
  <p>Shop.java</p>
  
  <pre><code>@XmlAccessorType(XmlAccessType.FIELD)
  @XmlType(name = "", propOrder = {
      "shopId",
  })
  @XmlRootElement(name = "shop")
  public class Shop {
      protected ShopId shopId;
      public ShopId getShopId() {
          return shopId;
      }
      public void setShopId(ShopId value) {
          this.shopId = value;
      }
  }
  </code></pre>
  
  <p>ShopId.java</p>
  
  <pre><code>@XmlAccessorType(XmlAccessType.FIELD)
  @XmlType(name = "", propOrder = {
      "value"
  })
  @XmlRootElement(name = "shopId")
  public class ShopId {
  
      @XmlValue
      protected String value;
      public String getValue() {
          return value;
      }
      public void setValue(String value) {
          this.value = value;
      }
  }
  </code></pre>
  
  <p>Exception stacktrace:</p>
  
  <pre><code>com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `com.test.Shop` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('76091')
   at [Source: (StringReader); line: 12, column: 29] (through reference chain: com.test.Discover["response"]-&gt;com.test.Response["respDetail"]-&gt;com.test.respDetail["shop"]-&gt;java.util.ArrayList[0])
      at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:63)
      at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1343)
      at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1032)
      at com.fasterxml.jackson.databind.deser.ValueInstantiator._createFromStringFallbacks(ValueInstantiator.java:371)
      at com.fasterxml.jackson.databind.deser.std.StdValueInstantiator.createFromString(StdValueInstantiator.java:323)
      at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromString(BeanDeserializerBase.java:1373)
      at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:171)
      at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:161)
      at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:286)
      at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)
      at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27)
      at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:136)
      at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
      at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
      at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:127)
      at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
      at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
      at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:127)
      at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
      at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
      at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4013)
      at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3004)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:74)
      at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:84)
      at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
      at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
      at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
      at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
      at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
      at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
      at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
      at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
      at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
      at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:67)
  </code></pre>
  
  <p>Sample XML Response</p>
  
  <pre><code>&lt;!DOCTYPE discover SYSTEM "discover.dtd"&gt;
  &lt;discover version="6.0"&gt;
   &lt;response requestTime="0.5914"&gt;
     &lt;respDetail&gt;
       &lt;shop&gt;
         &lt;shopId&gt;47645543&lt;/shopId&gt;
       &lt;/shop&gt;
       &lt;adminMode&gt;N&lt;/adminMode&gt;
       &lt;token&gt;10744&lt;/token&gt;
     &lt;/respDetail&gt;
   &lt;/response&gt;
  &lt;/discover&gt;
  </code></pre>