title: Morphia - CodecConfigurationException: Can't find a codec for class - But class is registered
body: <p>i've got a problem i have not been facing yet.
  I want to store a Object with an embedded Object in MongoDB using Morphia.</p>
  <p>It seems like it perfectly understand how to de-/serialize the top-level-class but not the embedded one. Here are the two classes:</p>
  <pre><code>@Entity(value = &quot;cb-homes&quot;, noClassnameStored = true)
  @Getter
  @Setter
  @ToString
  public class DatastoreHome extends DatastoreEntity {
  
      @Id
      private ObjectId id;
      @Indexed(options = @IndexOptions(unique = true, sparse = true, background = true))
      private UUID uniqueId;
      @Property(&quot;homes&quot;)
      @Embedded
      private Map&lt;String, List&lt;HomeLocation&gt;&gt; homeLocations;
  
      public List&lt;String&gt; getHomeNameList() {
          List&lt;HomeLocation&gt; locations = homeLocations.get(Bukkit.getServerName());
          if(locations == null) {
              locations = new ArrayList&lt;&gt;();
              homeLocations.put(Bukkit.getServerName(), locations);
          }
          return locations.stream().map(HomeLocation::getHomeName).collect(Collectors.toList());
      }
  
      public List&lt;Location&gt; getHomeLocationList() {
          List&lt;HomeLocation&gt; locations = homeLocations.get(Bukkit.getServerName());
          if(locations == null) {
              locations = new ArrayList&lt;&gt;();
              homeLocations.put(Bukkit.getServerName(), locations);
          }
          return locations.stream().map(HomeLocation::getLocation).collect(Collectors.toList());
      }
  
      public boolean hasSetBaseHome() {
          return getHomeLocation(&quot;home&quot;) != null;
      }
  
      public Location getBaseHomeLocation() {
          return getHomeLocation(&quot;home&quot;);
      }
  
      public Location getHomeLocation(String homeName) {
          List&lt;HomeLocation&gt; locations = homeLocations.get(Bukkit.getServerName());
          if(locations == null) {
              locations = new ArrayList&lt;&gt;();
              homeLocations.put(Bukkit.getServerName(), locations);
          }
          return locations.stream()
                  .filter(location -&gt; location.getHomeName().equals(homeName.toLowerCase()))
                  .findAny()
                  .map(HomeLocation::getLocation)
                  .filter(location -&gt; location.getWorld().getName() != &quot;world&quot;)
                  .orElse(null);
      }
  
      public boolean isHomeAlreadySet(String name) {
          return getHomeNameList().contains(name.toLowerCase());
      }
  
      public HomeLocation addHomeLocation(String homeName, Location location) {
          List&lt;HomeLocation&gt; locations = homeLocations.get(Bukkit.getServerName());
          if(locations == null) {
              locations = new ArrayList&lt;&gt;();
              homeLocations.put(Bukkit.getServerName(), locations);
          }
          if(isHomeAlreadySet(homeName)) {
              locations.remove(getHomeLocation(homeName));
          }
          HomeLocation homeLocation = new HomeLocation();
          homeLocation.setHomeName(homeName.toLowerCase());
          homeLocation.setLocation(location);
          homeLocations.get(Bukkit.getServerName()).add(homeLocation);
          return homeLocation;
      }
  
      public void removeBaseHomeLocation() {
          removeHomeLocation(&quot;home&quot;);
          addHomeLocation(&quot;home&quot;, new Location(Bukkit.getWorld(&quot;world&quot;), 0, 0, 0, 0, 0));
      }
  
      public boolean removeHomeLocation(String homeName) {
          if(homeLocations.get(Bukkit.getServerName()) == null) {
              homeLocations.put(Bukkit.getServerName(), new ArrayList&lt;&gt;());
          }
          return homeLocations.get(Bukkit.getServerName()).removeIf(location -&gt; location.getHomeName().equals(homeName));
      }
  
      static {
          datastore.ensureIndexes(DatastoreHome.class);
      }
  }
  </code></pre>
  <p>and</p>
  <pre><code>@Embedded
  @Getter
  @Setter
  @ToString
  public class HomeLocation extends DatastoreEntity {
  
      @Id
      private ObjectId id;
  
      private String homeName;
      @Property(&quot;location&quot;)
      private Document document;
  
      public Location getLocation() {
          return deserialize(document);
      }
  
      public void setLocation(Location location) {
          document = serialize(location);
      }
  
      private Document serialize(Location location) {
          return new Document(&quot;world&quot;, location.getWorld())
                  .append(&quot;x&quot;, location.getX())
                  .append(&quot;y&quot;, location.getY())
                  .append(&quot;z&quot;, location.getZ())
                  .append(&quot;yaw&quot;, location.getYaw())
                  .append(&quot;pitch&quot;, location.getPitch());
      }
  
      private Location deserialize(Document document) {
          return new Location(Bukkit.getWorld((String) get(&quot;world&quot;)), (double) get(&quot;x&quot;), (double) get(&quot;y&quot;), (double) get(&quot;z&quot;), (float) get(&quot;yaw&quot;), (float) get(&quot;pitch&quot;));
      }
  
      private Object get(String key) {
          return document.get(key);
      }
  
      static {
          datastore.ensureIndexes(HomeLocation.class);
      }
  
  }
  </code></pre>
  <p>As you can see both classes are added to the Morphia index via static class initialization. This works for all other classes just for the HomeLocation.class it does not work.</p>
  <p>Have you guys any ideas how to fix this?
  I also tried adding the classes manually to the Morphia index when initializing Morphia but that also does not work.</p>
  <p>I hope you can help me.</p>
  <p>Kind Regards,</p>
  <p>Fabian Schmidt</p>