Skip to content

Commit

Permalink
Merge pull request payara#475 from JamesHillyard/FISH-5686-Enterprise
Browse files Browse the repository at this point in the history
FISH-5686 Log warning when not running on a supported (LTS) JDK version
  • Loading branch information
JamesHillyard authored Sep 20, 2021
2 parents c2bab93 + 49a0f3b commit d47d607
Show file tree
Hide file tree
Showing 17 changed files with 47 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2021] Payara Foundation and/or affiliates

package org.glassfish.appclient.client;

Expand Down Expand Up @@ -70,6 +71,7 @@
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Logger;
import javax.xml.bind.*;
import javax.xml.bind.util.ValidationEventCollector;
import javax.xml.parsers.ParserConfigurationException;
Expand Down Expand Up @@ -122,6 +124,8 @@ public class AppClientFacade {

private static boolean isJWS = false;

private static final Logger logger = Logger.getLogger(AppClientFacade.class.getName());


/**
* Prepares the ACC (if not already done by the agent) and then transfers
Expand Down Expand Up @@ -185,16 +189,8 @@ public static void launch(String[] args) throws NoSuchMethodException,
}

public static void prepareACC(String agentArgsText, Instrumentation inst) throws UserError, MalformedURLException, URISyntaxException, JAXBException, FileNotFoundException, ParserConfigurationException, SAXException, IOException, Exception {
int minor = JDK.getMinor();
int major = JDK.getMajor();
if (major<9) {
if (minor < 6) {
throw new UserError(localStrings.getLocalString(
stringsAnchor,
"main.badVersion",
"Current Java version {0} is too low; {1} or later required",
new Object[] {System.getProperty("java.version"), "1.6"}));
}
if (!JDK.isRunningLTSJDK()) {
logger.warning("You are running the product on an unsupported JDK version and might see unexpected results or exceptions.");
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
import com.sun.enterprise.glassfish.bootstrap.GlassFishImpl;
import com.sun.enterprise.server.logging.ODLLogFormatter;

import com.sun.enterprise.util.JDK;
import fish.payara.deployment.util.JavaArchiveUtils;
import fish.payara.deployment.util.URIUtils;
import org.glassfish.embeddable.BootstrapProperties;
Expand Down Expand Up @@ -1054,6 +1055,10 @@ public PayaraMicroRuntime bootStrap() throws BootstrapException {
resetLogging(loggingProperty);
});
}
//Check a supported JDK version is being used
if (!JDK.isRunningLTSJDK()) {
LOGGER.warning("You are running the product on an unsupported JDK version and might see unexpected results or exceptions.");
}
runtimeDir.processDirectoryInformation();

// build the runtime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
# only if the new code is made subject to such option by the copyright
# holder.
#
# Portions Copyright [2021] Payara Foundation and/or affiliates

CommandSuccessful=Befehl {0} wurde erfolgreich ausgef\u00FChrt.
CommandSuccessfulWithWarnings=Befehl {0} wurde mit Warnungen abgeschlossen.
Expand Down Expand Up @@ -201,7 +202,6 @@ badEnvVarUnset=CLI163: Festlegung der Umgebungsvariable konnte nicht aufgehoben\
cantRemoveEnvVar=CLI149: Umgebungsvariable ist nicht festgelegt: {0}
operandPrompt=Geben Sie den Wert f\u00FCr den {0}-Operanden ein>
optionPrompt=Geben Sie den Wert f\u00FCr die {0}-Option ein>
OldJdk=GlassFish erfordert Java SE, Version 6. Ihr JDK ist Version {0}
DeprecatedSyntax=Verworfene Syntax. Verwenden Sie stattdessen:
## Parser
parser.noValueAllowed=Wert nicht zul\u00E4ssig f\u00FCr Option: {0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
# only if the new code is made subject to such option by the copyright
# holder.
#
# Portions Copyright [2021] Payara Foundation and/or affiliates

CommandSuccessful=El comando {0} se ha ejecutado correctamente.
CommandSuccessfulWithWarnings=El comando {0} se ha completado con advertencias.
Expand Down Expand Up @@ -201,7 +202,6 @@ badEnvVarUnset=CLI163: no se ha podido anular la definici\u00F3n de la variable
cantRemoveEnvVar=CLI149: la variable de entorno no est\u00E1 definida - {0}
operandPrompt=Introduzca el valor para el operando {0}>
optionPrompt=Introduzca el valor para la opci\u00F3n {0}>
OldJdk=GlassFish necesita Java SE versi\u00F3n 6. Su versi\u00F3n de JDK es {0}
DeprecatedSyntax=Sintaxis anticuada; en su lugar utilice:
## Parser
parser.noValueAllowed=La opci\u00F3n no puede tener el valor: {0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
# only if the new code is made subject to such option by the copyright
# holder.
#
# Portions Copyright [2021] Payara Foundation and/or affiliates

CommandSuccessful=La commande {0} a \u00E9t\u00E9 correctement ex\u00E9cut\u00E9e.
CommandSuccessfulWithWarnings=La commande {0} a \u00E9t\u00E9 ex\u00E9cut\u00E9e avec des avertissements.
Expand Down Expand Up @@ -201,7 +202,6 @@ badEnvVarUnset=CLI163 : impossible d''annuler la d\u00E9finition de la variable
cantRemoveEnvVar=CLI149 : la variable d''environnement n''est pas d\u00E9finie : {0}
operandPrompt=Entrez la valeur de l''op\u00E9rande {0}>
optionPrompt=Entrez la valeur de l''option {0}>
OldJdk=GlassFish n\u00E9cessite la version 6 de Java SE. Votre Java Development Kit (JDK) utilise la version {0}
DeprecatedSyntax=Syntaxe en phase d'abandon, utilisez plut\u00F4t :
## Parser
parser.noValueAllowed=L''option ne peut avoir la valeur : {0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
# only if the new code is made subject to such option by the copyright
# holder.
#
# Portions Copyright [2021] Payara Foundation and/or affiliates

CommandSuccessful=Esecuzione del comando {0} riuscita.
CommandSuccessfulWithWarnings=Comando {0} completato con avvertenze.
Expand Down Expand Up @@ -201,7 +202,6 @@ badEnvVarUnset=CLI163 Impossibile annullare l''impostazione della variabile di a
cantRemoveEnvVar=CLI149 Variabile di ambiente non impostata: {0}
operandPrompt=Immettere il valore per l''operando {0}>
optionPrompt=Immettere il valore per l''opzione {0}>
OldJdk=GlassFish richiede Java SE versione 6. Versione JDK in uso: {0}
DeprecatedSyntax=Sintassi deprecata, usare:
## Parser
parser.noValueAllowed=L''opzione non pu\u00F2 avere il valore {0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
# only if the new code is made subject to such option by the copyright
# holder.
#
# Portions Copyright [2021] Payara Foundation and/or affiliates

CommandSuccessful=\u30B3\u30DE\u30F3\u30C9{0}\u306F\u6B63\u5E38\u306B\u5B9F\u884C\u3055\u308C\u307E\u3057\u305F\u3002
CommandSuccessfulWithWarnings=\u30B3\u30DE\u30F3\u30C9{0}\u306F\u5B8C\u4E86\u3057\u307E\u3057\u305F\u304C\u3001\u8B66\u544A\u304C\u3042\u308A\u307E\u3059\u3002
Expand Down Expand Up @@ -201,7 +202,6 @@ badEnvVarUnset=CLI163: \u74B0\u5883\u5909\u6570\u3092\u8A2D\u5B9A\u89E3\u9664\u3
cantRemoveEnvVar=CLI149: \u74B0\u5883\u5909\u6570\u306F\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093: {0}
operandPrompt={0}\u30AA\u30DA\u30E9\u30F3\u30C9\u306E\u5024\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044>
optionPrompt={0}\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u5024\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044>
OldJdk=GlassFish\u3067\u306FJava SE\u306E\u30D0\u30FC\u30B8\u30E7\u30F36\u304C\u5FC5\u8981\u3067\u3059\u3002\u4F7F\u7528\u4E2D\u306EJDK\u306E\u30D0\u30FC\u30B8\u30E7\u30F3\u306F{0}\u3067\u3059
DeprecatedSyntax=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u69CB\u6587\u3067\u3059\u3002\u6B21\u306E\u69CB\u6587\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044:
## Parser
parser.noValueAllowed=\u30AA\u30D7\u30B7\u30E7\u30F3\u306B\u5024\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093: {0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
# only if the new code is made subject to such option by the copyright
# holder.
#
# Portions Copyright [2021] Payara Foundation and/or affiliates

CommandSuccessful={0} \uBA85\uB839\uC774 \uC131\uACF5\uC801\uC73C\uB85C \uC2E4\uD589\uB418\uC5C8\uC2B5\uB2C8\uB2E4.
CommandSuccessfulWithWarnings=\uBA85\uB839 {0}\uC774(\uAC00) \uC644\uB8CC\uB418\uC5C8\uC9C0\uB9CC \uACBD\uACE0\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4.
Expand Down Expand Up @@ -201,7 +202,6 @@ badEnvVarUnset=CLI163: \uD658\uACBD \uBCC0\uC218\uB97C \uC124\uC815 \uD574\uC81C
cantRemoveEnvVar=CLI149: \uD658\uACBD \uBCC0\uC218\uAC00 \uC124\uC815\uB418\uC9C0 \uC54A\uC74C: {0}
operandPrompt={0} \uD53C\uC5F0\uC0B0\uC790\uC5D0 \uB300\uD55C \uAC12 \uC785\uB825>
optionPrompt={0} \uC635\uC158\uC5D0 \uB300\uD55C \uAC12 \uC785\uB825>
OldJdk=GlassFish\uC5D0\uB294 Java SE \uBC84\uC804 6\uC774 \uD544\uC694\uD569\uB2C8\uB2E4. \uD604\uC7AC JDK \uBC84\uC804\uC740 {0}\uC785\uB2C8\uB2E4.
DeprecatedSyntax=\uB354 \uC774\uC0C1 \uC0AC\uC6A9\uB418\uC9C0 \uC54A\uB294 \uAD6C\uBB38\uC785\uB2C8\uB2E4. \uB2E4\uC74C\uC744 \uB300\uC2E0 \uC0AC\uC6A9\uD558\uC2ED\uC2DC\uC624.
## Parser
parser.noValueAllowed=\uC635\uC158\uC5D0 \uAC12\uC774 \uC5C6\uC744 \uC218 \uC788\uC2B5\uB2C8\uB2E4. {0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
# only if the new code is made subject to such option by the copyright
# holder.
#
# Portions Copyright [2021] Payara Foundation and/or affiliates

CommandSuccessful=Comando {0} executado com sucesso.
CommandSuccessfulWithWarnings=Comando {0} conclu\u00EDdo com advert\u00EAncias.
Expand Down Expand Up @@ -201,7 +202,6 @@ badEnvVarUnset=CLI163: N\u00E3o \u00E9 poss\u00EDvel cancelar defini\u00E7\u00E3
cantRemoveEnvVar=CLI149: A vari\u00E1vel de ambiente n\u00E3o est\u00E1 definida: {0}
operandPrompt=Digite o valor do operando {0}>
optionPrompt=Digite o valor da op\u00E7\u00E3o {0}>
OldJdk=GlassFish exige Java SE vers\u00E3o 6. A vers\u00E3o do seu JDK \u00E9 {0}
DeprecatedSyntax=Sintaxe obsoleta; em vez dela use:
## Parser
parser.noValueAllowed=A op\u00E7\u00E3o n\u00E3o pode ter valor: {0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
# only if the new code is made subject to such option by the copyright
# holder.
#
# Portions Copyright [2021] Payara Foundation and/or affiliates

CommandSuccessful=\u5DF2\u6210\u529F\u6267\u884C\u547D\u4EE4{0}\u3002
CommandSuccessfulWithWarnings=\u547D\u4EE4{0}\u5DF2\u5B8C\u6210, \u4F46\u51FA\u73B0\u8B66\u544A\u3002
Expand Down Expand Up @@ -201,7 +202,6 @@ badEnvVarUnset=CLI163: \u65E0\u6CD5\u53D6\u6D88\u8BBE\u7F6E\u73AF\u5883\u53D8\u9
cantRemoveEnvVar=CLI149: \u73AF\u5883\u53D8\u91CF\u672A\u8BBE\u7F6E: {0}
operandPrompt=\u8BF7\u8F93\u5165{0}\u64CD\u4F5C\u6570\u7684\u503C>
optionPrompt=\u8BF7\u8F93\u5165{0}\u9009\u9879\u7684\u503C>
OldJdk=GlassFish \u9700\u8981 Java SE \u7B2C 6 \u7248\u3002\u60A8\u7684 JDK \u7248\u672C\u4E3A{0}
DeprecatedSyntax=\u8BED\u6CD5\u5DF2\u8FC7\u65F6, \u8BF7\u6539\u7528:
## Parser
parser.noValueAllowed=\u9009\u9879\u4E0D\u80FD\u6709\u4EE5\u4E0B\u503C: {0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
# only if the new code is made subject to such option by the copyright
# holder.
#
# Portions Copyright [2021] Payara Foundation and/or affiliates

CommandSuccessful=\u5DF2\u6210\u529F\u57F7\u884C\u547D\u4EE4 {0}\u3002
CommandSuccessfulWithWarnings=\u547D\u4EE4 {0} \u5DF2\u5B8C\u6210\uFF0C\u4F46\u51FA\u73FE\u8B66\u544A\u3002
Expand Down Expand Up @@ -201,7 +202,6 @@ badEnvVarUnset=CLI163\uFF1A\u7121\u6CD5\u53D6\u6D88\u8A2D\u5B9A\u74B0\u5883\u8B8
cantRemoveEnvVar=CLI149\uFF1A\u672A\u8A2D\u5B9A\u74B0\u5883\u8B8A\u6578\uFF1A{0}
operandPrompt=\u8F38\u5165 {0} \u904B\u7B97\u5143\u7684\u503C>
optionPrompt=\u8F38\u5165 {0} \u9078\u9805\u7684\u503C>
OldJdk=GlassFish \u9700\u8981 Java SE \u7B2C 6 \u7248\u3002\u60A8\u7684 JDK \u7248\u672C\u662F {0}
DeprecatedSyntax=\u8A9E\u6CD5\u5DF2\u505C\u7528\uFF0C\u8ACB\u6539\u7528\uFF1A
## Parser
parser.noValueAllowed=\u9078\u9805\u4E0D\u53EF\u5305\u542B\u503C\uFF1A{0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2018] Payara Foundation and/or affiliates
// Portions Copyright [2018-2021] Payara Foundation and/or affiliates
package com.sun.enterprise.admin.cli;

import com.sun.enterprise.admin.remote.reader.ProprietaryReaderFactory;
Expand Down Expand Up @@ -204,18 +204,6 @@ public static void main(String[] args) {
}

protected int doMain(String[] args) {
int minor = JDK.getMinor();
int major = JDK.getMajor();
//In case of JDK1 to JDK8 the major version would be 1 always.Starting from
//JDK9 the major verion would be the real major version e.g in case
// of JDK9 major version is 9.So in that case checking the major version only.
if (major<9) {
if (minor < 6) {
System.err.println(strings.get( "OldJdk", "" + minor));
return ERROR;
}
}

boolean trace = env.trace();
boolean debug = env.debug();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
# only if the new code is made subject to such option by the copyright
# holder.
#
# Portions Copyright [2019] Payara Foundation and/or affiliates
# Portions Copyright [2019-2021] Payara Foundation and/or affiliates

CommandSuccessful=Command {0} executed successfully.
CommandSuccessfulWithWarnings=Command {0} completed with warnings.
Expand Down Expand Up @@ -198,7 +198,6 @@ badEnvVarUnset=CLI163: Could not unset environment variable: {0}\nVariable names
cantRemoveEnvVar=CLI149: Environment variable is not set: {0}
operandPrompt=Enter the value for the {0} operand>
optionPrompt=Enter the value for the {0} option>
OldJdk=Payara requires Java SE version 7 or higher. The JDK version appears to be {0}
DeprecatedSyntax=Deprecated syntax, instead use:
## Parser
parser.noValueAllowed=Option may not have value: {0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2016-2020] [Payara Foundation and/or its affiliates]
// Portions Copyright [2016-2021] [Payara Foundation and/or its affiliates]

package com.sun.enterprise.admin.launcher;

Expand Down Expand Up @@ -229,6 +229,7 @@ public void setup() throws GFLauncherException, MiniXmlParserException {
setCommandLine();
setJvmOptions();
logCommandLine();
checkJDKVersion();
// if no <network-config> element, we need to upgrade this domain
needsAutoUpgrade = !parser.hasNetworkConfig();
needsManualUpgrade = !parser.hasDefaultConfig();
Expand Down Expand Up @@ -1059,6 +1060,12 @@ void logCommandLine() {
}
}

private void checkJDKVersion() {
if(!JDK.isRunningLTSJDK()) {
GFLauncherLogger.warning("You are running the product on an unsupported JDK version and might see unexpected results or exceptions.");
}
}

String getClasspath() {
return classpath;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2018-2020] [Payara Foundation and/or its affiliates]
// Portions Copyright [2018-2021] [Payara Foundation and/or its affiliates]

package com.sun.enterprise.util;

Expand Down Expand Up @@ -74,6 +74,18 @@ public static boolean isOpenJSSEFlagRequired() {
&& updateVersion <= OPENJSSE_MAXIMUM_UPDATE_VERSION;
}

/**
* See if the current JDK is an LTS version
* @return true if JDK is an LTS version (8, 11, 17, 21, 25, 29...)
*/
public static boolean isRunningLTSJDK() {
int major = getMajor();
int minor = getMinor();
//Checks for LTS JDK versions following the 2 year LTS cadence after and including JDK 17
//JDK 1-8 always have a major version of 1.
return (major - 17) % 4 == 0 && major >= 17 || (major == 1 && minor == 8) || major == 11;
}

/**
* See if the current JDK is legal for running GlassFish
* @return true if the JDK is >= 1.6.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2021] [Payara Foundation and/or its affiliates]

package com.sun.enterprise.glassfish.bootstrap;

Expand Down Expand Up @@ -80,13 +81,6 @@ public static void log(Logger logger, Level level, String messageId,
logger.log(rec);
}

@LogMessageInfo(
message = "GlassFish requires JDK {0}, you are using JDK version {1}.",
level = "SEVERE",
cause="Incorrect JDK version is used.",
action="Please use correct JDK version.")
public static final String BOOTSTRAP_INCORRECT_JDKVERSION = "NCLS-BOOTSTRAP-00001";

@LogMessageInfo(
message = "Using {0} as the framework configuration file.",
level = "INFO")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2017-2019] [Payara Foundation and/or its affiliates]
// Portions Copyright [2017-2021] [Payara Foundation and/or its affiliates]

package com.sun.enterprise.glassfish.bootstrap;

Expand Down Expand Up @@ -69,16 +69,8 @@ public class MainHelper {
/*protected*/

static void checkJdkVersion() {
int major = JDK.getMajor();
int minor = JDK.getMinor();
//In case of JDK1 to JDK8 the major version would be 1 always.Starting from
//JDK9 the major verion would be the real major version e.g in case
// of JDK9 major version is 9.So in that case checking the major version only
if (major < 9) {
if (minor < 8) {
logger.log(Level.SEVERE, LogFacade.BOOTSTRAP_INCORRECT_JDKVERSION, new Object[]{8, minor});
System.exit(1);
}
if(!JDK.isRunningLTSJDK()) {
logger.warning("You are running the product on an unsupported JDK version and might see unexpected results or exceptions.");
}
}

Expand Down

0 comments on commit d47d607

Please sign in to comment.