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

why the main-class is setted "${start-class}" in the "config.json" file of jib-image.tar ? #1601

Closed
onethin opened this issue Apr 4, 2019 · 7 comments

Comments

@onethin
Copy link

onethin commented Apr 4, 2019

Spring Boot Project and not config the in pom.xml
All other projects is ok,jib can find the main class automatically
but one project is strange,the man class value is setted "${start-class}" in the config.json file of jib-image.tar

@onethin
Copy link
Author

onethin commented Apr 4, 2019

not config the mainClass in pom.xml

@briandealwis
Copy link
Member

Hi @onethin. So if I understand correctly, you have a Spring Boot-based project, but you aren't explicitly configuring Jib (i.e., you're running something like mvn package com.google.cloud.tools:jib-maven-plugin:dockerBuild). Jib is producing an image — implying that it has found a single class with a main — but it is ${start-class}. That does sound puzzling.

Could you please post your build logs? And the config.json?

@onethin
Copy link
Author

onethin commented Apr 8, 2019

@briandealwis Thanks
use "mvn clean jib:buildTar"

[INFO] --- jib-maven-plugin:1.0.2:buildTar (default-cli) @ hades-demo-web-console ---
[WARNING] 'mainClass' is not a valid Java class : ${start-class}
[INFO] 
[INFO] Containerizing application to file at 'D:\Workspaces\eclipse-hades\hades-demos\hades-demo-web-console\target\jib-image.tar'...
[INFO] Getting base image 203.3.233.201/hades/hades-alpine-openjdk8-jre:1.8.0_191...
[INFO] Building resources layer...
[INFO] Building dependencies layer...
[INFO] Building snapshot dependencies layer...
[INFO] Building classes layer...
[INFO] The base image requires auth. Trying again for 203.3.233.201/hades/hades-alpine-openjdk8-jre:1.8.0_191...
[INFO] Retrieving registry credentials for 203.3.233.201...
[INFO] 
[INFO] Container entrypoint set to [java, -XX:+PrintGCDateStamps, -XX:+PrintGCDetails, -XX:+PrintGCApplicationStoppedTime, -XX:+PrintCommandLineFlags, -XX:+HeapDumpOnOutOfMemoryError, -Xloggc:/app/heapdump/heap_trace.log, -XX:HeapDumpPath=/app/heapdump, -XX:-OmitStackTraceInFastThrow, -cp, /app/resources:/app/classes:/app/libs/*, ${start-class}]
[INFO] Building image to tar file...
[INFO] 
[INFO] Built image tarball at D:\Workspaces\eclipse-hades\hades-demos\hades-demo-web-console\target\jib-image.tar
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  29.828 s
[INFO] Finished at: 2019-04-08T10:44:01+08:00

the config.json

{"created":"1970-01-01T00:00:00Z","architecture":"amd64","os":"linux","config":{"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","JAVA_APP_DIR=/deployments","JAVA_MAJOR_VERSION=8"],"Entrypoint":["java","-XX:+PrintGCDateStamps","-XX:+PrintGCDetails","-XX:+PrintGCApplicationStoppedTime","-XX:+PrintCommandLineFlags","-XX:+HeapDumpOnOutOfMemoryError","-Xloggc:/app/heapdump/heap_trace.log","-XX:HeapDumpPath=/app/heapdump","-XX:-OmitStackTraceInFastThrow","-cp","/app/resources:/app/classes:/app/libs/*","${start-class}"],"ExposedPorts":{"8778/tcp":{},"9779/tcp":{}},"Labels":{},"WorkingDir":"","Volumes":{}},"history":[{"created":"2018-12-21T00:21:29.97055571Z","created_by":"/bin/sh -c #(nop) ADD file:2ff00caea4e83dfade726ca47e3c795a1e9acb8ac24e392785c474ecf9a621f2 in / "},{"created":"2018-12-21T00:21:30.122610396Z","created_by":"/bin/sh -c #(nop)  CMD [\"/bin/sh\"]","empty_layer":true},{"created":"2019-01-14T13:24:37.115341901Z","created_by":"/bin/sh -c #(nop)  USER root","empty_layer":true},{"created":"2019-01-14T13:24:39.111348633Z","created_by":"/bin/sh -c mkdir -p /deployments"},{"created":"2019-01-14T13:24:39.45811588Z","created_by":"/bin/sh -c #(nop)  ENV JAVA_APP_DIR=/deployments JAVA_MAJOR_VERSION=8","empty_layer":true},{"created":"2019-01-14T13:24:50.393621157Z","created_by":"/bin/sh -c apk add --update     curl     openjdk8-jre-base=8.191.12-r0  && rm /var/cache/apk/*  && echo \"securerandom.source=file:/dev/urandom\" >> /usr/lib/jvm/default-jvm/jre/lib/security/java.security"},{"created":"2019-01-14T13:24:51.008289061Z","created_by":"/bin/sh -c #(nop) ADD file:0e4d47c8ceb53292ec2698ca6f70c3f2954e747263a46f1b6b1fa70f71d9d9d4 in /opt/run-java-options "},{"created":"2019-01-14T13:24:52.959797363Z","created_by":"/bin/sh -c mkdir -p /opt/agent-bond  && curl http://central.maven.org/maven2/io/fabric8/agent-bond-agent/1.2.0/agent-bond-agent-1.2.0.jar           -o /opt/agent-bond/agent-bond.jar  && chmod 444 /opt/agent-bond/agent-bond.jar  && chmod 755 /opt/run-java-options"},{"created":"2019-01-14T13:24:53.320998802Z","created_by":"/bin/sh -c #(nop) ADD file:19cf38fb1c34ab0ebb2252bb70ed3ea973b69d12e67d2ef36785bb6efa0eb9f4 in /opt/agent-bond/ "},{"created":"2019-01-14T13:24:53.632008253Z","created_by":"/bin/sh -c #(nop)  EXPOSE 8778 9779","empty_layer":true},{"created":"2019-01-14T13:24:54.113490455Z","created_by":"/bin/sh -c #(nop) COPY file:c121251c5fd10f3b2814eb72e82dac239a4a84b049b91809d8133aa59f4b763f in /deployments/ "},{"created":"2019-01-14T13:24:56.153904916Z","created_by":"/bin/sh -c chmod 755 /deployments/run-java.sh"},{"created":"2019-01-14T13:24:56.51742612Z","created_by":"/bin/sh -c #(nop)  CMD [\"/deployments/run-java.sh\"]","empty_layer":true},{"created":"2019-03-01T16:36:50.527653055Z","author":"OneThin","created_by":"/bin/sh -c #(nop)  MAINTAINER OneThin","empty_layer":true},{"created":"2019-03-01T16:36:51.110891574Z","author":"OneThin","created_by":"/bin/sh -c mkdir -p /opt/data/"},{"created":"2019-03-01T16:36:51.610627902Z","author":"OneThin","created_by":"/bin/sh -c mkdir -p /app/heapdump/"},{"created":"1970-01-01T00:00:00Z","author":"Jib","created_by":"jib-maven-plugin:1.0.2","comment":"dependencies"},{"created":"1970-01-01T00:00:00Z","author":"Jib","created_by":"jib-maven-plugin:1.0.2","comment":"snapshot dependencies"},{"created":"1970-01-01T00:00:00Z","author":"Jib","created_by":"jib-maven-plugin:1.0.2","comment":"resources"},{"created":"1970-01-01T00:00:00Z","author":"Jib","created_by":"jib-maven-plugin:1.0.2","comment":"classes"}],"rootfs":{"type":"layers","diff_ids":["sha256:7bff100f35cb359a368537bb07829b055fe8e0b1cb01085a3a628ae9c187c7b8","sha256:4fa7cb4cb54a14aa27eef600d1266cb48ce6f954fd903ce57514e6b04792d2f7","sha256:a21828faa6f933a24da588e099311a00ccd6ef3a9935917ddec98f71856f4c00","sha256:01d30edec8014a9b3c6a6ac750ee8dbe3d8cfccaa9f59ba35b10facaefb6c201","sha256:69453ad4670de45286952f8e462f5ea866c8c860b9185b181483665612c3f22e","sha256:7df12ee9b582b85c278b7a48e798327f0f89151594135a2287a19e199523a39c","sha256:bb1fd88282635d6e9917db79fbd9214d3ba78808baf099633dc0542ff8e6ffad","sha256:ffed7356a70e6b9591436b2636743a4ce12550c98a62b694b8c745441827c2ea","sha256:b37b4f7607b286545aad1e943a29c14d28db2b49813dd99bb847ea790b4f6dde","sha256:0959d6df08a902c25833cf92d985d11b285f6be95d2c11587316bfafe4e926ff","sha256:518659e7a8a8d414a9a3f397ddeeb4324eb34dad724d4755be4bed64e2505994","sha256:af9fac62d596eff9624827fe73a2da1a45809f65c724c8f9097da21066eb26db","sha256:666ffbfb3022e22bbb437aad262496d37c4915b35c78e9dc06107a24f935ad90","sha256:1b4a236b37cf82638141ff8052b00218b5304ff3216c4bffb1ef26ce1a7fed29"]}}

in the Entrypoint, the last element is "${start-class}", it should be a full class name。

@chanseokoh
Copy link
Member

Can you share pom.xml? You may have the ${start-class} string somewhere in your pom.xml?

@onethin
Copy link
Author

onethin commented Apr 9, 2019

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<parent>
		<artifactId>hades</artifactId>
		<groupId>com.czb</groupId>
		<version>1.0.23-SNAPSHOT</version>
	</parent>
	<modelVersion>4.0.0</modelVersion>
	<groupId>com.czb.demo</groupId>
	<artifactId>hades-demo-web-console</artifactId>
	<version>1.0.0-SNAPSHOT</version>
	<name>hades-demo-web-console</name>
	<url>http://maven.apache.org</url>
	<packaging>jar</packaging>

	<properties>
		<easypoi.version>3.3.0</easypoi.version>
		<easyexcel.version>1.1.1</easyexcel.version>
		<hades-demo-service.version>1.0.0-SNAPSHOT</hades-demo-service.version>
		<hades-oauth2.version>1.0.0-SNAPSHOT</hades-oauth2.version>
		<hades-web-extjs-theme-hades.version>1.0.0</hades-web-extjs-theme-hades.version>
		<hades-web-extjs-theme-classic.version>1.0.0</hades-web-extjs-theme-classic.version>
		
		<!-- 如下参数在使用jib打包镜像时必须配置 -->
		<jib.image.to.space>hades-demo</jib.image.to.space><!-- 镜像所在的空间名 -->
		
		<!-- jib -->
		<jib-maven-plugin.version>1.0.2</jib-maven-plugin.version>
		<jib.image.url>image.test.com</jib.image.url>
		<jib.image.from>hades/hades-alpine-openjdk8-jre:1.8.0_191</jib.image.from>
		<jib.image.to.space>default</jib.image.to.space>
		<jib.from.credHelper></jib.from.credHelper>
		<jib.from.auth.username>...</jib.from.auth.username>
		<jib.from.auth.password>...</jib.from.auth.password>
		<jib.to.credHelper></jib.to.credHelper>
		<jib.to.auth.username>...</jib.to.auth.username>
		<jib.to.auth.password>...</jib.to.auth.password>
		<jib.skip>false</jib.skip>
		<jib.allowInsecureRegistries>false</jib.allowInsecureRegistries>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter</artifactId>
			<exclusions>
				<exclusion>
					<groupId>org.springframework.boot</groupId>
					<artifactId>spring-boot-starter-logging</artifactId>
				</exclusion>
			</exclusions>
		</dependency>

		<dependency>
			<groupId>com.czb</groupId>
			<artifactId>hades-web</artifactId>
		</dependency>
		
		<dependency>
			<groupId>com.czb.hades.web</groupId>
			<artifactId>hades-web-extjs-theme-hades</artifactId>
			<version>${hades-web-extjs-theme-hades.version}</version>
		</dependency>
		<dependency>
			<groupId>com.czb</groupId>
			<artifactId>hades-web-extjs</artifactId>
			<exclusions>
				<exclusion>
					<groupId>com.czb</groupId>
					<artifactId>hades-web-extjs-theme-xianui</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>com.czb</groupId>
			<artifactId>hades-rpc</artifactId>
		</dependency>
		<dependency>
			<groupId>com.czb</groupId>
			<artifactId>hades-sequence</artifactId>
		</dependency>
		<dependency>
			<groupId>com.czb</groupId>
			<artifactId>hades-ssoc</artifactId>
		</dependency>
		<dependency>
			<groupId>com.czb</groupId>
			<artifactId>hades-db</artifactId>
		</dependency>
		<dependency>
			<groupId>com.czb</groupId>
			<artifactId>hades-validator</artifactId>
		</dependency>
		<dependency>
			<groupId>com.czb.demo</groupId>
			<artifactId>hades-demo-service-api</artifactId>
			<version>${hades-demo-service.version}</version>
		</dependency>
		<dependency>
			<groupId>cn.afterturn</groupId>
			<artifactId>easypoi-web</artifactId>
			<version>${easypoi.version}</version>
		</dependency>
		<dependency>
			<groupId>cn.afterturn</groupId>
			<artifactId>easypoi-base</artifactId>
			<version>${easypoi.version}</version>
		</dependency>
		
		<dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>easyexcel</artifactId>
			<version>${easyexcel.version}</version>
		</dependency>
		<!-- mysql jdbc驱动,如果使用其他数据库可删除该引用 -->
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
		</dependency>

 		<dependency>
			<groupId>com.czb.oauth2</groupId>
	        <artifactId>oauth2-client</artifactId>
			<version>${hades-oauth2.version}</version>
		</dependency>
		
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<configuration>
					<!--fork : 如果没有该项配置,肯定devtools不会起作用,即应用不会restart -->
					<fork>true</fork>
				</configuration>
				<executions>
					<execution>
						<goals>
							<goal>repackage</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<!--generator插件 -->
			<plugin>
				<groupId>org.mybatis.generator</groupId>
				<artifactId>mybatis-generator-maven-plugin</artifactId>
			</plugin>
			
			<plugin>
				<groupId>com.google.cloud.tools</groupId>
				<artifactId>jib-maven-plugin</artifactId>
				<version>${jib-maven-plugin.version}</version>
				<configuration>
					<from>
						<image>${jib.image.url}/${jib.image.from}</image>
						<credHelper>${jib.from.credHelper}</credHelper>
						<auth>
							<username>${jib.from.auth.username}</username>
							<password>${jib.from.auth.password}</password>
						</auth>
					</from>
					<to>
						<image>${jib.image.url}/${jib.image.to.space}/${project.artifactId}</image>
						<credHelper>${jib.to.credHelper}</credHelper>
						<auth>
							<username>${jib.to.credHelper}</username>
							<password>${jib.to.auth.password}</password>
						</auth>
						<tags>
							<tag>${project.version}-${current.time}</tag>
						</tags>
					</to>
					<skip>${jib.skip}</skip>
					<allowInsecureRegistries>${jib.allowInsecureRegistries}</allowInsecureRegistries>
					<container>
						<useCurrentTimestamp>true</useCurrentTimestamp>
						<jvmFlags>
							<jvmFlag>-XX:+PrintGCDateStamps</jvmFlag><!-- 打印GC的时间戳 -->
							<jvmFlag>-XX:+PrintGCDetails</jvmFlag><!-- 打印GC的明细信息 -->
							<jvmFlag>-XX:+PrintGCApplicationStoppedTime</jvmFlag><!-- 打印GC期间程序暂停的时间 -->
							<jvmFlag>-XX:+PrintCommandLineFlags</jvmFlag><!-- 打印已经设置过的详细JVM参数值 -->
							<jvmFlag>-XX:+HeapDumpOnOutOfMemoryError</jvmFlag><!-- 内存溢出时生成堆转储快照文件 -->
							<jvmFlag>-Xloggc:/app/heapdump/heap_trace.log</jvmFlag><!-- GC的日志路径 -->
							<jvmFlag>-XX:HeapDumpPath=/app/heapdump</jvmFlag><!-- 生成堆转储快照文件所在的目录 -->
							<jvmFlag>-XX:-OmitStackTraceInFastThrow</jvmFlag><!-- 大量抛出重复异常的时候打印完整的异常链信息 -->
						</jvmFlags>
					</container>
				</configuration>
			</plugin>
		</plugins>
		<resources>
			<resource>
				<directory>src/main/java</directory>
				<includes>
					<include>**/*.xml</include>
					<include>**/*.properties</include>
				</includes>
				<filtering>false</filtering>
			</resource>
			<resource>
				<directory>src/main/resources</directory>
				<filtering>false</filtering><!--是否替换资源中的属性 -->
			</resource>
		</resources>
	</build>
</project>

@chanseokoh
Copy link
Member

@onethin I suspect the parent POM has the ${start-class} string. Can you share the parent POM too?

	<parent>
		<artifactId>hades</artifactId>
		<groupId>com.czb</groupId>
		<version>1.0.23-SNAPSHOT</version>
	</parent>

Even if that isn't the case, I bet mvn help:effective-pom on the Spring Boot project would output ${start-class} somewhere. Can you also check the output of mvn help:effective-pom?

@onethin
Copy link
Author

onethin commented Apr 9, 2019

Thanks All @briandealwis @chanseokoh
I solve the problem, because there are two main classes in the project,so jib can't decide which one shoud put in to config.json, and use string ${start-class}. In this case, we should set the “start-class” in properties。
I delete one of them,it's done.

@onethin onethin closed this as completed Apr 9, 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

3 participants