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

java.lang.NoClassDefFoundError: com/google/gson/ReflectionAccessFilter #1525

Closed
mudlee opened this issue Mar 15, 2023 · 13 comments
Closed

java.lang.NoClassDefFoundError: com/google/gson/ReflectionAccessFilter #1525

mudlee opened this issue Mar 15, 2023 · 13 comments
Assignees
Labels

Comments

@mudlee
Copy link

mudlee commented Mar 15, 2023

Describe the bug

After upgrading to 22.12.0 I get this error whenever I try to connect to its API:

java.lang.NoClassDefFoundError: com/google/gson/ReflectionAccessFilter
	at ***.jobs.PaymentJob.testStripeFailure(PaymentJob.java:35) ~[classes/:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
	at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84) ~[spring-context-5.3.1.jar:5.3.1]
	at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) ~[spring-context-5.3.1.jar:5.3.1]
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[na:na]
	at java.base/java.util.concurrent.FutureTask.runAndReset$$$capture(FutureTask.java:305) ~[na:na]
	at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java) ~[na:na]
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) ~[na:na]
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
	at java.base/java.lang.Thread.run(Thread.java:829) ~[na:na]
Caused by: java.lang.ClassNotFoundException: com.google.gson.ReflectionAccessFilter
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) ~[na:na]
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[na:na]
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[na:na]
	... 14 common frames omitted

To Reproduce

  1. Create a new Java 11 project
  2. Import Stripe
  3. Try to run the following code (it's a Springboot job):
  @Scheduled(fixedRate = 60000, initialDelay = 5000)
  public void testStripeFailure() {
    logger.info("Running cron");
    final var params =
        PaymentMethodListParams.builder()
            .setType(PaymentMethodListParams.Type.CARD)
            .setCustomer("***")
            .build();

    logger.error("BEFORE GET");
    try {
      String url = ApiResource.fullUrl(Stripe.getApiBase(), options(), "/v1/payment_methods"); // <--- ERRORS HERE
    } catch (StripeException e) {
      throw new RuntimeException(e);
    }
    logger.error("AFTER GET");
  }

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

@mudlee mudlee added the bug label Mar 15, 2023
@richardm-stripe
Copy link
Contributor

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? ApiResource.fullUrl doesn't throw StripeException so my adaptation of your snippet won't compile.

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.

@mudlee
Copy link
Author

mudlee commented Mar 16, 2023

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.
Here is an issue where the guys face with something similar. Maybe. IBM/java-sdk-core#168

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>

@mudlee mudlee removed their assignment Mar 16, 2023
@richardm-stripe
Copy link
Contributor

Hi mudlee. What is your version of GSON? ReflectionAccessFilter (added to stripe-java in
#1496) is only available in Gson 2.9.1. Are you able to upgrade your version of GSON to 2.9.1 or newer?

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.

@mudlee
Copy link
Author

mudlee commented Mar 20, 2023

@richardm-stripe I'm not using gson at all. Stripe uses it internally. Am I wrong?

@richardm-stripe
Copy link
Contributor

@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 com/google/gson/ReflectionAccessFilter being undefined.

Can you run mvn dependency:tree (or ./gradlew dependencies if you use gradle) to see what version of GSON is being used, and where it is coming from?

@richardm-stripe richardm-stripe assigned mudlee and unassigned mudlee Mar 21, 2023
@mudlee
Copy link
Author

mudlee commented Mar 22, 2023

Stripe related

[INFO] +- com.stripe:stripe-java:jar:22.12.0:compile
[INFO] |  \- com.google.code.gson:gson:jar:2.8.6:runtime

Full

[INFO] global.iop:payment:jar:0.3.0
[INFO] +- org.springframework.boot:spring-boot-starter-webflux:jar:2.5.2:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter:jar:2.4.0:compile
[INFO] |  |  +- org.springframework.boot:spring-boot:jar:2.4.0:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-autoconfigure:jar:2.4.0:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-logging:jar:2.4.0:compile
[INFO] |  |  |  +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] |  |  |  |  \- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] |  |  |  +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.13.3:compile
[INFO] |  |  |  |  \- org.apache.logging.log4j:log4j-api:jar:2.13.3:compile
[INFO] |  |  |  \- org.slf4j:jul-to-slf4j:jar:1.7.30:compile
[INFO] |  |  +- jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile
[INFO] |  |  \- org.yaml:snakeyaml:jar:1.27:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-json:jar:2.4.0:compile
[INFO] |  |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.11.3:compile
[INFO] |  |  |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.11.3:compile
[INFO] |  |  |  \- com.fasterxml.jackson.core:jackson-core:jar:2.11.3:compile
[INFO] |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.11.3:compile
[INFO] |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.11.3:compile
[INFO] |  |  \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.11.3:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-reactor-netty:jar:2.4.0:compile
[INFO] |  |  \- io.projectreactor.netty:reactor-netty-http:jar:1.0.1:compile
[INFO] |  |     +- io.netty:netty-codec-http:jar:4.1.54.Final:compile
[INFO] |  |     |  +- io.netty:netty-common:jar:4.1.54.Final:compile
[INFO] |  |     |  +- io.netty:netty-buffer:jar:4.1.54.Final:compile
[INFO] |  |     |  +- io.netty:netty-transport:jar:4.1.54.Final:compile
[INFO] |  |     |  \- io.netty:netty-codec:jar:4.1.54.Final:compile
[INFO] |  |     +- io.netty:netty-codec-http2:jar:4.1.54.Final:compile
[INFO] |  |     +- io.netty:netty-resolver-dns:jar:4.1.54.Final:compile
[INFO] |  |     |  +- io.netty:netty-resolver:jar:4.1.54.Final:compile
[INFO] |  |     |  \- io.netty:netty-codec-dns:jar:4.1.54.Final:compile
[INFO] |  |     \- io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.54.Final:compile
[INFO] |  |        \- io.netty:netty-transport-native-unix-common:jar:4.1.54.Final:compile
[INFO] |  +- org.springframework:spring-web:jar:5.3.1:compile
[INFO] |  |  \- org.springframework:spring-beans:jar:5.3.1:compile
[INFO] |  \- org.springframework:spring-webflux:jar:5.3.1:compile
[INFO] +- org.springframework.boot:spring-boot-starter-validation:jar:2.5.2:compile
[INFO] |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:9.0.39:compile
[INFO] |  \- org.hibernate.validator:hibernate-validator:jar:6.1.6.Final:compile
[INFO] |     +- jakarta.validation:jakarta.validation-api:jar:2.0.2:compile
[INFO] |     +- org.jboss.logging:jboss-logging:jar:3.4.1.Final:compile
[INFO] |     \- com.fasterxml:classmate:jar:1.5.1:compile
[INFO] +- org.springframework.boot:spring-boot-starter-security:jar:2.5.2:compile
[INFO] |  +- org.springframework:spring-aop:jar:5.3.1:compile
[INFO] |  +- org.springframework.security:spring-security-config:jar:5.4.1:compile
[INFO] |  |  +- org.springframework.security:spring-security-core:jar:5.4.1:compile
[INFO] |  |  \- org.springframework:spring-context:jar:5.3.1:compile
[INFO] |  \- org.springframework.security:spring-security-web:jar:5.4.1:compile
[INFO] |     \- org.springframework:spring-expression:jar:5.3.1:compile
[INFO] +- org.springframework.boot:spring-boot-starter-actuator:jar:2.5.2:compile
[INFO] |  +- org.springframework.boot:spring-boot-actuator-autoconfigure:jar:2.4.0:compile
[INFO] |  |  \- org.springframework.boot:spring-boot-actuator:jar:2.4.0:compile
[INFO] |  \- io.micrometer:micrometer-core:jar:1.6.1:compile
[INFO] |     +- org.hdrhistogram:HdrHistogram:jar:2.1.12:compile
[INFO] |     \- org.latencyutils:LatencyUtils:jar:2.0.3:runtime
[INFO] +- io.projectreactor:reactor-test:jar:3.4.7:test
[INFO] |  \- io.projectreactor:reactor-core:jar:3.4.0:compile
[INFO] |     \- org.reactivestreams:reactive-streams:jar:1.0.3:compile
[INFO] +- org.springframework.boot:spring-boot-starter-data-r2dbc:jar:2.5.2:compile
[INFO] |  +- org.springframework.data:spring-data-r2dbc:jar:1.2.1:compile
[INFO] |  |  +- org.springframework.data:spring-data-commons:jar:2.4.1:compile
[INFO] |  |  +- org.springframework.data:spring-data-relational:jar:2.1.1:compile
[INFO] |  |  +- org.springframework:spring-r2dbc:jar:5.3.1:compile
[INFO] |  |  \- org.springframework:spring-tx:jar:5.3.1:compile
[INFO] |  +- io.r2dbc:r2dbc-spi:jar:0.8.3.RELEASE:compile
[INFO] |  \- io.r2dbc:r2dbc-pool:jar:0.8.5.RELEASE:compile
[INFO] |     \- io.projectreactor.addons:reactor-pool:jar:0.2.0:compile
[INFO] +- io.r2dbc:r2dbc-postgresql:jar:0.8.8.RELEASE:compile
[INFO] |  +- com.ongres.scram:client:jar:2.1:compile
[INFO] |  |  \- com.ongres.scram:common:jar:2.1:compile
[INFO] |  |     \- com.ongres.stringprep:saslprep:jar:1.1:compile
[INFO] |  |        \- com.ongres.stringprep:stringprep:jar:1.1:compile
[INFO] |  \- io.projectreactor.netty:reactor-netty:jar:1.0.1:compile
[INFO] |     +- io.projectreactor.netty:reactor-netty-core:jar:1.0.1:compile
[INFO] |     |  +- io.netty:netty-handler:jar:4.1.54.Final:compile
[INFO] |     |  \- io.netty:netty-handler-proxy:jar:4.1.54.Final:compile
[INFO] |     |     \- io.netty:netty-codec-socks:jar:4.1.54.Final:compile
[INFO] |     \- io.projectreactor.netty:reactor-netty-http-brave:jar:1.0.1:runtime
[INFO] |        \- io.zipkin.brave:brave-instrumentation-http:jar:5.13.1:runtime
[INFO] |           \- io.zipkin.brave:brave:jar:5.13.1:runtime
[INFO] |              \- io.zipkin.reporter2:zipkin-reporter-brave:jar:2.16.0:runtime
[INFO] |                 \- io.zipkin.reporter2:zipkin-reporter:jar:2.16.0:runtime
[INFO] |                    \- io.zipkin.zipkin2:zipkin:jar:2.22.2:runtime
[INFO] +- org.postgresql:postgresql:jar:42.2.22:compile
[INFO] |  \- org.checkerframework:checker-qual:jar:3.5.0:runtime
[INFO] +- com.stripe:stripe-java:jar:22.12.0:compile
[INFO] |  \- com.google.code.gson:gson:jar:2.8.6:runtime
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.5.2:test
[INFO] |  +- org.springframework.boot:spring-boot-test:jar:2.4.0:test
[INFO] |  +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.4.0:test
[INFO] |  +- com.jayway.jsonpath:json-path:jar:2.4.0:test
[INFO] |  |  \- net.minidev:json-smart:jar:2.3:test
[INFO] |  |     \- net.minidev:accessors-smart:jar:1.2:test
[INFO] |  |        \- org.ow2.asm:asm:jar:5.0.4:test
[INFO] |  +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.3:test
[INFO] |  |  \- jakarta.activation:jakarta.activation-api:jar:1.2.2:test
[INFO] |  +- org.assertj:assertj-core:jar:3.18.1:test
[INFO] |  +- org.hamcrest:hamcrest:jar:2.2:test
[INFO] |  +- org.junit.jupiter:junit-jupiter:jar:5.7.0:test
[INFO] |  |  +- org.junit.jupiter:junit-jupiter-api:jar:5.7.0:test
[INFO] |  |  |  +- org.apiguardian:apiguardian-api:jar:1.1.0:test
[INFO] |  |  |  +- org.opentest4j:opentest4j:jar:1.2.0:test
[INFO] |  |  |  \- org.junit.platform:junit-platform-commons:jar:1.7.0:test
[INFO] |  |  +- org.junit.jupiter:junit-jupiter-params:jar:5.7.0:test
[INFO] |  |  \- org.junit.jupiter:junit-jupiter-engine:jar:5.7.0:test
[INFO] |  |     \- org.junit.platform:junit-platform-engine:jar:1.7.0:test
[INFO] |  +- org.mockito:mockito-core:jar:3.6.0:test
[INFO] |  |  +- net.bytebuddy:byte-buddy:jar:1.10.18:test
[INFO] |  |  +- net.bytebuddy:byte-buddy-agent:jar:1.10.18:test
[INFO] |  |  \- org.objenesis:objenesis:jar:3.1:test
[INFO] |  +- org.mockito:mockito-junit-jupiter:jar:3.6.0:test
[INFO] |  +- org.skyscreamer:jsonassert:jar:1.5.0:test
[INFO] |  |  \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
[INFO] |  +- org.springframework:spring-core:jar:5.3.1:compile
[INFO] |  |  \- org.springframework:spring-jcl:jar:5.3.1:compile
[INFO] |  +- org.springframework:spring-test:jar:5.3.1:test
[INFO] |  \- org.xmlunit:xmlunit-core:jar:2.7.0:test
[INFO] +- org.liquibase:liquibase-core:jar:3.10.3:test
[INFO] |  +- javax.xml.bind:jaxb-api:jar:2.3.1:test
[INFO] |  |  \- javax.activation:javax.activation-api:jar:1.2.0:test
[INFO] |  \- org.slf4j:slf4j-api:jar:1.7.30:compile
[INFO] \- org.springframework.boot:spring-boot-starter-jdbc:jar:2.5.2:test
[INFO]    +- com.zaxxer:HikariCP:jar:3.4.5:test
[INFO]    \- org.springframework:spring-jdbc:jar:5.3.1:test
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.155 s
[INFO] Finished at: 2023-03-22T07:23:54+01:00
[INFO] ------------------------------------------------------------------------

@richardm-stripe
Copy link
Contributor

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 gson.version that controls what is installed.

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 pom.xml

@azavisha-snap
Copy link

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.

@richardm-stripe
Copy link
Contributor

Hello azavisha-snap, can you say more about

There may be other dependencies that require a lower version of gson which breaks stripe

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?

@mudlee
Copy link
Author

mudlee commented Mar 28, 2023

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.
So it's a spring-boot kind-a-related issue, please feel free to close this one.

@azavisha-snap
Copy link

@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.

@richardm-stripe
Copy link
Contributor

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.

@japhet99
Copy link

japhet99 commented Apr 7, 2023

描述错误

升级到之后,22.12.0每当我尝试连接到它的 API 时都会收到此错误:

java.lang.NoClassDefFoundError: com/google/gson/ReflectionAccessFilter
	at ***.jobs.PaymentJob.testStripeFailure(PaymentJob.java:35) ~[classes/:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
	at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84) ~[spring-context-5.3.1.jar:5.3.1]
	at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) ~[spring-context-5.3.1.jar:5.3.1]
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[na:na]
	at java.base/java.util.concurrent.FutureTask.runAndReset$$$capture(FutureTask.java:305) ~[na:na]
	at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java) ~[na:na]
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) ~[na:na]
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
	at java.base/java.lang.Thread.run(Thread.java:829) ~[na:na]
Caused by: java.lang.ClassNotFoundException: com.google.gson.ReflectionAccessFilter
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) ~[na:na]
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[na:na]
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[na:na]
	... 14 common frames omitted

重现

  1. 创建一个新的 Java 11 项目
  2. 进口条纹
  3. 尝试运行以下代码(这是一个 Springboot 作业):
  @Scheduled(fixedRate = 60000, initialDelay = 5000)
  public void testStripeFailure() {
    logger.info("Running cron");
    final var params =
        PaymentMethodListParams.builder()
            .setType(PaymentMethodListParams.Type.CARD)
            .setCustomer("***")
            .build();

    logger.error("BEFORE GET");
    try {
      String url = ApiResource.fullUrl(Stripe.getApiBase(), options(), "/v1/payment_methods"); // <--- ERRORS HERE
    } catch (StripeException e) {
      throw new RuntimeException(e);
    }
    logger.error("AFTER GET");
  }

预期行为

我希望它不会失败。首先代码库是 Java 17,但我发现了一个 GSON 问题,所以我将它降级到 Java 11,但问题仍然存在。

有了22.3.0它就可以了。

代码片段

没有反应

操作系统

macOS/Linux

Java版

Java 11

条纹Java版本

v22.12.0

接口版本

2022-11-15

附加上下文

没有反应

Thank you very much for your answer
good ,I try to use 22.3.0,is ok,successful ,
last , look my pom.xml and picture

pom.xml

<!--  stripe   begin -->
        <dependency>
            <groupId>com.sparkjava</groupId>
            <artifactId>spark-core</artifactId>
            <version>2.9.4</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.10.1</version>
        </dependency>
        <dependency>
            <groupId>com.stripe</groupId>
            <artifactId>stripe-java</artifactId>
            <version>22.3.0</version>
        </dependency>
        <!--  stripe  end -->

java code

@Test
    public void test1() throws StripeException {
        Map<String, Object> params = new HashMap<>();
        params.put("name", "product1 ----");
        List<String> list = new ArrayList<>();
        for (String pic : "a.jpg,b.jpg,c.jpg".split(",")) {
            list.add(pic);
        }
        params.put("images", list);
        params.put("description", "描述。。。");
        logger.info("----------");
        Product product = Product.create(params);
//        Product product = stripeService.createProduct(params);
        logger.info("-----"+product.toString());
    }

picture
image
image

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

No branches or pull requests

4 participants