title: Error in Jackson custom Serializers/Deserializers
body: <p>in order to sort out the problems in the custom Serializers/Deserializers I carried out it to another project
  it make such a mistake</p>
  
  <p>ERROR/AndroidRuntime(288): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example/com.example.MyActivity}: java.lang.UnsupportedOperationException: Can not create generator for non-byte-based target</p>
  
  <p><a href="http://i.imgur.com/hOFYI.jpg" rel="nofollow">http://i.imgur.com/hOFYI.jpg</a></p>
  
  <p>program files:</p>
  
  <p>MyActivity.java</p>
  
  <pre><code>package com.example;
  
  import android.app.Activity;
  import android.os.Bundle;
  import com.example.JacksonObject;
  import org.codehaus.jackson.map.*;
  import org.codehaus.jackson.JsonGenerationException;
  import java.io.IOException;
  
  public class MyActivity extends Activity
  {
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState)
  {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  
  String jacksonString = "{\"DateField\":\"/Date(61283424600000)/\",\"StringField\":\"STRING_string\",\"DoubleField\":\"87.12345\",\"IntegerField\":\"387\"}";
  try {
      MyJsonWrapper sss = new MyJsonWrapper();
  
      JacksonObject[] mailItems2 = sss.getMyJson().readValue(jacksonString, JacksonObject[].class);
      int a2 = 3;  //это просто так, что бы поставить точки!!!
      int  b = a2; //это просто так, что бы поставить точки!!!
  
  }   catch (JsonGenerationException e) {
  
      e.printStackTrace();
  
  } catch (JsonMappingException e) {
  
      e.printStackTrace();
  
  } catch (IOException e) {
  
      e.printStackTrace();
  
  }
  int a = 3; //это просто так, что бы поставить точки!!!
  int s = 10; //это просто так, что бы поставить точки!!!
  s = s + a; //это просто так, что бы поставить точки!!!
  }
  }
  </code></pre>
  
  <p>JacksonObject.java</p>
  
  <pre><code>package com.example;
  
  import java.util.Date;
  
  public class JacksonObject
  {
  public Date DateField;
  public String StringField;
  public Double DoubleField;
  public int IntegerField;
  }
  </code></pre>
  
  <p>MyJsonWrapper.java</p>
  
  <pre><code>package com.example;
  
  import org.codehaus.jackson.JsonParser;
  import org.codehaus.jackson.Version;
  import org.codehaus.jackson.map.*;
  import org.codehaus.jackson.map.module.SimpleModule;
  import org.codehaus.jackson.map.JsonDeserializer;
  import org.codehaus.jackson.map.JsonSerializer;
  import org.codehaus.jackson.smile.*;
  import org.codehaus.jackson.*;
  import org.codehaus.jackson.map.ser.*;
  import org.codehaus.jackson.map.ser.std.NullSerializer;
  import org.codehaus.jackson.map.deser.*;
  
  import java.io.IOException;
  import java.lang.reflect.Type;
  import java.util.Date;
  
  public class MyJsonWrapper
  {
  
  public ObjectMapper getMyJson()
  {
  ObjectMapper mapper = new ObjectMapper(new SmileFactory());        
  SimpleModule module = new SimpleModule("MyModule", new Version(1, 0, 0, null));
  
  module.addSerializer(Date.class, new JsonDateSerializer());
  module.addDeserializer(Date.class, new JsonDateDeserializer());
  
  mapper.registerModule(module);
  
  return mapper;
  }
  
  public class JsonDateDeserializer extends JsonDeserializer&lt;Date&gt;
  {
  
  public Date deserialize(JsonParser jp, DeserializationContext context) throws IOException, JsonProcessingException
  {
      try {
  
      String s = jp.getText().replace("/Date(", "").replace(")/", "");
  
      if (s.equals("")) return null;
  
      boolean isDateBefore1970 = false;
  
      ............................................
  
      if (isDateBefore1970)
          return new Date(-Long.valueOf(s) - offset * 60 * 1000);
      else
          return new Date(Long.valueOf(s) + offset * 60 * 1000);
  
      }catch (JsonMappingException e){
          // If a JSON Mapping occurs, simply returning null instead of blocking things
          return null;
      }
  
    }
    }
  
    public class JsonDateSerializer extends JsonSerializer&lt;Date&gt;
   {
     public void serialize(Date date, JsonGenerator jgen, SerializerProvider provider)   throws IOException, JsonProcessingException
    {            
      jgen.writeString("/Date(" + date.getTime() + ")/");
    }
   }    
   }
  </code></pre>
  
  <p>and when in My JsonWrapper.java use static instead of public</p>
  
  <pre><code> public class MyJsonWrapper
  {
   public static ObjectMapper getMyJson()
  {        
  ObjectMapper mapper = new ObjectMapper(new SmileFactory());        
  SimpleModule module = new SimpleModule("MyModule", new Version(1, 0, 0, null));
  
  module.addSerializer(Date.class, new JsonDateSerializer());
  module.addDeserializer(Date.class, new JsonDateDeserializer());
  
  mapper.registerModule(module);
  
  return mapper;
  }
  
  static class JsonDateDeserializer extends JsonDeserializer&lt;Date&gt;
  {
  
  public Date deserialize(JsonParser jp, DeserializationContext context) throws IOException, JsonProcessingException
  {
      try {
  </code></pre>
  
  <p>tnen it makes such a mistake</p>
  
  <p>ERROR/AndroidRuntime(314): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example/com.example.MyActivity}: java.lang.UnsupportedOperationException: Can not create generator for ......</p>
  
  <p><a href="http://i.imgur.com/dohnz.jpg" rel="nofollow">http://i.imgur.com/dohnz.jpg</a></p>
  
  <p>line with the error</p>
  
  <pre><code>JacksonObject[] mailItems2 = sss.getMyJson().readValue(jacksonString, JacksonObject[].class);
  </code></pre>