swp-fu-eid / eid-fu-swp

Docker-based REST API implemented with Django and restframework.
MIT License
2 stars 1 forks source link

maven in tomcat container #74

Closed Armagetron closed 6 years ago

Armagetron commented 6 years ago

I want to migrate the build of the DemoApp from ant to maven. This is my Dockerfile

FROM tomcat:8.5

RUN apt-get update \
 && apt-get install -y default-jdk ant maven \
 && apt-get clean \
 && rm -rf /var/lib/apt/lists/*

COPY DemoApp /DemoApp

RUN cd /DemoApp/saml \
 && export JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::") \
 && echo $JAVA_HOME \
 && mvn compile

COPY DemoApp/saml/tls-ssl-commcert.p12 $CATALINA_HOME/conf/tls-ssl-commcert.p12
COPY server.xml $CATALINA_HOME/conf/server.xml
CMD ["catalina.sh", "run"]

However I get the following error:

[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 5 source files to /DemoApp/saml/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.682 s
[INFO] Finished at: 2017-09-21T14:17:01+00:00
[INFO] Final Memory: 13M/118M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project saml: Fatal e
rror compiling: invalid target release: 1.8.0_141 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
The command '/bin/sh -c cd /DemoApp/saml  && export JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::")  && echo $JAVA_HOME
  && mvn compile' returned a non-zero code: 1

Although JAVA_HOME is set to /usr/lib/jvm/java-8-openjdk-amd64.

Does anyone have hints on this? @zervnet @nils-wisiol

Armagetron commented 6 years ago

Ok, found a solution. My original pom.xml was

<source>${java.version}</source>
<target>${java.version}</target>

Changing it to

<source>1.8</source>
<target>1.8</target>

did the trick. Being specific here is also not a problem since tomcat is more or less bound to a specific java version.