TheoKanning / openai-java

OpenAI Api Client in Java
MIT License
4.79k stars 1.22k forks source link

java.lang.NoClassDefFoundError: retrofit2/converter/jackson/JacksonConverterFactory #50

Closed Tjalf2 closed 1 year ago

Tjalf2 commented 1 year ago

I am facing the issue below: Exception in thread "main" java.lang.NoClassDefFoundError: retrofit2/converter/jackson/JacksonConverterFactory at com.example.journaling.OpenAiApi.main(OpenAiApi.java:8) Caused by: java.lang.ClassNotFoundException: retrofit2.converter.jackson.JacksonConverterFactory at java.net.URLClassLoader.findClass(URLClassLoader.java:382) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 1 more

My gradle build looks like this: dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'androidx.appcompat:appcompat:1.0.2' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' implementation 'com.theokanning.openai-gpt3-java:client:0.8.1'

Does somebody know how to fix this issue. Would really appreciate it.

madppiper commented 1 year ago

I have the same problem.

cryptoapebot commented 1 year ago

This is my list of jar versions. Obviously some of them are for the application I have and not this and are out of date, but maybe this one?

https://mvnrepository.com/artifact/com.squareup.retrofit2/converter-jackson/2.9.0

adapter-rxjava2-2.9.0.jar api-0.6.0.jar api-0.6.0-sources.jar api-0.8.0.jar api-0.8.1.jar client-0.6.0.jar client-0.8.0.jar client-0.8.1.jar com.fasterxml.jackson.databind-2.10.3.LIFERAY-PATCHED-1.jar converter-jackson-2.9.0.jar fuzzywuzzy-1.3.0.jar gson-2.9.0.jar gson-2.9.1.jar guava-31.1-jre.jar jackson-annotations-2.13.4.jar jackson-core-2.13.4.jar jackson-databind-2.13.4.jar java-json-canonicalization-1.1.jar jna-5.12.1.jar json-20140107.jar junit-jupiter-api-5.9.1.jar kotlin-runtime-1.2.71.jar kotlin-stdlib-1.6.21.jar kotlin-stdlib-common-1.6.21.jar lombok-1.18.20.jar lombok-1.18.24.jar okhttp-4.10.0.jar okio-2.10.0.jar okio-3.1.0.jar reactive-streams-1.0.3.jar retrofit-2.9.0.jar retrofit2-rxjava2-adapter-1.0.0.jar rxjava-2.2.21.jar tf-gpt-2-2.1.0.jar

marcodimakis commented 1 year ago

I'm also getting this issue and using the converter-jackson package did not fix it. Is it because I also have to add all the other jackson packages?

cryptoapebot commented 1 year ago

maybe try this one. https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind I don't remember why I am using a patched one, but I'll try that one next.

Actually going back, it might not be the jackson packages at all. It might be a version issue w/ one of these.

retrofit-2.9.0.jar retrofit2-rxjava2-adapter-1.0.0.jar rxjava-2.2.21.jar

PixMod commented 1 year ago

Need implementation 'com.squareup.retrofit2:converter-jackson:2.1.0'

cryptoapebot commented 1 year ago

https://mvnrepository.com/artifact/com.squareup.retrofit2/converter-jackson

I'm looking in my current libs, though, I just have:

jackson-annotations-2.14.1.jar
jackson-core-2.14.1.jar
jackson-databind-2.14.1.jar
retrofit-2.9.0.jar
rxjava-2.2.21.jar
okhttp-4.10.0.jar
okio-3.2.0.jar