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

Fix war file creation #1100

Open
wants to merge 2 commits into
base: v1
Choose a base branch
from

Conversation

paddy-hack
Copy link

Closes #1099

This was disabled in bae0857 when
undoing changes made in an attempt to change IDE to Intellij.  The
comment markers appear to have slipped in by accident.
@y-okumura-isp
Copy link

y-okumura-isp commented Feb 2, 2021

I had the same issue and I tried to fix it by updating nodejs and npm version(but I still had build issues).
@paddy-hack I feel your solution is better then mine. After I apply your patch locally, I still have the following errors. How about you?

(1) about build error

By launch.sh, I got the following error.

$ bash launch.sh

// snip
[ERROR] Failed to execute goal org.jacoco:jacoco-maven-plugin:0.7.9:check (default-check) on project knowledge: Coverage checks have not been met. See log for details. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.jacoco:jacoco-maven-plugin:0.7.9:check (default-check) on project knowledge: Coverage checks have not been met. See log for details.

// snip
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project knowledge: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test failed: The forked VM terminated without saying properly goodbye. VM crash or System.exit called ? -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project knowledge: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test failed: The forked VM terminated without saying properly goodbye. VM crash or System.exit called ?
// snip stacks
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test failed: The forked VM terminated without saying properly goodbye. VM crash or System.exit called ?

(2) war build error

After sh launch.sh, I got the following log.
I want to note that the original message is not in English so I manually translate the messages.

mkdir: can not create directory `target/webapps': no permission
mv: cannot stat 'target/knowledge.war': no such file or directory.
(snip)
tomcat_1         | 02-Feb-2021 13:13:34.147 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
tomcat_1         | 02-Feb-2021 13:13:34.169 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
tomcat_1         | 02-Feb-2021 13:13:34.173 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 117 ms

It looks I could not build knowledge.war properly. In fact, /usr/local/tomcat/webapps in the container is empty.
How about you?

Here is my environment.

  • ubuntu 18.04 x86_64
  • Docker version 19.03.6, build 369ce74a3c
  • ufw disabled

@paddy-hack
Copy link
Author

I remember seeing the mkdir permission issue.

It happens when you run ./launch.sh are a regular user, i.e. not root, that is part of the docker group. In that case, you can run any docker and docker-compose commands as yourself. However, inside the container, the root user is doing the build and (re)creates the target/ directory. This means that a regular user will not be able to create a target/webapps/ directory.

This will probably not happen for people who use Docker on the Mac or Windows as that runs inside a VM with root privileges, IIRC.

I "solved" it by prefixing the mkdir command and the next command with

docker-compose run --rm maven

Ugly, but it does the trick. Perhaps I should create a separate PR for that as well.
Wondering whether it makes sense to put all the build stuff in a separate script and run that under a single docker-compose run --rm maven instead of doing that docker-compose invocation four times 🤔

@paddy-hack
Copy link
Author

I also remember seeing the goal execution errors you mentioned first. However, I do not see them with the PRs I submitted.

Have you uncommented the

docker-compose run --rm maven mv clean test site -e

line by any chance?

@y-okumura-isp
Copy link

@paddy-hack Thank you for advices and sorry for late reply.
I could build knowledge.war and deploy it successfully with some more changes.
Thank you very much! I write details below.

I remember seeing the mkdir permission issue.

Exactly! I use a regular user belong to docker group on ubuntu 19.10.
As a work around, I add sudo to mkdir and mv(see launch.sh below)

Have you uncommented the
docker-compose run --rm maven mv clean test site -e
line by any chance?

No. I kept this line commented as in https://github.com/support-project/knowledge/blob/v1/launch.sh#L4.

I found (1) error happends at docker-compose run maven mvn install -DskipTests=true -Dmaven.javadoc.skip=true -e.

I also found knowledge.war was created in spite of error (1).
But docker-compose run maven mvn clean package -e looks to remove the war file.
Thus the mv failed and target/webapps is empty.

I finally changed launch.sh as the following.

#!/bin/bash -eu

docker-compose run maven mvn install -DskipTests=true -Dmaven.javadoc.skip=true -e
# docker-compose run maven mvn clean test site -e
# docker-compose run maven mvn clean package -e

sudo mkdir -p target/webapps
sudo cp target/knowledge.war target/webapps/knowledge.war

docker-compose up --build -d tomcat
docker-compose logs -f tomcat

After ./launch.sh, I could see http://<host-ip-addr>:8080/knowledge.
Note: I changed ROOT.war by knowledge.war because of the following error.

tomcat_1         | 13-Feb-2021 09:14:30.812 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [/usr/local/tomcat/webapps /ROOT.war]
tomcat_1         | 13-Feb-2021 09:14:30.859 SEVERE [localhost-startStop-1] org.apache.catalina.startup.ContextConfig.beforeStart Exception fixing docBase for context []

I feel this is not the right way, but it's OK if I can start what I want 😅

Wondering whether it makes sense to put all the build stuff in a separate script and run that under a single docker-compose run --rm maven instead of doing that docker-compose invocation four times

I agree. I feel we could use docker multi stage build for example. Also, I want the developer manual...

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

Successfully merging this pull request may close these issues.

knowledge.war creation is broken
2 participants