Search code examples
gradlegradlew

How to correct the classpath of your application so that it contains a single compatible version


I have a micro service which is failing to start with the following error message:

2020-03-08T06:55:23.966752513Z ***************************
2020-03-08T06:55:23.966756613Z APPLICATION FAILED TO START
2020-03-08T06:55:23.966771414Z ***************************
2020-03-08T06:55:23.966775614Z 
2020-03-08T06:55:23.966779614Z Description:
2020-03-08T06:55:23.966783414Z 
2020-03-08T06:55:23.966787415Z An attempt was made to call the method okhttp3.HttpUrl.get(Ljava/lang/String;)Lokhttp3/HttpUrl; but it does not exist. Its class, okhttp3.HttpUrl, is available from the following locations:
2020-03-08T06:55:23.966791915Z 
2020-03-08T06:55:23.966795915Z     jar:file:/myapp/myapp.jar!/BOOT-INF/lib/okhttp-3.8.1.jar!/okhttp3/HttpUrl.class
2020-03-08T06:55:23.966865718Z 
2020-03-08T06:55:23.966876618Z It was loaded from the following location:
2020-03-08T06:55:23.966880919Z 
2020-03-08T06:55:23.966884919Z     jar:file:/myapp/myapp.jar!/BOOT-INF/lib/okhttp-3.8.1.jar!/
2020-03-08T06:55:23.966889119Z 
2020-03-08T06:55:23.966892919Z 
2020-03-08T06:55:23.966896719Z Action:
2020-03-08T06:55:23.966900719Z 
2020-03-08T06:55:23.966904520Z Correct the classpath of your application so that it contains a single, compatible version of okhttp3.HttpUrl
2020-03-08T06:55:23.966918320Z 

I am not directly using okhttp3, I am using two libraries that are using Microsoft keyvault and document libraries. The Microsoft libraries are using okhttp3 library.

Also, locally this service starts up but I only see this issue when I deploy to AWS.

How do I resolve it? Any help is appreciated and thanks in advance.

Thanks and regards, dj


Solution

  • You are loading it from 2 locations

    mvn dependency:tree

    Try to use maven exclusions in pom.xml to only get one instance of okhttp3 library.