Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pusher on Java 17 errors on Google GSON #70

Open
gusthavosouza opened this issue Aug 30, 2023 · 2 comments
Open

Pusher on Java 17 errors on Google GSON #70

gusthavosouza opened this issue Aug 30, 2023 · 2 comments

Comments

@gusthavosouza
Copy link

I have been trying to run Pusher http java on Java 17 and it is failing due to one of the dependencies.

Tried excluding the GSON from google no success:

implementation("com.pusher:pusher-http-java:1.3.3") { exclude group: "com.google.code.gson" }

Using latest version for GSON manually:
implementation("com.google.code.gson:gson:2.10.1")

System:

openjdk version "17.0.7" 2023-04-18 LTS
OpenJDK Runtime Environment Corretto-17.0.7.7.1 (build 17.0.7+7-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.7.7.1 (build 17.0.7+7-LTS, mixed mode, sharing)

Intellij

java.lang.reflect.InaccessibleObjectException: Unable to make field private final long java.time.Instant.seconds accessible: module java.base does not "opens java.time" to unnamed module @2d3379b4 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.internal.reflect.ReflectionHelper.makeAccessible(ReflectionHelper.java:35) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:286) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:130) at com.google.gson.Gson.getAdapter(Gson.java:556) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:160) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:294) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:130) at com.google.gson.Gson.getAdapter(Gson.java:556) at com.google.gson.internal.bind.CollectionTypeAdapterFactory.create(CollectionTypeAdapterFactory.java:53) at com.google.gson.Gson.getAdapter(Gson.java:556) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:160) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:294) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:130) at com.google.gson.Gson.getAdapter(Gson.java:556) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:160) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:294) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:130) at com.google.gson.Gson.getAdapter(Gson.java:556) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:160) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:294) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:130) at com.google.gson.Gson.getAdapter(Gson.java:556) at com.google.gson.internal.bind.CollectionTypeAdapterFactory.create(CollectionTypeAdapterFactory.java:53) at com.google.gson.Gson.getAdapter(Gson.java:556) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:160) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:294) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:130) at com.google.gson.Gson.getAdapter(Gson.java:556) at com.google.gson.Gson.toJson(Gson.java:834) at com.google.gson.Gson.toJson(Gson.java:812) at com.google.gson.Gson.toJson(Gson.java:759) at com.google.gson.Gson.toJson(Gson.java:736) at com.pusher.rest.marshaller.DefaultDataMarshaller.marshal(DefaultDataMarshaller.java:22) at com.pusher.rest.PusherAbstract.serialise(PusherAbstract.java:226) at com.pusher.rest.PusherAbstract.trigger(PusherAbstract.java:301) at com.pusher.rest.PusherAbstract.trigger(PusherAbstract.java:273) at com.pusher.rest.PusherAbstract.trigger(PusherAbstract.java:248) at myservice.MyClass.trigger(MyClass.java:37)

@gusthavosouza
Copy link
Author

I have done some research and it seems that when using Gson pusher would need to add a custom adapter for serializing any objects that has a date field.

@minhlongdo
Copy link

minhlongdo commented May 6, 2024

Hi, I am also having this problem. Is there a solution for this?
Is there a way to provide your "own" Gson?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants