title: Unable to serialize object having Hashtable as a property in Jersy restful service
body: <p>I am using sun jersey to implement restful services using java. But it seems jersey framework is unable to serialize an object having <strong>Hashtable</strong> as its property.Below is code snippet.</p>
  
  <p>Rest service code:</p>
  
  <pre><code>@Path("/get-test-infos")
  @POST
  @Produces(MediaType.APPLICATION_JSON)
  @Consumes(MediaType.APPLICATION_JSON)
  public Response getTests(Test test) throws ClassNotFoundException, SQLException {
      ResponseBuilder builder = new ResponseBuilderImpl();
      MyTest mtest=new MyTest();
      Dictionary&lt;Integer,String&gt; intString=new Hashtable&lt;Integer,String&gt;();
      List&lt;Integer&gt; intList=new ArrayList&lt;Integer&gt;();
      intList.add(1);
      intList.add(2);
      intString.put(1, "one");
      intString.put(2, "two");
      mtest.setIntString(intString);
      mtest.setIntList(intList);
      builder.entity(mtest);
      builder.status(Status.OK);
      return builder.build();
  }
  </code></pre>
  
  <p>MyTest class definition:</p>
  
  <pre><code>import java.util.Dictionary;
  import java.util.List;
  
  public class MyTest {
      private int testId;
      private Dictionary&lt;Integer,String&gt; intString;
      private List&lt;Integer&gt;intList;
      public int getTestId() {
          return testId;
      }
      public void setTestId(int testId) {
          this.testId = testId;
      }
      public Dictionary&lt;Integer,String&gt; getIntString() {
          return intString;
      }
      public void setIntString(Dictionary&lt;Integer,String&gt; intString) {
          this.intString = intString;
      }
      public List&lt;Integer&gt; getIntList() {
          return intList;
      }
      public void setIntList(List&lt;Integer&gt; intList) {
          this.intList = intList;
      }
  }
  </code></pre>
  
  <p>Below is pom.xml content:</p>
  
  <pre><code>    &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;OnePlatformEduService_v3&lt;/groupId&gt;
    &lt;artifactId&gt;OnePlatformEduService_v3&lt;/artifactId&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
    &lt;packaging&gt;war&lt;/packaging&gt;
    &lt;build&gt;
      &lt;sourceDirectory&gt;src&lt;/sourceDirectory&gt;
      &lt;resources&gt;
        &lt;resource&gt;
          &lt;directory&gt;src&lt;/directory&gt;
          &lt;excludes&gt;
            &lt;exclude&gt;**/*.java&lt;/exclude&gt;
          &lt;/excludes&gt;
        &lt;/resource&gt;
        &lt;resource&gt;
          &lt;directory&gt;DatabaseModule&lt;/directory&gt;
          &lt;excludes&gt;
            &lt;exclude&gt;**/*.java&lt;/exclude&gt;
          &lt;/excludes&gt;
        &lt;/resource&gt;
      &lt;/resources&gt;
      &lt;plugins&gt;
        &lt;plugin&gt;
          &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
          &lt;version&gt;3.5.1&lt;/version&gt;
          &lt;configuration&gt;
            &lt;source&gt;1.8&lt;/source&gt;
            &lt;target&gt;1.8&lt;/target&gt;
          &lt;/configuration&gt;
        &lt;/plugin&gt;
        &lt;plugin&gt;
          &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
          &lt;version&gt;3.0.0&lt;/version&gt;
          &lt;configuration&gt;
            &lt;warSourceDirectory&gt;WebContent&lt;/warSourceDirectory&gt;
          &lt;/configuration&gt;
        &lt;/plugin&gt;
      &lt;/plugins&gt;
    &lt;/build&gt;
      &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
          &lt;artifactId&gt;jersey-server&lt;/artifactId&gt;
          &lt;version&gt;1.8&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
      &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
      &lt;artifactId&gt;jersey-json&lt;/artifactId&gt;
      &lt;version&gt;1.8&lt;/version&gt;
  &lt;/dependency&gt;
  
       &lt;dependency&gt;
              &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-servlet&lt;/artifactId&gt;
              &lt;version&gt;1.18&lt;/version&gt;
          &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.eclipse.persistence&lt;/groupId&gt;
          &lt;artifactId&gt;javax.persistence&lt;/artifactId&gt;
          &lt;version&gt;2.1.0&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.eclipse.persistence&lt;/groupId&gt;
          &lt;artifactId&gt;org.eclipse.persistence.jpa&lt;/artifactId&gt;
          &lt;version&gt;2.5.0&lt;/version&gt;
      &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.jersey.contribs&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-multipart&lt;/artifactId&gt;
              &lt;version&gt;1.8&lt;/version&gt;
          &lt;/dependency&gt;
  
  &lt;!-- jdbc driver for Postgresql --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;postgresql&lt;/groupId&gt;
          &lt;artifactId&gt;postgresql&lt;/artifactId&gt;
          &lt;version&gt;9.1-901.jdbc4&lt;/version&gt;
          &lt;scope&gt;runtime&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-jdbc&lt;/artifactId&gt;
          &lt;version&gt;4.3.14.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
              &lt;version&gt;4.3.14.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
    &lt;/dependencies&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p>While trying to fetch the json response, getting following exception:</p>
  
  <pre><code>SEVERE: Servlet.service() for servlet [jersey-serlvet] in context with path [/OnePlatformEduService_v3] threw exception
  org.codehaus.jackson.map.JsonMappingException: (was java.lang.NullPointerException) (through reference chain: practise.MyTest["intString"])
      at org.codehaus.jackson.map.JsonMappingException.wrapWithPath(JsonMappingException.java:215)
      at org.codehaus.jackson.map.JsonMappingException.wrapWithPath(JsonMappingException.java:180)
      at org.codehaus.jackson.map.ser.SerializerBase.wrapAndThrow(SerializerBase.java:128)
      at org.codehaus.jackson.map.ser.BeanSerializer.serializeFields(BeanSerializer.java:253)
      at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:212)
      at org.codehaus.jackson.map.ser.StdSerializerProvider._serializeValue(StdSerializerProvider.java:587)
      at org.codehaus.jackson.map.ser.StdSerializerProvider.serializeValue(StdSerializerProvider.java:245)
      at org.codehaus.jackson.map.ObjectMapper.writeValue(ObjectMapper.java:1145)
      at org.codehaus.jackson.jaxrs.JacksonJsonProvider.writeTo(JacksonJsonProvider.java:520)
      at com.sun.jersey.json.impl.provider.entity.JacksonProviderProxy.writeTo(JacksonProviderProxy.java:160)
      at com.sun.jersey.spi.container.ContainerResponse.write(ContainerResponse.java:306)
      at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1437)
      at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
      at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
      at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
      at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
      at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:699)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
      at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
      at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
      at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
      at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
      at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      at java.lang.Thread.run(Unknown Source)
  Caused by: java.lang.NullPointerException
      at org.codehaus.jackson.map.ser.BasicSerializerFactory.createTypeSerializer(BasicSerializerFactory.java:247)
      at org.codehaus.jackson.map.ser.BasicSerializerFactory.buildMapSerializer(BasicSerializerFactory.java:481)
      at org.codehaus.jackson.map.ser.BasicSerializerFactory.findSerializerByLookup(BasicSerializerFactory.java:309)
      at org.codehaus.jackson.map.ser.BeanSerializerFactory.createSerializer(BeanSerializerFactory.java:231)
      at org.codehaus.jackson.map.ser.StdSerializerProvider._createUntypedSerializer(StdSerializerProvider.java:764)
      at org.codehaus.jackson.map.ser.StdSerializerProvider._createAndCacheUntypedSerializer(StdSerializerProvider.java:734)
      at org.codehaus.jackson.map.ser.StdSerializerProvider.findValueSerializer(StdSerializerProvider.java:404)
      at org.codehaus.jackson.map.ser.impl.PropertySerializerMap.findAndAddSerializer(PropertySerializerMap.java:47)
      at org.codehaus.jackson.map.ser.BeanPropertyWriter._findAndAddDynamic(BeanPropertyWriter.java:443)
      at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:423)
      at org.codehaus.jackson.map.ser.BeanSerializer.serializeFields(BeanSerializer.java:245)
      ... 36 more
  </code></pre>
  
  <p>I am getting following exception:</p>
  
  <pre><code>org.codehaus.jackson.map.JsonMappingException: (was java.lang.NullPointerException) (through reference chain: practise.MyTest["intString"])
  </code></pre>
  
  <p>Please help me to resolve above issue.</p>