Problem using maven with java8 on cartridge ‘diy’
My application is depeloped using a simple frameworl Dropwizard. Here a mini tutorial: https://blog.openshift.com/day-13-dropwizard-the-awesome-java-rest-server-stack/
Now I've to deploy application on OpenShift. Here some tips during deployment.
By default ‘diy’ cartridge uses java 7. I’ve to use java 8 in my application so I’ve found this hit for installing java 8 on my application:
http://stackoverflow.com/questions/23894323/jdk-8-support-at-diy-cartridge-in-openshift
Now following these instructions: http://dmly.github.io/blog/2013/05/01/diy-java-app-server-on-openshift-so-far-so-good/
Running maven, It can’t write in defaul repository for missing permission, so I’ve found a solution by specifing in sessings.xml file the repisitory location in my $OPENSHIFT_DATA_DIR
Here the explanation, how to run maven locally:
https://forums.openshift.com/maven-could-not-create-local-repository
Even when I specify JAVA_HOME to my java 8 installation, the default maven, yet installed by default on Openshift, uses java 7, so It gives problems compiling source, executing maven task:
+ mvn package -s /var/lib/openshift/566e8b000c1e66efec00002f/app-root/runtime/repo//.openshift/settings.xml -q clean package [debug] execute contextualize [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile) on project classcard_gest: 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
In fact from command line on connecting to my gear:
[classcardapp-simplethings.rhcloud.com 566e8b000c1e66efec00002f]\> export JAVA_HOME="${OPENSHIFT_DATA_DIR}jdk1.8.0_05" [classcardapp-simplethings.rhcloud.com 566e8b000c1e66efec00002f]\> export PATH=${OPENSHIFT_DATA_DIR}jdk1.8.0_05/bin:$PATH [classcardapp-simplethings.rhcloud.com 566e8b000c1e66efec00002f]\> 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) [classcardapp-simplethings.rhcloud.com 566e8b000c1e66efec00002f]\> javac -version javac 1.8.0_05 [classcardapp-simplethings.rhcloud.com 566e8b000c1e66efec00002f]\> [classcardapp-simplethings.rhcloud.com 566e8b000c1e66efec00002f]\> [classcardapp-simplethings.rhcloud.com 566e8b000c1e66efec00002f]\> [classcardapp-simplethings.rhcloud.com 566e8b000c1e66efec00002f]\> [classcardapp-simplethings.rhcloud.com 566e8b000c1e66efec00002f]\> mvn -version Apache Maven 3.0.4 (r1232336; 2012-12-18 14:36:37-0500) Maven home: /usr/share/java/apache-maven-3.0.4 Java version: 1.7.0_91, vendor: Oracle Corporation Java home: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.91/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "2.6.32-504.34.1.el6.x86_64", arch: "i386", family: "unix" [classcardapp-simplethings.rhcloud.com 566e8b000c1e66efec00002f]\>
http://stackoverflow.com/questions/33460703/openshift-maven-project-fails-to-find-java-8-compiler
https://bugzilla.redhat.com/show_bug.cgi?id=1109980
https://developer.jboss.org/people/fjuma/blog/2014/06/03/wildfly-810final-on-openshift--with-jdk-8-support
So I’ve to installa a mvn in my $OPENSHIFT_DATA_DIR and uses this one.
An example hook for installing maven
https://github.com/shekhargulati/spark-openshift-quickstart/blob/master/.openshift/action_hooks/deploy