docker run failed
See original GitHub issueEnvironment:
- Jib version: 1.8.0
- Build tool: Maven 3.6.1
- OS: Mac 10.15.2
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:
- dockerBuild
- run image
jib-maven-plugin
Configuration:
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>1.8.0</version>
<configuration>
<to>
<image>harbor.test.com/${project.parent.artifactId}/${project.artifactId}:${env}-${project.version}</image>
</to>
<from>
<image>openjdk:alpine</image>
</from>
<container>
<mainClass>com.test.auth.server.AuthServerApplication</mainClass>
<jvmFlags>
<jvmFlag>-Xms512m</jvmFlag>
</jvmFlags>
<ports>
<port>9082</port>
</ports>
<environment>
<TZ>Asia/Shanghai</TZ>
</environment>
<volumes>/tmp</volumes>
<useCurrentTimestamp>true</useCurrentTimestamp>
<labels>
<maintainer>jade</maintainer>
</labels>
</container>
<allowInsecureRegistries>true</allowInsecureRegistries>
</configuration>
</plugin>
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] <container><useCurrentTimestamp> is deprecated; use <container><creationTime> 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.<init>(SpringApplication.java:268) at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:249) at org.springframework.boot.builder.SpringApplicationBuilder.createSpringApplication(SpringApplicationBuilder.java:104) at org.springframework.boot.builder.SpringApplicationBuilder.<init>(SpringApplicationBuilder.java:92) at com.test.auth.server.AuthServerApplication.main(AuthServerApplication.java:22)
Additional Information: host 172.16.5.111 harbor.test.com
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (7 by maintainers)
Top GitHub Comments
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
SpringFactoriesLoader
(assuming linux)presumably if the theory holds true, you will see more than one instance of this class in multiple jar files?
@SandNight @kan-izh we’ve released Jib 2.7.0 which added a new configuration option (
jib.container.expandClasspathDependencies
(Gradle) /<container><expandClasspathDependencies>
(Maven)) that enables expanding classpath dependencies in the defaultjava
command for an imageENTRYPOINT
. Turning on the option (off by default) will enumerate all the dependencies, which will match the dependency loading order in Maven or Gradle builds. For example, theENTRYPOINT
becomesinstead 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 (
-Djib.container.expandClasspathDependencies=true|false
).