code: @Override
      public FancyRestObject getComplexObjectSizedMultiserializedJson(@PathParam("size") int number) {
          FancyRestObject fancy = getRandomObject(number);
          ByteArrayOutputStream baos = new ByteArrayOutputStream(0);
          try {
              ObjectOutputStream oos = new ObjectOutputStream(baos);
              oos.writeObject(fancy);
              oos.flush();
              byte[] bytes = baos.toByteArray();
              fancy = null;
              oos.close();
              baos = null;
              oos = null;
              ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes));
              fancy = (FancyRestObject)(in.readObject());
  
  
          } catch (IOException ioException) {
              throw new RuntimeException("Failed to serialize object",ioException);
          } catch (ClassNotFoundException cnfe) {
              throw new RuntimeException("Failed to deserialize object",cnfe);
          }
          return fancy;
      }
docs: Mimicks EJB-REST services
  EJB generates object, it is serialized and deserialized over RMI to output
  then converted to JSON/XML for REST by RESTEasy