title: Kryonet -- How can I register classes within my class?
body: <p>I have the following class:</p>
  <pre><code>public class QueryResults {
      protected Set&lt;String&gt; resultList = new HashSet&lt;String&gt;();
      protected long executionTime = 0;
  
      public long getExecutionTime() { return executionTime; }
      [...]
  }
  </code></pre>
  <p>And I register it as so:</p>
  <pre><code>Registrar.RegisterClass(this, QueryResults.class);
  ------------
  public class Registrar {
      public static void RegisterClass(Node n, Class theClass) {
          Map&lt;String, Node&gt; nodeMap = Node.getNodeMap();
          for (Map.Entry&lt;String, Node&gt; node : nodeMap.entrySet()) {
              if (node.getKey().equals(n.getHostname())) {
                  Log.info(&quot;Registering &quot; + theClass.getSimpleName() + &quot; for &quot; + node.getValue().getHostname());
                  node.getValue().getServer().getConnection().getKryo().register(theClass);
                  node.getValue().getClient().getConnection().getKryo().register(theClass);
              }
          }
      }
  }
  </code></pre>
  <p>This has worked well until attempting to serialize <code>QueryResults</code>, due to it containing a container, in this case a <code>HashSet</code> (We've tried an <code>ArrayList</code> as well, with the same results).</p>
  <p>On the endpoint populating and ultimately serializing this class to send back to the caller, I get this output:</p>
  <blockquote>
  <pre><code>Exception in thread &quot;Server&quot; com.esotericsoftware.kryo.KryoException:
  java.lang.IllegalArgumentException: Class is not registered: java.util.HashSet
  
  Note: To register this class use: kryo.register(java.util.HashSet.class);
  </code></pre>
  </blockquote>
  <p>If I explicitly call <code>Registrar.RegisterClass(this, HashSet.class);</code>, everything works swimmingly. However, this can be annoying once we start to implement more advanced classes, with many types of containers.</p>
  <p>Am I doing something wrong?</p>