12

Unable to run a docker image built. When I run with the command

docker run -p 8080:8080 -t {image prefix name}/{image name}

I get a message "no main manifest attribute, in app.jar"

Using docker-maven-plugin and tried maven-assembly-plugin with main class called out explicitly.

docker version Boot2Docker 1.7.0

MaxZoom
  • 7,619
  • 5
  • 28
  • 44
RSG
  • 121
  • 1
  • 1
  • 4
  • 1
    Can you rename app.jar to app.zip, unzip it and check the manifest? – David Pérez Cabrera Jun 26 '15 at 19:16
  • What will be location of app.zip. Under my project folder, under target/docker folder I see 2 files couchboot-0.0.1-snapshot.jar and Dockerfile. Content of Docker file is below. FROM java:7 EXPOSE 8080 VOLUME /tmp ADD couchboot-0.0.1-snapshot.jar app.zip ENTRYPOINT ["java", "-jar", "app.zip"] – RSG Jun 27 '15 at 18:39
  • At this point, You must forget Docker, and review the generated manifest file. – David Pérez Cabrera Jun 28 '15 at 14:55
  • Thanks David. I ripped the pom.xml and putting it back. Now my manifest file looks fine. However, I run into the following issue when I run the docker image. WARN 1 --- [ cb-io-1-1] c.c.client.core.endpoint.Endpoint : [null][KeyValueEndpoint]: Could not connect to endpoint. – RSG Jun 28 '15 at 22:43
  • As a result, org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'couchbaseService' defined in URL [jar:file:/app.jar!/com/nielsen/couchbase/couchboot/CouchbaseService.class]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.nielsen.couchbase.couchboot.CouchbaseService]: Constructor threw exception; nested exception is java.lang.RuntimeException: java.util.concurrent.TimeoutException – RSG Jun 28 '15 at 22:45
  • Worked. I had to modify my Spring boot application's resources/ yaml file to reflect IP address as against localhost or 127.0.0.1 and access the application from the following IP (DOCKER_HOST) and Port, http://192.168.59.103:8080/ – RSG Jun 29 '15 at 00:30
  • 1
    Does this answer your question? [Can't execute jar- file: "no main manifest attribute"](https://stackoverflow.com/questions/9689793/cant-execute-jar-file-no-main-manifest-attribute) – howlger Mar 21 '21 at 16:05

1 Answers1

1

The manifest inside the jar file inside the Docker image does not contain what you expect it to, causing the failure to start when running with java -jar ...

I would suggest you debug your procedure locally first:

  • Is the MANIFEST.MF file present?
  • Is it in the exact location expected by the JVM when invoking java as you do?
  • Is the line "Main-Class: classname" present in the MANIFEST.MF file?
  • Is the class name given that exact name as the class you want to invoke is named?
  • Is the classpath given in MANIFEST.MF as you expect it to be?
  • Is the class to be invoke present in that classpath?

Further details in the official Oracle documentation in https://docs.oracle.com/javase/tutorial/deployment/jar/appman.html with friends.

Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347
  • This has already been answered several times on Stack Overflow. Also one of the two deleted answer here, which got two downvotes and which is visible to you, says the same. – howlger Mar 21 '21 at 16:39
  • @howlger If you happen to know that this question has already been answered several times on Stack Overflow then select the best answer for closing this one as a duplicate. Also deleted answers are not visible to OP. – Thorbjørn Ravn Andersen Mar 23 '21 at 17:44