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

Docker logs throws NoSuchMethodError #88

Closed
ieggel opened this issue Nov 15, 2019 · 3 comments
Closed

Docker logs throws NoSuchMethodError #88

ieggel opened this issue Nov 15, 2019 · 3 comments

Comments

@ieggel
Copy link

ieggel commented Nov 15, 2019

Is this a BUG REPORT or FEATURE REQUEST?: BUG

Description

When calling DockerClient#logs a java.lang.NoSuchMethodError with message java.nio.ByteBuffer.position(I)Ljava/nio/ByteBuffer is thrown. As of my current research, this seems to be a problem when compiling with Java > 9 for a target JVM < 9. I'm using Java 8 on my current project.
Found some useful information here: https://www.baeldung.com/maven-java-version. This states that By default, the -source and -target options don't guarantee a cross-compilation.

Probably we should have something like this in the pom.xml:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.1</version>
    <configuration>
        <release>8</release>
    </configuration>
</plugin>

instead of:

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>

How to reproduce

Run a simple Java project on Java 1.8 which contains the following class:

import org.mandas.docker.client.DefaultDockerClient;
import org.mandas.docker.client.DockerClient;
import org.mandas.docker.client.DockerClient.LogsParam;
import org.mandas.docker.client.LogStream;
import org.mandas.docker.client.exceptions.DockerCertificateException;
import org.mandas.docker.client.exceptions.DockerException;

public class TestDockerClient {
	
	public static void main(String[] args) throws DockerCertificateException, DockerException, InterruptedException {
        DockerClient docker = DefaultDockerClient.fromEnv().build();
        
        String existingContainerId = "dfa449ae6603";
        LogStream ls = docker.logs(existingContainerId, LogsParam.stderr(), 
        		LogsParam.stdout(), LogsParam.since(0));
        
        //Error thrown here
        System.out.println(ls.hasNext());
	}
	
}

What do you expect

I would expect ls.hasNext() to return a boolean.

What happened instead

ls.hasNext() throws java.lang.NoSuchMethodError: java.nio.ByteBuffer.position(I)Ljava/nio/ByteBuffer Error.

Software:

  • docker version:
Client: Docker Engine - Community
 Version:           19.03.1
 API version:       1.40
 Go version:        go1.12.5
 Git commit:        74b1e89e8a
 Built:             Thu Jul 25 21:21:35 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.1
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.5
  Git commit:       74b1e89e8a
  Built:            Thu Jul 25 21:20:09 2019
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.2.6
  GitCommit:        894b81a4b802e4eb2a91d1ce216b8817763c29fb
 runc:
  Version:          1.0.0-rc8
  GitCommit:        425e105d5a03fabd737a126ad93d62a9eeede87f
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

  • Spotify's docker-client version: org.mandas:docker-client:2.0.1:shaded

Full backtrace

Exception in thread "main" java.lang.NoSuchMethodError: java.nio.ByteBuffer.position(I)Ljava/nio/ByteBuffer;
	at org.mandas.docker.client.LogReader.nextMessage(LogReader.java:61)
	at org.mandas.docker.client.DefaultLogStream.computeNext(DefaultLogStream.java:56)
	at org.mandas.docker.client.DefaultLogStream.computeNext(DefaultLogStream.java:35)
	at org.mandas.docker.client.shaded.com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:141)
	at org.mandas.docker.client.shaded.com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:136)
	at org.mandas.docker.client.DefaultLogStream.readFully(DefaultLogStream.java:77)
	at TestDockerClient.TestDockerClient.main(TestDockerClient.java:27)
@dmandalidis
Copy link
Owner

Good catch! I wasn't aware of that, I found out that jdk9 introduced different types for some of the java.nio.ByteBuffer methods. Working into it...

@dmandalidis
Copy link
Owner

It won't be that easy, after configuring the maven-compiler-plugin properly, I ran into JDK-8212233 which seems to be partially backported to jdk11. Omitting javadoc is not an option, so I guess I 'm going to drop jdk11 support, reopen #7, and backport until 1.1.x :(

Going to give it another try tomorrow...

@dmandalidis dmandalidis changed the title Docker logs throws NoSuchMethodError Proper cross-compile configuration (fixes #88) Nov 16, 2019
@dmandalidis
Copy link
Owner

It seems that a <failOnError>false</failOnError> in the javadoc plugin's configuration works around the error while javadoc is properly generating and docker logs is working properly

@dmandalidis dmandalidis changed the title Proper cross-compile configuration (fixes #88) Docker logs throws NoSuchMethodError Nov 16, 2019
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

2 participants