title: Spring data mongodb serialization of InetSocketAddress
body: <p>First off: I am very new to Spring, therefore I am sorry if I fail to provide all information necessary for the question. My problem is as follows: I have the following class which objects I want to save in a mongoDB </p>
  
  <pre><code>public class Subscription implements Serializable {
  
      private String type;
      private InetSocketAddress host;
  
      public String getType() {
          return type;
      }
  
      public void setType(String type) {
          this.type = type;
      }
  
      public InetSocketAddress getHost() {
          return host;
      }
  
      public void setHost(InetSocketAddress host) {
          this.host = host;
      }
  
  
      public Subscription(){}
  
  </code></pre>
  
  <p>I do this by just defining a Repository interface and autowiring it into my application (which works fine for another repository)</p>
  
  <pre><code>public interface SubscriptionRepository extends MongoRepository&lt;Subscription, String&gt; {
  }
  </code></pre>
  
  <p>I can save Subscription objects into the repository, but reading them into a <code>List&lt;Subscription&gt;</code> via <code>SubscriptionRepository.findall()</code> gives me an error</p>
  
  <pre><code>Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.net.InetSocketAddress]: No default constructor found; nested exception is java.lang.NoSuchMethodException: java.net.InetSocketAddress.&lt;init&gt;()
  </code></pre>
  
  <p>Looking into the database the InetSocketAddress object is saved kind of weird</p>
  
  <pre><code>{ "_id" : ObjectId("5e1a48f4a6e30c7d2089e5cd"), "type" : "test", "host" : { "holder" : { "addr" : { "holder" : { "address" : 174417169, "family" : 1 }, "_class" : "java.net.Inet4Address" }, "port" : 0 } }, "_class" : "com.example.myproject.Subscription" }
  </code></pre>
  
  <p>What do I have to change in order to save the InetSocketAddress field in a way so that I can retrieve the Subscription Object from the database correctly?</p>
  
  <p>Thank you in Advance</p>