4
votes

I was try to deploy my application on the OPENSHIFT, but maven can't compile it with error:

invalid target release 1.8

my "build" action_hook:

export JAVA_HOME="${OPENSHIFT_DATA_DIR}jdk1.8.0_05"
export PATH=${OPENSHIFT_DATA_DIR}jdk1.8.0_05/bin:$PATH
cd $OPENSHIFT_REPO_DIR
java -version
mvn package -s .openshift/settings.xml -DskipTests=true

RESULT

java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)
[devlt-chernihiv.rhcloud.com repo]\> mvn package -s .openshift/settings.xml -DskipTests=true
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building LaserTag 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ sector ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ sector ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 5 source files to /var/lib/openshift/5601634589f5cfa11000006a/app-root/runtime/repo/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.018s
[INFO] Finished at: Tue Sep 22 11:27:06 EDT 2015
[INFO] Final Memory: 10M/113M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project sector: Fatal error compiling: invalid target release: 1.8 -> [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

then I use this script and see the problem:

export JAVA_HOME=${OPENSHIFT_DATA_DIR}jdk1.8.0_05
export PATH=${OPENSHIFT_DATA_DIR}jdk1.8.0_05/bin:$PATH
java -version

java version "1.8.0_05"

Java(TM) SE Runtime Environment (build 1.8.0_05-b13)

Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)

mvn --version | grep 'Java home'

Java home: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.85/jre

Java Home was changed, but maven ignore new java home. Please help.

3
What does your ${HOME}/.mavenrc and your MAVEN_OPTS say?khmarbaise

3 Answers

4
votes

You can use WildFly catrtridge. This cartridge has all what you need. Java8, spring boot triggers, and admin panel.

1
votes

You should try using the java8 marker in your .openshift/markers folder for your project, that should help get maven to use the correct version. That is assuming that you are using one of the standard java cartridges and not a DIY cartridge.

0
votes

It sounds like your mvn command is setting its own JAVA_HOME. Check the contents of 'mvn' to see what it is doing.