Skip to content
This repository has been archived by the owner on Mar 2, 2023. It is now read-only.

Running webapp container is not able to find the Main class #5

Closed
arun-gupta opened this issue Feb 14, 2018 · 10 comments
Closed

Running webapp container is not able to find the Main class #5

arun-gupta opened this issue Feb 14, 2018 · 10 comments
Labels
bug Something isn't working maven

Comments

@arun-gupta
Copy link
Contributor

arun-gupta commented Feb 14, 2018

When a Docker image is generated for webapp using FMP, the Docker context has the following directory structure:

maven/webapp.war

The packaged WAR file has:

WEB-INF/classes/org/aws/samples/compute/webapp/Main.class

The java command to run the app is:

java -XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40 -XX:+ExitOnOutOfMemoryError -cp .:/maven/* org.aws.samples.compute.webapp.Main

Running the Docker container arungupta/webapp as:

docker container run -d arungupta/webapp

gives the following error:

Error: Could not find or load main class org.aws.samples.compute.webapp.Main
@ALRubinger
Copy link

FMP command run to reproduce, and from services?

@kenfinnigan
Copy link
Contributor

kenfinnigan commented Feb 15, 2018

Had emailed @arun-gupta privately, but will respond with my thoughts here.

The Java command seems odd, as I would expect it to be running the -swarm.jar instead of a Main of any kind. The MANIFEST in -swarm.jar then points to the WF Swarm bootstrap Main class for uber jars, which in turn then executes the WF Swarm Main class, or in this case the custom Main class provided by the webapp project.

@arun-gupta
Copy link
Contributor Author

mvn -pl webapp package -Pdocker produces the Docker image.

And then you run the container as docker container run -d arungupta/webapp.

@arun-gupta
Copy link
Contributor Author

Now getting:

services $ docker container run -p 8080:8080 -it arungupta/webapp
ERROR: Neither $JAVA_MAIN_CLASS nor $JAVA_APP_JAR is set and 52 found in /deployments (1 expected)

@arun-gupta arun-gupta reopened this Feb 15, 2018
@rafabene
Copy link

rafabene commented Feb 15, 2018

I've executed the last codebase and it worked! I can't reproduce this issue

@kenfinnigan
Copy link
Contributor

I'm also unable to replicate that error with the latest code

@yanaga
Copy link
Contributor

yanaga commented Feb 15, 2018

I've added a comment on PR #8, but I'll replicate here.

It happened to me before, so let me ask: are you running minikube or minishift and docker for mac at the same time? Sometimes the docker image gets pushed to the wrong registry. This seems to be the old image built with the error.

@arun-gupta
Copy link
Contributor Author

I had Kubernetes enabled using Docker for Mac. Also had a kops-based cluster running. Terminated both of them and now the container is being built and run correctly. Here is the build output:

[INFO] --- fabric8-maven-plugin:3.5.30:build (default) @ webapp ---
[WARNING] Error reading service account token from: [/var/run/secrets/kubernetes.io/serviceaccount/token]. Ignoring.
[WARNING] Error reading service account token from: [/var/run/secrets/kubernetes.io/serviceaccount/token]. Ignoring.
[WARNING] F8: Cannot access cluster for detecting mode: Unknown host kubernetes.default.svc
[INFO] F8: Building Docker image in Kubernetes mode
[WARNING] Error reading service account token from: [/var/run/secrets/kubernetes.io/serviceaccount/token]. Ignoring.
[WARNING] F8: Cannot access cluster for detecting mode: Unknown host kubernetes.default.svc
[WARNING] Error reading service account token from: [/var/run/secrets/kubernetes.io/serviceaccount/token]. Ignoring.
[WARNING] F8: Cannot access cluster for detecting mode: Unknown host kubernetes.default.svc
[WARNING] Error reading service account token from: [/var/run/secrets/kubernetes.io/serviceaccount/token]. Ignoring.
[INFO] F8: Running generator wildfly-swarm
[INFO] F8: wildfly-swarm: Using Docker image fabric8/java-jboss-openjdk8-jdk:1.2 as base / builder
[WARNING] Error reading service account token from: [/var/run/secrets/kubernetes.io/serviceaccount/token]. Ignoring.
[WARNING] F8: Cannot access cluster for detecting mode: Unknown host kubernetes.default.svc
[WARNING] Error reading service account token from: [/var/run/secrets/kubernetes.io/serviceaccount/token]. Ignoring.
[WARNING] F8: Cannot access cluster for detecting mode: Unknown host kubernetes.default.svc
[WARNING] Error reading service account token from: [/var/run/secrets/kubernetes.io/serviceaccount/token]. Ignoring.
[INFO] Copying files to /Users/argu/workspaces/aws-compute-options/services/webapp/target/docker/arungupta/webapp/build/maven
[INFO] Building tar: /Users/argu/workspaces/aws-compute-options/services/webapp/target/docker/arungupta/webapp/tmp/docker-build.tar
[INFO] F8: [arungupta/webapp:latest] "wildfly-swarm": Created docker-build.tar in 344 milliseconds
[INFO] F8: [arungupta/webapp:latest] "wildfly-swarm": Built image sha256:c0fad
[INFO] F8: [arungupta/webapp:latest] "wildfly-swarm": Tag with latest
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.669 s
[INFO] Finished at: 2018-02-15T14:09:41-08:00
[INFO] Final Memory: 51M/506M
[INFO] ------------------------------------------------------------------------

How can I get rid of WARNING from the build output?

@kenfinnigan
Copy link
Contributor

Glad it's working.

Not sure on the warnings, I see those as well

@arun-gupta
Copy link
Contributor Author

Warnings are not showing up if a k8s cluster is already running. Will close this issue and open another one if this becomes bothersome.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working maven
Projects
None yet
Development

No branches or pull requests

5 participants