Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events
SOLVED

Getting Java.lang.NoSuchMethodError with 6.5.17 Uber jar

Avatar

Level 3

Hi all,

 

I am trying build my project with new Uber jar 6.5.17.

I am getting

Java.lang.NoSuchMethodError: com.google.gson.internal.bind.ObjectaTyperAdapter.getFactory.

In the testing phase.

We have added the Gson(2.8.5)  dependency to the core POM file but still getting same error.

It was working file with 6.5.10 Uber jar.

Anyone knows how to fix it

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Make sure you added the Gson dependency before the Uber Jar. At least in the core pom.xml

        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.adobe.aem</groupId>
            <artifactId>uber-jar</artifactId>
        </dependency>

 

 

View solution in original post

4 Replies

Avatar

Correct answer by
Community Advisor

Make sure you added the Gson dependency before the Uber Jar. At least in the core pom.xml

        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.adobe.aem</groupId>
            <artifactId>uber-jar</artifactId>
        </dependency>

 

 

Avatar

Level 3

It resolved my issue.

Just for learning why we need to add Gson dependency before Uber?

Avatar

Community Advisor

Gson is also present in Uber Jar. But this gson is not scoped for unit tests(may be). When you add extra maven dependency for the unit test it needs to place before Uber Jar. Because you want to initialize the Gson from the Gson maven dependency for classpath priority.

Avatar

Level 1

I faced the same issue, but in my case the dependency was org.apache.poi and after coming across your issue-answer, I was able to fix it.

Thanks so much @Sady_Rifat for the answer.