Bug 1281868 - Cannot compile Java code using Java 8
Summary: Cannot compile Java code using Java 8
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: ImageStreams
Version: 2.2.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: Timothy Williams
QA Contact: DeShuai Ma
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-11-13 16:18 UTC by Eric Jones
Modified: 2019-09-12 09:18 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Tomcat 7
Last Closed: 2015-11-13 17:34:49 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Eric Jones 2015-11-13 16:18:46 UTC
Description of problem:
Use Java features from Java 8, attempt to upgrade the environment to use java 8 and it fails to build the app. Changed the marker and the pom.xml and neither works.

Version-Release number of selected component (if applicable):
Tomcat 7 (JBoss EWS 2.0)

How reproducible:
100%

Steps to Reproduce:
1. rhc app-create test jbossews-2.0
2. cd test
3. mv .openshift/markers/java7 .openshift/markers/java8
4. vim pom.xml 
     change 1.6 to 1.8 for source and target
5. vim src/main/java/Experimental.java
     add the following:
import java.time.LocalDateTime;

public class Experimental {

       public static void main(String[] args) {
               System.out.println("Today: "+LocalDateTime.now());
               System.out.println("VM  Total Memory: "+Runtime.getRuntime().totalMemory());
               System.out.println("VM  Free Memory: "+Runtime.getRuntime().maxMemory());
               System.out.println("VM  Max Memory: "+Runtime.getRuntime().freeMemory());
       }
}
6. git add -A ; git commit -m "all the changes" ; git push


Actual results:
Counting objects: 19, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (10/10), 739 bytes | 0 bytes/s, done.
Total 10 (delta 2), reused 0 (delta 0)
remote: The jbossews cartridge is already stopped
remote: Repairing links for 1 deployments
remote: Syncing git content to other proxy gears
remote: Building git ref 'master', commit 5cf082e
remote: Using Maven mirror /var/lib/openshift/5643a47a89f5cf4b5800004b/app-root/runtime/repo//.openshift/config/settings.rhcloud.xml
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_91, vendor: Oracle Corporation
remote: Java home: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.91/jre
remote: Default locale: en_US, platform encoding: ANSI_X3.4-1968
remote: OS name: "linux", version: "2.6.32-504.34.1.el6.x86_64", arch: "i386", family: "unix"
remote: Found pom.xml... attempting to build with 'mvn --global-settings /var/lib/openshift/5643a47a89f5cf4b5800004b/app-root/runtime/repo//.openshift/config/settings.rhcloud.xml clean package -Popenshift -DskipTests'
remote: [INFO] Scanning for projects...
remote: [INFO]                                                                         
remote: [INFO] ------------------------------------------------------------------------
remote: [INFO] Building experimental 1.0
remote: [INFO] ------------------------------------------------------------------------
remote: [INFO] 
remote: [INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ experimental ---
remote: [INFO] 
remote: [INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ experimental ---
remote: [debug] execute contextualize
remote: [INFO] Using 'UTF-8' encoding to copy filtered resources.
remote: [INFO] Copying 1 resource
remote: [INFO] 
remote: [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ experimental ---
remote: [INFO] Compiling 1 source file to /var/lib/openshift/5643a47a89f5cf4b5800004b/app-root/runtime/repo/target/classes
remote: [INFO] -------------------------------------------------------------
remote: [ERROR] COMPILATION ERROR : 
remote: [INFO] -------------------------------------------------------------
remote: [ERROR] Failure executing javac, but could not parse the error:
remote: javac: invalid target release: 1.8
remote: Usage: javac <options> <source files>
remote: use -help for a list of possible options
remote: 
remote: [INFO] 1 error
remote: [INFO] -------------------------------------------------------------
remote: [INFO] ------------------------------------------------------------------------
remote: [INFO] BUILD FAILURE
remote: [INFO] ------------------------------------------------------------------------
remote: [INFO] Total time: 2.991s
remote: [INFO] Finished at: Wed Nov 11 15:50:18 EST 2015
remote: [INFO] Final Memory: 4M/63M
remote: [INFO] ------------------------------------------------------------------------
remote: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project experimental: Compilation failure
remote: [ERROR] Failure executing javac, but could not parse the error:
remote: [ERROR] javac: invalid target release: 1.8
remote: [ERROR] Usage: javac <options> <source files>
remote: [ERROR] use -help for a list of possible options
remote: [ERROR] -> [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/MojoFailureException
remote: An error occurred executing 'gear postreceive' (exit code: 1)
remote: Error message: CLIENT_ERROR: Failed to execute: 'control build' for /var/lib/openshift/5643a47a89f5cf4b5800004b/jbossews
remote: 
remote: For more details about the problem, try running the command again with the '--trace' option.
To ssh://5643a47a89f5cf4b5800004b.com/~/git/experimental.git/
   0f17269..5cf082e  master -> master

Expected results:
build success

Additional info:

That is the error code from the customer which has slightly different names and a few extra lines but the idea is the same.

Comment 1 Timothy Williams 2015-11-13 17:34:49 UTC
Java 8 is not supported for use with Tomcat 7, so it is not offered. See the below article on the Jbossews-2.0 (Tomcat 7) supported configurations:

  https://access.redhat.com/articles/258223

If Java 8 is required, a Tomcat 8 cartridge can be created from the DIY cartridge. There have been many articles written that explain how to do this that a little googling will reveal, such as the below:

  https://blog.openshift.com/how-to-run-apache-tomcat-8-on-openshift/

There are also examples created by community members, one example below:

 https://github.com/shekhargulati/openshift-tomcat8-quickstart

Closing this WONTFIX since there are no plans to create an officially supported Jbossews-3.0 (Tomcat 8) cartridge in the near future.

Comment 2 Gilmar Leitao 2015-11-14 01:31:29 UTC
Hi,

This bug was reported by me.

I would say, now Java 8 is required because I saw the support in this page https://developers.openshift.com/en/tomcat-markers.html I changed the java7 to java8 marker and summing up all process I have done.. My app is now running in a jbossews-2.0 + Java8.

This is an official documentation page, so what all people and I should think about that? My team and I did a lot of work considering this support clearly communicated in that page, so that means we have been wasted our time? All migrations we did and all work..?  

I didn't get it. The documentation page contains the info about the java8 marker  support, we ran the app using java 8, and at this point the support does not exist? Why the info is there?

My app is running now, if a restart, reload, stop and restart, etc.. My app may just stop?

What should we do now? I'm sorry, but this situation it's really frustrating.

Comment 3 Eric Jones 2015-11-16 15:17:11 UTC
Hi Gilmar,

Java 8 is supported by certain versions of JBoss EAP and EWS, unfortunately, not the versions of JBoss EWS that are used in OpenShift Online, you can see the various versions below [0][1]. 
[0] https://access.redhat.com/solutions/879433
[1] https://access.redhat.com/solutions/662713

Due to this, 'almost' sort of thing, confusion occurred and the docs included this as a feature for the wrong version of Tomcat, hence the documentation you referred to.

You can see here on the github [2][3][4], it was mistakenly added to the code and then later removed as it has not been tested with the version of JBoss EWS that is used for OpenShift Online.
[2] https://github.com/openshift/origin-server/commits/833c5ea1778cb9279ef53cdac99f3e879adee1d4/cartridges/openshift-origin-cartridge-jbossews/bin/util
[3] https://github.com/openshift/origin-server/commit/632d56c8cca60207504c5323301825e03aecb5fd
[4] https://github.com/openshift/origin-server/commit/833c5ea1778cb9279ef53cdac99f3e879adee1d4

Sorry for the confusion.

Comment 4 Timothy Williams 2015-11-16 15:55:31 UTC
The below PR has been submitted to remove the incorrect java8 marker documentation from jbossews:

https://github.com/openshift/devcenter/pull/385


Note You need to log in before you can comment on or make changes to this bug.