-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 run failed #2228
Comments
Hi @SandNight, could you share a sample repo? |
I am pretty sure there are conflicting versions of Spring dependencies. So, nothing to do with Jib. Even if the app works locally, it may fail in docker just because .jars are placed into the classpath in random order and different classes are loaded. |
as @kan-izh said, it's quite possible that the ordering of dependency loading is messing this up. Especially if this works locally. Can you run
inspect the copied dependencies by looking for
presumably if the theory holds true, you will see more than one instance of this class in multiple jar files? |
thank you,I should have found the problem $ grep SpringFactoriesLoader.class -r * |
So there are two parts of this problem:
|
@SandNight I'm interested in the problem. I develop Linkage Checker Enforcer rule to detect such incompatible libraries in your project: |
Try building this with Java 11. That might detect split package issues and same classes in multiple jars that Java 8 won't warn about. |
@SandNight we didn't hear from you for a while. We will assume that the issue is due to a class loading order at runtime that is different from that of the dependency order listed in your |
@SandNight @kan-izh we've released Jib 2.7.0 which added a new configuration option (
instead of the default
Expanding the dependency list can be useful in AppCDS too. Note that an expanded dependency list can become very long in practice, and we are not sure if there may be a potential issue due to a long command line ("argument list too long" or "command line is too long"). As with other Jib configurations, this option can also be set through the system property ( |
Environment:
Description of the issue:
run jib-maven-plugin:1.8.0:dockerBuild in idea
the image build successful
but when I run this image, failed
Maybe the JDK configuration is wrong
What should I do
Expected behavior:
run success
Steps to reproduce:
jib-maven-plugin
Configuration:Log output:
/Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk/Contents/Home/bin/java -Dvisualvm.id=2681117957594 -Dmaven.multiModuleProjectDirectory=/Users/jade/work/workspace/test/test-auth/test-auth-server -Dmaven.home=/Users/jade/work/software/apache-maven-3.6.1 -Dclassworlds.conf=/Users/jade/work/software/apache-maven-3.6.1/bin/m2.conf "-Dmaven.ext.class.path=/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven-event-listener.jar" "-javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=50153:/Applications/IntelliJ IDEA.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath /Users/jade/work/software/apache-maven-3.6.1/boot/plexus-classworlds-2.6.0.jar org.codehaus.classworlds.Launcher -Didea.version2019.3.1 -s /Users/jade/work/software/apache-maven-3.6.1/conf/settings.xml -DskipTests=true com.google.cloud.tools:jib-maven-plugin:1.8.0:dockerBuild -P dev
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.test:test-auth-server:jar:1.0-SNAPSHOT
[WARNING] 'dependencyManagement.dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.alibaba:fastjson:jar -> duplicate declaration of version 1.2.60 @ com.test:test-dependencies:1.0.2, /Users/jade/work/software/maven_repository/com/test/test-dependencies/1.0.2/test-dependencies-1.0.2.pom, line 3179, column 25
[WARNING] 'dependencyManagement.dependencies.dependency.version' for com.test.cloud:test-cloud-starter:jar is either LATEST or RELEASE (both of them are being deprecated) @ com.test:test-dependencies:1.0.2, /Users/jade/work/software/maven_repository/com/test/test-dependencies/1.0.2/test-dependencies-1.0.2.pom, line 3187, column 26
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ----------------------< com.test:test-auth-server >-----------------------
[INFO] Building test-auth-server 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from test: http://172.16.6.124:8044/nexus/repository/maven-public/com/test/test-auth-api/1.0.4-SNAPSHOT/maven-metadata.xml
Downloaded from test: http://172.16.6.124:8044/nexus/repository/maven-public/com/test/test-auth-api/1.0.4-SNAPSHOT/maven-metadata.xml (772 B at 3.4 kB/s)
Downloading from test: http://172.16.6.124:8044/nexus/repository/maven-public/com/test/cloud/test-cloud-starter/1.0.6-SNAPSHOT/maven-metadata.xml
Downloaded from test: http://172.16.6.124:8044/nexus/repository/maven-public/com/test/cloud/test-cloud-starter/1.0.6-SNAPSHOT/maven-metadata.xml (780 B at 52 kB/s)
Downloading from test: http://172.16.6.124:8044/nexus/repository/maven-public/com/test/test-utils/1.0-SNAPSHOT/maven-metadata.xml
Downloaded from test: http://172.16.6.124:8044/nexus/repository/maven-public/com/test/test-utils/1.0-SNAPSHOT/maven-metadata.xml (760 B at 51 kB/s)
Downloading from test: http://172.16.6.124:8044/nexus/repository/maven-public/com/test/test-base/1.0-SNAPSHOT/maven-metadata.xml
Downloaded from test: http://172.16.6.124:8044/nexus/repository/maven-public/com/test/test-base/1.0-SNAPSHOT/maven-metadata.xml (588 B at 42 kB/s)
[INFO]
[INFO] --- jib-maven-plugin:1.8.0:dockerBuild (default-cli) @ test-auth-server ---
[WARNING] is deprecated; use with the value USE_CURRENT_TIMESTAMP instead
[WARNING] Setting image creation time to current time; your image may not be reproducible.
[INFO]
[INFO] Containerizing application to Docker daemon as harbor.test.com/test-auth/test-auth-server:dev-1.0-SNAPSHOT...
[WARNING] Base image 'openjdk:alpine' does not use a specific image digest - build may not be reproducible
[INFO] Getting manifest for base image openjdk:alpine...
[INFO] Building dependencies layer...
[INFO] Building resources layer...
[INFO] Building snapshot dependencies layer...
[INFO] Building classes layer...
[INFO] The base image requires auth. Trying again for openjdk:alpine...
[INFO] Retrieving registry credentials for registry-1.docker.io...
[WARNING] The credential helper (docker-credential-desktop) has nothing for server URL: registry-1.docker.io
Got output:
credentials not found in native keychain
[WARNING] The credential helper (docker-credential-desktop) has nothing for server URL: registry.hub.docker.com
Got output:
credentials not found in native keychain
[WARNING] The credential helper (docker-credential-desktop) has nothing for server URL: index.docker.io
Got output:
credentials not found in native keychain
[WARNING] The credential helper (docker-credential-desktop) has nothing for server URL: docker.io
Got output:
credentials not found in native keychain
[INFO] Using base image with digest: sha256:d4c84528b8de75bf40ef402e7b02ffe60c5ae834a702e510664be1f6fc03d510
[INFO]
[INFO] Container entrypoint set to [java, -Xms512m, -cp, /app/resources:/app/classes:/app/libs/*, com.test.auth.server.AuthServerApplication]
[INFO] Loading to Docker daemon...
[INFO]
[INFO] Built image to Docker daemon as harbor.test.com/test-auth/test-auth-server:dev-1.0-SNAPSHOT
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15.254 s
[INFO] Finished at: 2020-01-14T09:34:38+08:00
[INFO] ------------------------------------------------------------------------
docker run log
Exception in thread "main" java.lang.IllegalAccessError: tried to access method org.springframework.core.io.support.SpringFactoriesLoader.loadFactoryNames(Ljava/lang/Class;Ljava/lang/ClassLoader;)Ljava/util/List; from class org.springframework.boot.SpringApplication
at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:418)
at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:412)
at org.springframework.boot.SpringApplication.(SpringApplication.java:268)
at org.springframework.boot.SpringApplication.(SpringApplication.java:249)
at org.springframework.boot.builder.SpringApplicationBuilder.createSpringApplication(SpringApplicationBuilder.java:104)
at org.springframework.boot.builder.SpringApplicationBuilder.(SpringApplicationBuilder.java:92)
at com.test.auth.server.AuthServerApplication.main(AuthServerApplication.java:22)
Additional Information:
host
172.16.5.111 harbor.test.com
The text was updated successfully, but these errors were encountered: