Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+17 votes

Hi, I'm currently fixing the save feature of my group project, the JSON file seems to be created just fine, but when I clicked on it and tried to open it, it says that the file does not exist, it turns out that the JSON file has not been written on at all, and the error says:
Caused by: com.google.gson.JsonIOException: Failed making field 'javafx.scene.layout.HBox#biasDirty' accessible; either increase its visibility or write a custom TypeAdapter for its declaring type.

at com.google.gson@2.10.1/com.google.gson.internal.reflect.ReflectionHelper.makeAccessible(ReflectionHelper.java:38)
at com.google.gson@2.10.1/com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:286)
at com.google.gson@2.10.1/com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:130)
at com.google.gson@2.10.1/com.google.gson.Gson.getAdapter(Gson.java:556)
at com.google.gson@2.10.1/com.google.gson.internal.bind.CollectionTypeAdapterFactory.create(CollectionTypeAdapterFactory.java:53)
at com.google.gson@2.10.1/com.google.gson.Gson.getAdapter(Gson.java:556)
at com.google.gson@2.10.1/com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:160)
at com.google.gson@2.10.1/com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:294)
at com.google.gson@2.10.1/com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:130)
at com.google.gson@2.10.1/com.google.gson.Gson.getAdapter(Gson.java:556)
at com.google.gson@2.10.1/com.google.gson.internal.bind.CollectionTypeAdapterFactory.create(CollectionTypeAdapterFactory.java:53)
at com.google.gson@2.10.1/com.google.gson.Gson.getAdapter(Gson.java:556)
at com.google.gson@2.10.1/com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:160)
at com.google.gson@2.10.1/com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:294)
at com.google.gson@2.10.1/com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:130)
at com.google.gson@2.10.1/com.google.gson.Gson.getAdapter(Gson.java:556)
at com.google.gson@2.10.1/com.google.gson.Gson.toJson(Gson.java:834)
at com.google.gson@2.10.1/com.google.gson.Gson.toJson(Gson.java:812)
at com.google.gson@2.10.1/com.google.gson.Gson.toJson(Gson.java:759)
at com.google.gson@2.10.1/com.google.gson.Gson.toJson(Gson.java:736)
at edu.augustana/edu.augustana.LessonPlan.saveToFile(LessonPlan.java:76)
at edu.augustana/edu.augustana.App.saveCurrentLessonPlanToFile(App.java:155)
at edu.augustana/edu.augustana.NewLessonPlanController.saveCurrentLessonPlanToFile(NewLessonPlanController.java:459)
at edu.augustana/edu.augustana.NewLessonPlanController.saveActionAs(NewLessonPlanController.java:453)
at edu.augustana/edu.augustana.NewLessonPlanController.saveAction(NewLessonPlanController.java:440)
at edu.augustana/edu.augustana.NewLessonPlanController.SaveButton(NewLessonPlanController.java:435)
... 57 more

Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private boolean javafx.scene.layout.HBox.biasDirty accessible: module javafx.graphics does not "opens javafx.scene.layout" to module com.google.gson

at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)
at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
at com.google.gson@2.10.1/com.google.gson.internal.reflect.ReflectionHelper.makeAccessible(ReflectionHelper.java:35)
... 82 more

Does anybody run into this error before, and what can I do to fix it? Thank you

asked in CSC305 Fall 2023 by (1 point)

2 Answers

+2 votes

You may need to add this to the module-info.java:
opens edu.augustana to javafx.fxml, com.google.gson;

answered by (1 point)
+1

It looks like my module file has already got that line in there, so this should not be the case. But thank you Joshua!

0 votes

i think you need to update the module-info.java

answered by (1 point)
...