daydreamer
daydreamer

Reputation: 91949

Wildfly 8.1.0: invalid target release: 1.8?

I learnt that by default wildfly 8.1.0 cartridge supports JDK 8

However, when I deploy my application, I see the following error

remote: Stopping wildfly cart
remote: Repairing links for 1 deployments
remote: Building git ref master, commit af5f0d3
remote: Found pom.xml... attempting to build with mvn -e clean package -Popenshift -DskipTests
remote: Apache Maven 3.0.4 (r1232336; 2012-12-18 14:36:37-0500)
remote: Maven home: /usr/share/java/apache-maven-3.0.4
remote: Java version: 1.7.0_65, vendor: Oracle Corporation
remote: Java home: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65/jre
remote: Default locale: en_US, platform encoding: ANSI_X3.4-1968
remote: OS name: linux, version: 2.6.32-431.23.3.el6.x86_64, arch: i386, family: unix
remote: [INFO] Scanning for projects...
remote: [INFO]
remote: [INFO] ------------------------------------------------------------------------
remote: [INFO] Building pennyapp 1.0-SNAPSHOT
remote: [INFO] ------------------------------------------------------------------------
remote: [INFO]
remote: [INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ pennyapp ---
remote: [INFO]
remote: [INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ pennyapp ---
remote: [debug] execute contextualize
remote: [WARNING] Using platform encoding (ANSI_X3.4-1968 actually) to copy filtered resources, i.e. build is platform dependent!
remote: [INFO] skip non existing resourceDirectory /var/lib/openshift/53ec289c5973ca0333000a6c/app-root/runtime/repo/src/main/resources
remote: [INFO]
remote: [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ pennyapp ---
remote: [INFO] Changes detected - recompiling the module!
remote: [WARNING] File encoding has not been set, using platform encoding ANSI_X3.4-1968, i.e. build is platform dependent!
remote: [INFO] Compiling 1 source file to /var/lib/openshift/53ec289c5973ca0333000a6c/app-root/runtime/repo/target/classes
remote: [INFO] ------------------------------------------------------------------------
remote: [INFO] BUILD FAILURE
remote: [INFO] ------------------------------------------------------------------------
remote: [INFO] Total time: 5.602s
remote: [INFO] Finished at: Sat Aug 16 00:54:13 EDT 2014
remote: [INFO] Final Memory: 7M/111M
remote: [INFO] ------------------------------------------------------------------------
remote: [WARNING] The requested profile openshift could not be activated because it does not exist.
remote: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project pennyapp: Fatal error compiling: invalid target release: 1.8 -> [Help 1]
remote: [ERROR]
remote: [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
remote: [ERROR] Re-run Maven using the -X switch to enable full debug logging.
remote: [ERROR]
remote: [ERROR] For more information about the errors and possible solutions, please read the following articles:
remote: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
remote: An error occurred executing gear postreceive (exit code: 1)
remote: Error message: CLIENT_ERROR: Failed to execute: control build for /var/lib/openshift/53ec289c5973ca0333000a6c/wildfly
remote:

As you can see the logs clearly say

remote: Java version: 1.7.0_65, vendor: Oracle Corporation

To confirm this, I logged into the Openshift box and see this

[api-myapp.rhcloud.com 53ec5973ca0333000a6c]\> java -version
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) Server VM (build 25.5-b02, mixed mode)

and

[api-myapp.rhcloud.com 53ec5973ca0333000a6c]\> 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_65, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-431.23.3.el6.x86_64", arch: "i386", family: "unix"

Problem?

Maven uses java version 1.7.0_65

Question?

How do I tell maven to use java 1.8?

I know a way on mac using command-line as

export JAVA_HOME=$(/usr/libexec/java_home)

But is there a better way, so that I do not have to fiddle around when setting up Continuous Deployment?

Thanks

UPDATE - 1
I also see that JAVA_HOME is correctly set

 echo $JAVA_HOME
 /var/lib/openshift/53ec289c5973ca0333000a6c/wildfly/usr/lib/jvm/jdk1.8.0_05

UPDATE - 2
Im my pom.xml, I have plugin defined as

           <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <source>${javac.version}</source>
                    <target>${javac.version}</target>
                </configuration>
            </plugin>  

and

   <properties>
        <maven-compiler-plugin.version>3.1</maven-compiler-plugin.version>
        <javac.version>1.8</javac.version>
        <maven-sortpom-plugin.version>2.3.0</maven-sortpom-plugin.version>
    </properties>

UPDATE - 3
Some more pointers

[api-myapp.rhcloud.com repo]\> echo $PATH
/var/lib/openshift/53ec289c5973ca0333000a6c/wildfly/usr/lib/jvm/jdk1.8.0_05/bin:/etc/alternatives/maven-3.0/bin:/var/lib/openshift/53ec289c5973ca0333000a6c/wildfly//bin/tools:/bin:/usr/bin:/usr/sbin
[api-myapp.rhcloud.com repo]\> which java
/var/lib/openshift/53ec289c5973ca0333000a6c/wildfly/usr/lib/jvm/jdk1.8.0_05/bin/java
[api-myapp.rhcloud.com repo]\> /usr/bin/java -version
java version "1.7.0_65"
OpenJDK Runtime Environment (rhel-2.5.1.2.el6_5-i386 u65-b17)
OpenJDK Server VM (build 24.65-b04, mixed mode)
[api-pennyapp.rhcloud.com repo]\> 

Upvotes: 1

Views: 1500

Answers (1)

daydreamer
daydreamer

Reputation: 91949

There was a bug in Wildfly cartridge.

I worked with Ben Parees, who helped fixing this issue. You can find the bug reference here and the pull request changes

Happy Hacking!

Upvotes: 1

Related Questions