Solved GsonTypes error

Discussion in 'Spigot Plugin Development' started by FrostedSnowman, Apr 16, 2017.

Thread Status:
Not open for further replies.
  1. FrostedSnowman

    Resource Staff

    hi, whenever i try to save / serialize an object so it saves into a file, i always get this error: (spammed)

    Code (Text):

            at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:380) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:375) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:380) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:117) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:72) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.Gson.getAdapter(Gson.java:356) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTypeAdapterFactory.java:82) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:81) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:118) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:72) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.Gson.getAdapter(Gson.java:356) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTypeAdapterFactory.java:82) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:81) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:118) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:72)
    (ReflectiveTypeAdapterFactory.java:82) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:81) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:118) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:72) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.Gson.getAdapter(Gson.java:356) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTypeAdapterFactory.java:82) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:81) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:118) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:72) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.Gson.getAdapter(Gson.java:356) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTypeAdapterFactory.java:82) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:81) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:118) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:72) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.Gson.getAdapter(Gson.java:356) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTypeAdapterFactory.java:82) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:81) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:118) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:72) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.Gson.getAdapter(Gson.java:356) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTypeAdapterFactory.java:82) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:81) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:118) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:72) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.Gson.getAdapter(Gson.java:356) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTypeAdapterFactory.java:82) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:81) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:118) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:72) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.Gson.getAdapter(Gson.java:356) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTypeAdapterFactory.java:82) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:81) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:118) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:72) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.Gson.getAdapter(Gson.java:356) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTypeAdapterFactory.java:82) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:81) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:118) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:72) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.Gson.getAdapter(Gson.java:356) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTypeAdapterFactory.java:82) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:81) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:118) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:72) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.Gson.getAdapter(Gson.java:356) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTypeAdapterFactory.java:82) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:81) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:118) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:72) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.Gson.getAdapter(Gson.java:356) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTypeAdapterFactory.java:82) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:81) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:118) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:72) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.Gson.getAdapter(Gson.java:356) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTypeAdapterFactory.java:82) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:81) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:118) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:72) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.Gson.getAdapter(Gson.java:356) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTypeAdapterFactory.java:82) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:81) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:118) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:72) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.Gson.getAdapter(Gson.java:356) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTypeAdapterFactory.java:82) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:81) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:118) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:72) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.Gson.getAdapter(Gson.java:356) ~[paperclip.jar:git-Paper-1076]
            at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTypeAdapterFactory.java:82) ~[paperclip.jar:git-Paper-1076]
            at
     
    what can i do to fix this?

    this is my current code:
    Code (Java):

    try (FileWriter writer = new FileWriter(Main.get().getDataFolder() + File.separator + "users" + File.separator + "profiles" + File.separator + uuid + ".json")) {
        writer.write(gson.toJson(object));
        writer.flush();
        writer.close();
     
    ive looked online for the answer, but no real good explanation on how to solve this
     
  2. FrostedSnowman

    Resource Staff

    solution:

    register custom type adapters for any 'custom classes' you may have within the class you're trying to serialize
     
Thread Status:
Not open for further replies.