相关文章推荐
帅气的勺子  ·  SQL Server ...·  8 月前    · 
坚强的梨子  ·  PostgreSQL 语法 | 菜鸟教程·  1 年前    · 
奔跑的斑马  ·  不再写 for 循环 - 知乎·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

java.lang.NoSuchMethodError: okhttp3.internal.Platform.log AND Exception in thread "Okhttp Dispatcher" java.lang.NoSuchFieldError: INSTANCE

Ask Question

Help me, please. I have okhttp3 and logging-interceptor 4.7.2 versions. I have java.lang.NoSuchMethodError: okhttp3.internal.Platform.log in "Okhttp Dispatcher" thread when I call ONVIF getDeviceInformation. If I set okhttp3 3.14.7 version I have java.lang.NoSuchFieldError: INSTANCE in "Okhttp Dispatcher" thread.

<modelVersion>4.0.0</modelVersion>
<groupId>prj.group.id</groupId>
<artifactId>art.id</artifactId>
<version>0.1.0</version>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.3.0.M4</version>
</parent>
<properties>
    <java-version>1.8</java-version>
</properties>
<dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-messaging</artifactId>
        <version>5.2.5.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-websocket</artifactId>
        <version>5.2.4.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.bytedeco</groupId>
        <artifactId>javacv</artifactId>
        <version>1.5.2</version>
    </dependency>
    <dependency>
        <groupId>org.bytedeco</groupId>
        <artifactId>ffmpeg</artifactId>
        <version>4.2.1-1.5.2</version>
    </dependency>
    <dependency>
        <groupId>org.bytedeco</groupId>
        <artifactId>ffmpeg-platform</artifactId>
        <version>4.2.1-1.5.2</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-core</artifactId>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.18.12</version>
    </dependency>
    <dependency>
        <groupId>be.teletask.onvif</groupId>
        <artifactId>onvif</artifactId>
        <version>1.0.2</version>
    </dependency>
</dependencies>
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>okhttp</artifactId>
            <version>4.7.2</version>
        </dependency>
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>logging-interceptor</artifactId>
            <version>4.7.2</version>
        </dependency>
        <dependency>
            <groupId>com.burgstaller</groupId>
            <artifactId>okhttp-digest</artifactId>
            <version>2.0</version>
        </dependency>
    </dependencies>
</dependencyManagement>
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>2.2.2.RELEASE</version>
        </plugin>
    </plugins>
</build>
<repositories>
</repositories>
<pluginRepositories>
</pluginRepositories>

Error in onError method when I call getDeviceInformation

OnvifManager manager = new OnvifManager();
manager.setOnvifResponseListener( new OnvifResponseListener() {
@Override
public void onError(OnvifDevice device, int I, String s) {
System.out.println(s);
manager.getDeviceInformation(onvifDevice, (device, information) -> {
// Don't reach this code
information.getModel();
  

I have okhttp3 and logging-interceptor 4.7.2 versions. I have java.lang.NoSuchMethodError: okhttp3.internal.Platform.log

It is a Dependency issue, You are using :

  • okhttp-4.7.2
  • logging-interceptor-4.7.2
  • okhttp-digest-2.0
  • Runtime dependency of okhttp-digest-2.0 is okhttp-4.0.1

    Maven Repo: https://mvnrepository.com/artifact/com.burgstaller/okhttp-digest/2.0

    So now you have two different versions of same library

    1.okhttp-4.0.1 from okhttp-digest-2.0

    2.okhttp-4.7.2

    There was a change in log function(Which is what error is saying NoSuchMethodError:okhttp3.internal.Platform.log) we can see in the image

    Solutions:

  • You Can Update version of okhttp-digest which can work with okhttp-4.7.2
  • You could exclude the okhttp dependency from okhttl-digest if you're not using the features relying on it.
  • Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.