-
Notifications
You must be signed in to change notification settings - Fork 365
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
java.lang.NoClassDefFoundError: com/google/gson/ReflectionAccessFilter #1525
Comments
Hello @mudlee, thank you for reporting this. I'm struggling a bit to reproduce this with the code you have provided. Are you missing a line? Also inside the stack trace there is no mention of any classes of stripe-java. Can you include enough of the stack trace so that the entry point from stripe-java is visible? Thank you, and sorry that you are experiencing this error. |
You're right. I was just copying the failing code after 2 hours of debugging and was not care enough to give you a fully reproducible code. And yes, there is no stripe in the strace at all, if you see the error, there is something wrong with your gson version you use. Especially that version does not compatible with newer Java versions. I use Zulu 17 SDK. Code that should fail: package mudlee.payment;
import com.stripe.exception.StripeException;
import com.stripe.model.PaymentMethod;
import com.stripe.net.RequestOptions;
import com.stripe.param.PaymentMethodListParams;
public class PaymentApplication {
public static void main(String[] args) {
final var params =
PaymentMethodListParams.builder()
.setType(PaymentMethodListParams.Type.CARD)
.setCustomer("***")
.build();
try {
PaymentMethod.list(params, RequestOptions.builder().setApiKey("***").build());
} catch (StripeException e) {
throw new RuntimeException(e);
}
}
} Exception Connected to the target VM, address: '127.0.0.1:49742', transport: 'socket'
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/gson/ReflectionAccessFilter
at global.iop.console.payment.PaymentApplication.main(PaymentApplication.java:17)
Caused by: java.lang.ClassNotFoundException: com.google.gson.ReflectionAccessFilter
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
... 1 more Relevant pom.xml <dependency>
<groupId>com.stripe</groupId>
<artifactId>stripe-java</artifactId>
<version>22.12.0</version>
</dependency> |
Hi mudlee. What is your version of GSON? We pin a recent version of GSON in our pom, so you should be getting a compatible version by default, unless you are explicitly pinning gson to a particular older version. |
@richardm-stripe I'm not using gson at all. Stripe uses it internally. Am I wrong? |
@mudlee Stripe does use Gson internally. If your project doesn't declare a dependency on gson outside of stripe-java, then I would expect your build tool (maven? gradle?) to resolve Gson to the version defined in stripe-java's pom, which is version GSON 2.10.1, but if that's the case it would be very surprising that you are getting an error about Can you run |
Stripe related
Full
|
This is very puzzling to me. When I create a Maven project and upgrade from 22.3.0 to 22.12.0, I do not see this behavior -- Gson automatically updates from 2.9.0 to 2.10.1 as expected. Can you reproduce this in a smaller sample project that you can share? The fact that the version you are seeing is 2.8.6 is also unusual, since we stopped depending on that version in v20.75.0. Could the incompatible version of Gson be coming from Spring Boot somehow? Reading here, Spring Boot has a property In any case, I think tracking down the source of the incompatible version in your project would be ideal, but failing that you should be able to prevent the NoClassDefFoundError by declaring 2.10.1 as a direct dependency in your |
There may be other dependencies that require a lower version of gson which breaks stripe. The latest version of stripe compatible with gson 2.8.6 seems to be 22.3.0. |
Hello azavisha-snap, can you say more about
As far as I am aware, according to their Changelog GSON hasn't included a backwards-incompatible change since 2.8.5 (released in 2018). Is there a particular library you know of that has a dependency on old GSON? |
All right, I found it. Created a new project with the latest spring boot (3.0.5) and it works perfectly. Using the version (2.4.0) I use at my slightly old project it appears again. |
@richardm-stripe Yes, I know something that depends on an old version of GSON. It has nothing to do with Stripe so feel free to close this ticket. Thanks for your help. |
Thank you all! I am closing, but please feel free to comment/reopen if you can't find a version of GSON that satisfies all the constraints. |
Thank you very much for your answer
|
Describe the bug
After upgrading to
22.12.0
I get this error whenever I try to connect to its API:To Reproduce
Expected behavior
I expect it not to fail. First the codebase was at Java 17, but I found a GSON issue, so I downgraded it to Java 11, but the issue is still the same.
With
22.3.0
it works.Code snippets
No response
OS
macOS/Linux
Java version
Java 11
stripe-java version
v22.12.0
API version
2022-11-15
Additional context
No response
The text was updated successfully, but these errors were encountered: