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/internal/reflect/ReflectionAccessor #168

Closed
NickKanellos opened this issue Mar 15, 2022 · 4 comments
Assignees

Comments

@NickKanellos
Copy link

Hey, ya'll. Do ya'll know about this?

Cross posting this issue here: IBM/cloudant-java-sdk#253 & IBM/cloudant-java-sdk#236

Describe the bug

java.lang.NoClassDefFoundError: com/google/gson/internal/reflect/ReflectionAccessor
 at com.ibm.cloud.sdk.core.util.DynamicModelTypeAdapterFactory.(DynamicModelTypeAdapterFactory.java:77)
 at com.ibm.cloud.sdk.core.util.GsonSingleton.registerTypeAdapters(GsonSingleton.java:77)
 at com.ibm.cloud.sdk.core.util.GsonSingleton.createGson(GsonSingleton.java:53)
 at com.ibm.cloud.sdk.core.util.GsonSingleton.getGsonWithoutPrettyPrinting(GsonSingleton.java:102)
 at com.ibm.cloud.sdk.core.http.RequestBuilder.bodyContent(RequestBuilder.java:417)
 at com.ibm.cloud.cloudant.v1.Cloudant.postDocument(Cloudant.java:825)

To Reproduce

call com.ibm.cloud.cloudant.v1.Cloudant.postDocument() using

<dependency>
     <groupId>com.ibm.cloud</groupId>
     <artifactId>cloudant</artifactId>
     <version>0.0.36</version>
</dependency>

and

<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
    <groupId>com.google.code.gson</groupId>
    <artifactId>gson</artifactId>
    <version>2.9.0</version>
</dependency>

Unfortunately I can't use an earlier version of GSON because of this:
google/gson#1875
and this
google/gson#1902

Must gather (please complete the following information):

$ java --version
openjdk 16.0.2 2021-07-20
OpenJDK Runtime Environment Temurin-16.0.2+7 (build 16.0.2+7)
OpenJDK 64-Bit Server VM Temurin-16.0.2+7 (build 16.0.2+7, mixed mode, sharing)
@padamstx
Copy link
Member

Yes, we're aware that SDKs cannot yet upgrade to gson 2.9.0. The latest version the java core can use is currently 2.8.9, and we have an issue on our backlog to migrate to gson 2.9.0:
https://github.ibm.com/arf/planning-sdk-squad/issues/3106

@padamstx
Copy link
Member

Version 9.15.5 of the java core has been released which bumps up the gson dependency to 2.9.0.

@japhet99
Copy link

japhet99 commented Apr 7, 2023

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

@padamstx
Copy link
Member

@japhet99 Your problem doesn't appear to be an issue with this particular repository. You must be using gson in a different context.

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

3 participants