From d9d881dd5ae21e5f7bb8fef81c8de392629575c3 Mon Sep 17 00:00:00 2001 From: Jim Gish Date: Tue, 5 Jul 2022 20:54:06 +0000 Subject: [PATCH 1/8] JIRA WDT-638 - Should never exit with uncaught exceptions --- core/src/main/python/compare_model.py | 5 +++- core/src/main/python/create.py | 5 +++- core/src/main/python/deploy.py | 6 +++- core/src/main/python/discover.py | 8 ++++-- core/src/main/python/encrypt.py | 5 +++- core/src/main/python/extract_resource.py | 5 +++- core/src/main/python/model_help.py | 5 +++- core/src/main/python/prepare_model.py | 6 +++- core/src/main/python/update.py | 5 +++- core/src/main/python/validate.py | 5 +++- core/src/main/python/variable_inject.py | 5 +++- .../wlsdeploy/exception/exception_helper.py | 28 +++++++++++++++++++ .../deploy/messages/wlsdeploy_rb.properties | 2 ++ 13 files changed, 78 insertions(+), 12 deletions(-) diff --git a/core/src/main/python/compare_model.py b/core/src/main/python/compare_model.py index 9d793343c..3bfcd6cf5 100644 --- a/core/src/main/python/compare_model.py +++ b/core/src/main/python/compare_model.py @@ -348,4 +348,7 @@ def format_message(key, *args): if __name__ == "__main__": - main() + try: + main() + except: + exception_helper.__handleUnexpectedException(sys.exc_info(), _program_name, _class_name, _logger) diff --git a/core/src/main/python/create.py b/core/src/main/python/create.py index 6daff2c07..f76644fb8 100644 --- a/core/src/main/python/create.py +++ b/core/src/main/python/create.py @@ -376,4 +376,7 @@ def main(args): if __name__ == '__main__' or __name__ == 'main': WebLogicDeployToolingVersion.logVersionInfo(_program_name) - main(sys.argv) + try: + main(sys.argv) + except: + exception_helper.__handleUnexpectedException(sys.exc_info(), _program_name, _class_name, __logger) diff --git a/core/src/main/python/deploy.py b/core/src/main/python/deploy.py index 80cc1156c..74580d586 100644 --- a/core/src/main/python/deploy.py +++ b/core/src/main/python/deploy.py @@ -17,6 +17,7 @@ # imports from local packages start here from wlsdeploy.aliases.aliases import Aliases from wlsdeploy.aliases.wlst_modes import WlstModes +from wlsdeploy.exception import exception_helper from wlsdeploy.exception.expection_types import ExceptionType from wlsdeploy.logging.platform_logger import PlatformLogger from wlsdeploy.tool.deploy import deployer_utils @@ -258,4 +259,7 @@ def main(args): if __name__ == '__main__' or __name__ == 'main': WebLogicDeployToolingVersion.logVersionInfo(_program_name) - main(sys.argv) + try: + main(sys.argv) + except: + exception_helper.__handleUnexpectedException(sys.exc_info(), _program_name, _class_name, __logger) diff --git a/core/src/main/python/discover.py b/core/src/main/python/discover.py index fca2f1549..87d9a4c48 100644 --- a/core/src/main/python/discover.py +++ b/core/src/main/python/discover.py @@ -367,6 +367,7 @@ def __disconnect_domain(helper): _method_name = '__disconnect_domain' __logger.entering(class_name=_class_name, method_name=_method_name) + if __wlst_mode == WlstModes.ONLINE: try: helper.disconnect() @@ -571,7 +572,6 @@ def main(args): :return: """ _method_name = 'main' - __logger.entering(class_name=_class_name, method_name=_method_name) for index, arg in enumerate(args): __logger.finer('sys.argv[{0}] = {1}', str(index), str(arg), class_name=_class_name, method_name=_method_name) @@ -638,4 +638,8 @@ def main(args): if __name__ == '__main__' or __name__ == 'main': WebLogicDeployToolingVersion.logVersionInfo(_program_name) - main(sys.argv) + try: + main(sys.argv) + except: + exception_helper.__handleUnexpectedException(sys.exc_info(), _program_name, _class_name, __logger) + diff --git a/core/src/main/python/encrypt.py b/core/src/main/python/encrypt.py index f76b972a9..89b71171b 100644 --- a/core/src/main/python/encrypt.py +++ b/core/src/main/python/encrypt.py @@ -253,4 +253,7 @@ def main(args): if __name__ == '__main__' or __name__ == 'main': WebLogicDeployToolingVersion.logVersionInfo(_program_name) - main(sys.argv) + try: + main(sys.argv) + except: + exception_helper.__handleUnexpectedException(sys.exc_info(), _program_name, _class_name, __logger) diff --git a/core/src/main/python/extract_resource.py b/core/src/main/python/extract_resource.py index 091cb33c8..1f3c82201 100644 --- a/core/src/main/python/extract_resource.py +++ b/core/src/main/python/extract_resource.py @@ -158,4 +158,7 @@ def main(args): if __name__ == '__main__' or __name__ == 'main': WebLogicDeployToolingVersion.logVersionInfo(_program_name) - main(sys.argv) + try: + main(sys.argv) + except: + exception_helper.__handleUnexpectedException(sys.exc_info(), _program_name, _class_name, __logger) diff --git a/core/src/main/python/model_help.py b/core/src/main/python/model_help.py index 972adca88..434a5a977 100644 --- a/core/src/main/python/model_help.py +++ b/core/src/main/python/model_help.py @@ -133,4 +133,7 @@ def main(args): if __name__ == '__main__' or __name__ == 'main': WebLogicDeployToolingVersion.logVersionInfo(_program_name) - main(sys.argv) + try: + main(sys.argv) + except: + exception_helper.__handleUnexpectedException(sys.exc_info(), _program_name, _class_name, __logger) diff --git a/core/src/main/python/prepare_model.py b/core/src/main/python/prepare_model.py index 33a552992..4860f02a6 100644 --- a/core/src/main/python/prepare_model.py +++ b/core/src/main/python/prepare_model.py @@ -15,6 +15,7 @@ from oracle.weblogic.deploy.util import WebLogicDeployToolingVersion from oracle.weblogic.deploy.prepare import PrepareException +from wlsdeploy.exception import exception_helper from wlsdeploy.logging.platform_logger import PlatformLogger from wlsdeploy.tool.prepare.model_preparer import ModelPreparer from wlsdeploy.tool.util import model_context_helper @@ -109,4 +110,7 @@ def main(): if __name__ == "__main__" or __name__ == 'main': WebLogicDeployToolingVersion.logVersionInfo(_program_name) - main() + try: + main() + except: + exception_helper.__handleUnexpectedException(sys.exc_info(), _program_name, _class_name, __logger) diff --git a/core/src/main/python/update.py b/core/src/main/python/update.py index 970719bb4..030eeb432 100644 --- a/core/src/main/python/update.py +++ b/core/src/main/python/update.py @@ -309,4 +309,7 @@ def main(args): if __name__ == '__main__' or __name__ == 'main': WebLogicDeployToolingVersion.logVersionInfo(_program_name) - main(sys.argv) + try: + main(sys.argv) + except: + exception_helper.__handleUnexpectedException(sys.exc_info(), _program_name, _class_name, __logger) diff --git a/core/src/main/python/validate.py b/core/src/main/python/validate.py index 1080d9c29..6f267d277 100644 --- a/core/src/main/python/validate.py +++ b/core/src/main/python/validate.py @@ -196,4 +196,7 @@ def main(args): if __name__ == '__main__' or __name__ == 'main': WebLogicDeployToolingVersion.logVersionInfo(_program_name) - main(sys.argv) + try: + main(sys.argv) + except: + exception_helper.__handleUnexpectedException(sys.exc_info(), _program_name, _class_name, __logger) diff --git a/core/src/main/python/variable_inject.py b/core/src/main/python/variable_inject.py index 29822804c..e4947cdf7 100644 --- a/core/src/main/python/variable_inject.py +++ b/core/src/main/python/variable_inject.py @@ -204,4 +204,7 @@ def main(args): if __name__ == '__main__' or __name__ == 'main': WebLogicDeployToolingVersion.logVersionInfo(_program_name) - main(sys.argv) + try: + main(sys.argv) + except: + exception_helper.__handleUnexpectedException(sys.exc_info(), _program_name, _class_name, __logger) diff --git a/core/src/main/python/wlsdeploy/exception/exception_helper.py b/core/src/main/python/wlsdeploy/exception/exception_helper.py index af98462f4..de7b65b66 100644 --- a/core/src/main/python/wlsdeploy/exception/exception_helper.py +++ b/core/src/main/python/wlsdeploy/exception/exception_helper.py @@ -31,6 +31,8 @@ import oracle.weblogic.deploy.yaml.YamlException as JYamlException from wlsdeploy.exception.expection_types import ExceptionType +from wlsdeploy.util.cla_utils import CommandLineArgUtil +from wlsdeploy.util import tool_exit _EXCEPTION_TYPE_MAP = { ExceptionType.ALIAS: 'create_alias_exception', @@ -462,3 +464,29 @@ def _return_exception_params(*args, **kwargs): arg_list = list(args) error = kwargs.pop('error', None) return arg_list, error + +def __log_and_exit(logger, exit_code, class_name): + """ + Helper method to log the exiting message and call sys.exit() + :param logger: the logger to use + :param exit_code: the exit code to use + :param class_name: the class name to pass to the logger + """ + logger.exiting(result=exit_code, class_name=class_name, method_name=None) + tool_exit.end(None, exit_code) + +def __handleUnexpectedException(ex, program_name, class_name, logger): + """ + Helper method to log and unexpected exception with exiting message and call sys.exit() + Note that the user sees the 'Unexpected' message along with the exception, but no stack trace. + The stack trace goes to the log + :param ex: the exception thrown + :param program_name: the program where it occurred + :param class_name: the class where it occurred + :param logger: the logger to use + """ + exc_type, exc_obj, exc_tb = sys.exc_info() + ee_string = traceback.format_exception(exc_type, exc_obj, exc_tb) + logger.severe('WLSDPLY-20035', program_name, exc_obj) + logger.finer('WLSDPLY-20036', program_name, ee_string) + __log_and_exit(logger, CommandLineArgUtil.PROG_ERROR_EXIT_CODE, class_name) diff --git a/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties b/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties index a4a43c212..5889bbfe4 100644 --- a/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties +++ b/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties @@ -1671,6 +1671,8 @@ WLSDPLY-20031={0} specified Variable File {1} is not a valid file: {2} WLSDPLY-20032=No model specified and no model in archive, no validation performed WLSDPLY-20033=Applying filter with name "{0}" WLSDPLY-20034=Applying filter with ID "{0}" +WLSDPLY-20035={0} encountered an unexpected runtime exception. Please file an issue on GitHub and attach the log file and stdout. Error: {1} +WLSDPLY-20036={0} encountered an unexpected runtime exception. Stacktrace: {1} # Messages for internal filters WLSDPLY-20201=Unsupported attribute {0} at location {1} removed from model From e2a955cc26816521c798ec508d0681cbcc77f273 Mon Sep 17 00:00:00 2001 From: Jim Gish Date: Wed, 6 Jul 2022 20:12:06 +0000 Subject: [PATCH 2/8] JIRA WDT-638 - simplify handling of uncaught exceptions --- core/src/main/python/compare_model.py | 4 ++-- core/src/main/python/create.py | 4 ++-- core/src/main/python/deploy.py | 4 ++-- core/src/main/python/discover.py | 5 +++-- core/src/main/python/encrypt.py | 4 ++-- core/src/main/python/extract_resource.py | 4 ++-- core/src/main/python/model_help.py | 4 ++-- core/src/main/python/prepare_model.py | 4 ++-- core/src/main/python/update.py | 4 ++-- core/src/main/python/validate.py | 4 ++-- core/src/main/python/variable_inject.py | 4 ++-- .../src/main/python/wlsdeploy/exception/exception_helper.py | 6 ++---- 12 files changed, 25 insertions(+), 26 deletions(-) diff --git a/core/src/main/python/compare_model.py b/core/src/main/python/compare_model.py index 3bfcd6cf5..a047b0703 100644 --- a/core/src/main/python/compare_model.py +++ b/core/src/main/python/compare_model.py @@ -350,5 +350,5 @@ def format_message(key, *args): if __name__ == "__main__": try: main() - except: - exception_helper.__handleUnexpectedException(sys.exc_info(), _program_name, _class_name, _logger) + except Exception, ex: + exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, _logger) diff --git a/core/src/main/python/create.py b/core/src/main/python/create.py index f76644fb8..12cc98323 100644 --- a/core/src/main/python/create.py +++ b/core/src/main/python/create.py @@ -378,5 +378,5 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) - except: - exception_helper.__handleUnexpectedException(sys.exc_info(), _program_name, _class_name, __logger) + except Exception, ex: + exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/deploy.py b/core/src/main/python/deploy.py index 74580d586..30f20684a 100644 --- a/core/src/main/python/deploy.py +++ b/core/src/main/python/deploy.py @@ -261,5 +261,5 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) - except: - exception_helper.__handleUnexpectedException(sys.exc_info(), _program_name, _class_name, __logger) + except Exception, ex: + exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/discover.py b/core/src/main/python/discover.py index 87d9a4c48..f2d2d02b3 100644 --- a/core/src/main/python/discover.py +++ b/core/src/main/python/discover.py @@ -11,6 +11,7 @@ from java.io import IOException from java.lang import IllegalArgumentException from java.lang import IllegalStateException +from java.lang import RuntimeException from oracle.weblogic.deploy.aliases import AliasException from oracle.weblogic.deploy.discover import DiscoverException from oracle.weblogic.deploy.json import JsonException @@ -640,6 +641,6 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) - except: - exception_helper.__handleUnexpectedException(sys.exc_info(), _program_name, _class_name, __logger) + except Exception, ex: + exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/encrypt.py b/core/src/main/python/encrypt.py index 89b71171b..5ba58c21b 100644 --- a/core/src/main/python/encrypt.py +++ b/core/src/main/python/encrypt.py @@ -255,5 +255,5 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) - except: - exception_helper.__handleUnexpectedException(sys.exc_info(), _program_name, _class_name, __logger) + except Exception, ex: + exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/extract_resource.py b/core/src/main/python/extract_resource.py index 1f3c82201..36bff5aa4 100644 --- a/core/src/main/python/extract_resource.py +++ b/core/src/main/python/extract_resource.py @@ -160,5 +160,5 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) - except: - exception_helper.__handleUnexpectedException(sys.exc_info(), _program_name, _class_name, __logger) + except Exception, ex: + exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/model_help.py b/core/src/main/python/model_help.py index 434a5a977..17555e600 100644 --- a/core/src/main/python/model_help.py +++ b/core/src/main/python/model_help.py @@ -135,5 +135,5 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) - except: - exception_helper.__handleUnexpectedException(sys.exc_info(), _program_name, _class_name, __logger) + except Exception, ex: + exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/prepare_model.py b/core/src/main/python/prepare_model.py index 4860f02a6..7b9ce6cce 100644 --- a/core/src/main/python/prepare_model.py +++ b/core/src/main/python/prepare_model.py @@ -112,5 +112,5 @@ def main(): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main() - except: - exception_helper.__handleUnexpectedException(sys.exc_info(), _program_name, _class_name, __logger) + except Exception, ex: + exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/update.py b/core/src/main/python/update.py index 030eeb432..120198c4f 100644 --- a/core/src/main/python/update.py +++ b/core/src/main/python/update.py @@ -311,5 +311,5 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) - except: - exception_helper.__handleUnexpectedException(sys.exc_info(), _program_name, _class_name, __logger) + except Exception, ex: + exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/validate.py b/core/src/main/python/validate.py index 6f267d277..82f91fb92 100644 --- a/core/src/main/python/validate.py +++ b/core/src/main/python/validate.py @@ -198,5 +198,5 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) - except: - exception_helper.__handleUnexpectedException(sys.exc_info(), _program_name, _class_name, __logger) + except Exception, ex: + exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/variable_inject.py b/core/src/main/python/variable_inject.py index e4947cdf7..252e53e43 100644 --- a/core/src/main/python/variable_inject.py +++ b/core/src/main/python/variable_inject.py @@ -206,5 +206,5 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) - except: - exception_helper.__handleUnexpectedException(sys.exc_info(), _program_name, _class_name, __logger) + except Exception, ex: + exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/wlsdeploy/exception/exception_helper.py b/core/src/main/python/wlsdeploy/exception/exception_helper.py index de7b65b66..2029de2da 100644 --- a/core/src/main/python/wlsdeploy/exception/exception_helper.py +++ b/core/src/main/python/wlsdeploy/exception/exception_helper.py @@ -485,8 +485,6 @@ def __handleUnexpectedException(ex, program_name, class_name, logger): :param class_name: the class where it occurred :param logger: the logger to use """ - exc_type, exc_obj, exc_tb = sys.exc_info() - ee_string = traceback.format_exception(exc_type, exc_obj, exc_tb) - logger.severe('WLSDPLY-20035', program_name, exc_obj) - logger.finer('WLSDPLY-20036', program_name, ee_string) + logger.severe('WLSDPLY-20035', program_name, ex) + logger.finer('WLSDPLY-20036', program_name, ex.stackTrace) __log_and_exit(logger, CommandLineArgUtil.PROG_ERROR_EXIT_CODE, class_name) From cefd63ae95514ac892e1a08509bfcc6596944ec6 Mon Sep 17 00:00:00 2001 From: Jim Gish Date: Wed, 6 Jul 2022 20:16:09 +0000 Subject: [PATCH 3/8] JIRA WDT-638 - remove unnecessary import --- core/src/main/python/discover.py | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/main/python/discover.py b/core/src/main/python/discover.py index f2d2d02b3..083c7cf57 100644 --- a/core/src/main/python/discover.py +++ b/core/src/main/python/discover.py @@ -11,7 +11,6 @@ from java.io import IOException from java.lang import IllegalArgumentException from java.lang import IllegalStateException -from java.lang import RuntimeException from oracle.weblogic.deploy.aliases import AliasException from oracle.weblogic.deploy.discover import DiscoverException from oracle.weblogic.deploy.json import JsonException From b0ca00e2601943ccdc9d820552ee2aae29aeb081 Mon Sep 17 00:00:00 2001 From: Jim Gish Date: Thu, 7 Jul 2022 21:17:54 +0000 Subject: [PATCH 4/8] JIRA WDT-638 - separate Java and Python exception handling --- core/src/main/python/compare_model.py | 4 +++- core/src/main/python/create.py | 6 +++++- core/src/main/python/deploy.py | 5 ++++- core/src/main/python/discover.py | 5 ++++- core/src/main/python/encrypt.py | 5 +++-- core/src/main/python/extract_resource.py | 4 +++- core/src/main/python/model_help.py | 6 +++++- core/src/main/python/prepare_model.py | 7 +++++-- core/src/main/python/update.py | 5 ++++- core/src/main/python/validate.py | 6 +++++- core/src/main/python/variable_inject.py | 3 ++- .../python/wlsdeploy/exception/exception_helper.py | 10 +++++++++- 12 files changed, 52 insertions(+), 14 deletions(-) diff --git a/core/src/main/python/compare_model.py b/core/src/main/python/compare_model.py index a047b0703..85bc8f3be 100644 --- a/core/src/main/python/compare_model.py +++ b/core/src/main/python/compare_model.py @@ -11,6 +11,7 @@ # # If the flag is not provided then all output is written to the standard out. # +import exceptions import os import sets import sys @@ -21,6 +22,7 @@ import java.io.IOException as JIOException import java.io.PrintWriter as JPrintWriter from java.lang import System +from java.lang import Throwable from oracle.weblogic.deploy.compare import CompareException from oracle.weblogic.deploy.exception import ExceptionHelper from oracle.weblogic.deploy.util import CLAException @@ -350,5 +352,5 @@ def format_message(key, *args): if __name__ == "__main__": try: main() - except Exception, ex: + except (exceptions.Exception, Throwable), ex: exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, _logger) diff --git a/core/src/main/python/create.py b/core/src/main/python/create.py index 12cc98323..84e837e29 100644 --- a/core/src/main/python/create.py +++ b/core/src/main/python/create.py @@ -4,12 +4,15 @@ The main module for the WLSDeploy tool to create empty domains. """ +import exceptions import os import sys + from java.io import IOException from java.lang import IllegalArgumentException from java.lang import String from java.lang import System +from java.lang import Throwable from oracle.weblogic.deploy.create import CreateException from oracle.weblogic.deploy.deploy import DeployException from oracle.weblogic.deploy.util import CLAException @@ -378,5 +381,6 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) - except Exception, ex: + except (exceptions.Exception, Throwable), ex: exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) + diff --git a/core/src/main/python/deploy.py b/core/src/main/python/deploy.py index 30f20684a..4cd84fd96 100644 --- a/core/src/main/python/deploy.py +++ b/core/src/main/python/deploy.py @@ -4,9 +4,12 @@ The entry point for the deployApps tool. """ +import exceptions import os import sys +from java.lang import Throwable + from oracle.weblogic.deploy.deploy import DeployException from oracle.weblogic.deploy.exception import BundleAwareException from oracle.weblogic.deploy.util import CLAException @@ -261,5 +264,5 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) - except Exception, ex: + except (exceptions.Exception, Throwable), ex: exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/discover.py b/core/src/main/python/discover.py index 083c7cf57..b0b9b3684 100644 --- a/core/src/main/python/discover.py +++ b/core/src/main/python/discover.py @@ -4,6 +4,7 @@ The entry point for the discoverDomain tool. """ +import exceptions import os import sys @@ -11,6 +12,7 @@ from java.io import IOException from java.lang import IllegalArgumentException from java.lang import IllegalStateException +from java.lang import Throwable from oracle.weblogic.deploy.aliases import AliasException from oracle.weblogic.deploy.discover import DiscoverException from oracle.weblogic.deploy.json import JsonException @@ -234,6 +236,7 @@ def __discover(model_context, aliases, credential_injector, helper): model = Model() base_location = LocationContext() __connect_to_domain(model_context, helper) + try: _add_domain_name(base_location, aliases, helper) DomainInfoDiscoverer(model_context, model.get_model_domain_info(), base_location, wlst_mode=__wlst_mode, @@ -640,6 +643,6 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) - except Exception, ex: + except (exceptions.Exception, Throwable), ex: exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/encrypt.py b/core/src/main/python/encrypt.py index 5ba58c21b..710867167 100644 --- a/core/src/main/python/encrypt.py +++ b/core/src/main/python/encrypt.py @@ -4,10 +4,11 @@ The main module for the WLSDeploy tool to encrypt passwords. """ +import exceptions import sys from java.io import IOException -from java.lang import String, System +from java.lang import String, System, Throwable from oracle.weblogic.deploy.encrypt import EncryptionException from oracle.weblogic.deploy.util import CLAException @@ -255,5 +256,5 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) - except Exception, ex: + except (exceptions.Exception, Throwable), ex: exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/extract_resource.py b/core/src/main/python/extract_resource.py index 36bff5aa4..ce93f53b8 100644 --- a/core/src/main/python/extract_resource.py +++ b/core/src/main/python/extract_resource.py @@ -4,8 +4,10 @@ The entry point for the extractDomainResource tool. """ +import exceptons import sys +from java.lang import Throwable from oracle.weblogic.deploy.deploy import DeployException from oracle.weblogic.deploy.util import CLAException from oracle.weblogic.deploy.util import WebLogicDeployToolingVersion @@ -160,5 +162,5 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) - except Exception, ex: + except (exceptions.Exception, Throwable), ex: exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/model_help.py b/core/src/main/python/model_help.py index 17555e600..b2a904683 100644 --- a/core/src/main/python/model_help.py +++ b/core/src/main/python/model_help.py @@ -4,8 +4,12 @@ The entry point for the modelHelp tool. """ +import excpetions import os import sys + +from java.lang import Throwable + from oracle.weblogic.deploy.util import CLAException from oracle.weblogic.deploy.util import WebLogicDeployToolingVersion @@ -135,5 +139,5 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) - except Exception, ex: + except (exceptions.Exception, Throwable), ex: exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/prepare_model.py b/core/src/main/python/prepare_model.py index 7b9ce6cce..56e64f2e9 100644 --- a/core/src/main/python/prepare_model.py +++ b/core/src/main/python/prepare_model.py @@ -7,9 +7,12 @@ # # This code prepare a list of models for deploying to WebLogic Kubernetes Operator Environment. +import exceptions +import sys import traceback -import sys +from java.lang import Throwable + from oracle.weblogic.deploy.util import CLAException from oracle.weblogic.deploy.util import PyWLSTException from oracle.weblogic.deploy.util import WebLogicDeployToolingVersion @@ -112,5 +115,5 @@ def main(): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main() - except Exception, ex: + except (exceptions.Exception, Throwable), ex: exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/update.py b/core/src/main/python/update.py index 120198c4f..76dd47c5d 100644 --- a/core/src/main/python/update.py +++ b/core/src/main/python/update.py @@ -4,9 +4,12 @@ The entry point for the updateDomain tool. """ +import exceptions import os import sys +from java.lang import Throwable + from oracle.weblogic.deploy.deploy import DeployException from oracle.weblogic.deploy.exception import BundleAwareException from oracle.weblogic.deploy.util import CLAException @@ -311,5 +314,5 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) - except Exception, ex: + except (exceptions.Exception, Throwable), ex: exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/validate.py b/core/src/main/python/validate.py index 82f91fb92..d59538362 100644 --- a/core/src/main/python/validate.py +++ b/core/src/main/python/validate.py @@ -4,8 +4,12 @@ The WLS Deploy tooling entry point for the validateModel tool. """ + import copy +import exceptions import sys + +from java.lang import Throwable from java.util.logging import Level from oracle.weblogic.deploy.logging import WLSDeployLogEndHandler @@ -198,5 +202,5 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) - except Exception, ex: + except (exceptions.Exception, Throwable), ex: exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/variable_inject.py b/core/src/main/python/variable_inject.py index 252e53e43..82aa11ed2 100644 --- a/core/src/main/python/variable_inject.py +++ b/core/src/main/python/variable_inject.py @@ -4,6 +4,7 @@ The entry point for the injectVariables tool. """ +import exceptions import sys from java.io import File @@ -206,5 +207,5 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) - except Exception, ex: + except (exceptions.Exception, Throwable), ex: exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/wlsdeploy/exception/exception_helper.py b/core/src/main/python/wlsdeploy/exception/exception_helper.py index 2029de2da..1c095d7ef 100644 --- a/core/src/main/python/wlsdeploy/exception/exception_helper.py +++ b/core/src/main/python/wlsdeploy/exception/exception_helper.py @@ -486,5 +486,13 @@ def __handleUnexpectedException(ex, program_name, class_name, logger): :param logger: the logger to use """ logger.severe('WLSDPLY-20035', program_name, ex) - logger.finer('WLSDPLY-20036', program_name, ex.stackTrace) + + if hasattr(ex, 'stackTrace'): + # this works best for java exceptions, and gets the full stacktrace all the way back to weblogic.WLST + logger.finer('WLSDPLY-20036', program_name, ex.stackTrace) + else: + # this is for Python exceptions + # Note: since this is Python 2, it seems we can only get the traceback object via sys.exc_info, and of course only + # while in the except block handling code + logger.finer('WLSDPLY-20036', program_name, traceback.format_exception(type(ex), ex, sys.exc_info()[2])) __log_and_exit(logger, CommandLineArgUtil.PROG_ERROR_EXIT_CODE, class_name) From 9284bc6e561f898802949fcb7ae98251d5e570d5 Mon Sep 17 00:00:00 2001 From: Jim Gish Date: Thu, 7 Jul 2022 21:27:49 +0000 Subject: [PATCH 5/8] JIRA WDT-638 - fix typo in import statements --- core/src/main/python/extract_resource.py | 2 +- core/src/main/python/model_help.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/python/extract_resource.py b/core/src/main/python/extract_resource.py index ce93f53b8..a8de24451 100644 --- a/core/src/main/python/extract_resource.py +++ b/core/src/main/python/extract_resource.py @@ -4,7 +4,7 @@ The entry point for the extractDomainResource tool. """ -import exceptons +import exceptions import sys from java.lang import Throwable diff --git a/core/src/main/python/model_help.py b/core/src/main/python/model_help.py index b2a904683..9ef4700c6 100644 --- a/core/src/main/python/model_help.py +++ b/core/src/main/python/model_help.py @@ -4,7 +4,7 @@ The entry point for the modelHelp tool. """ -import excpetions +import exceptions import os import sys From 3e418932fc6d74d04fa3da8669e9ad9a2e7ae803 Mon Sep 17 00:00:00 2001 From: Jim Gish Date: Tue, 19 Jul 2022 17:01:01 +0000 Subject: [PATCH 6/8] JIRA WDT-638 - catch java.lang.Exception instead of Throwable --- core/src/main/python/compare_model.py | 3 +-- core/src/main/python/create.py | 3 +-- core/src/main/python/deploy.py | 4 +--- core/src/main/python/discover.py | 3 +-- core/src/main/python/encrypt.py | 4 ++-- core/src/main/python/extract_resource.py | 3 +-- core/src/main/python/model_help.py | 4 +--- core/src/main/python/prepare_model.py | 4 +--- core/src/main/python/update.py | 4 +--- core/src/main/python/validate.py | 3 +-- core/src/main/python/variable_inject.py | 2 +- 11 files changed, 12 insertions(+), 25 deletions(-) diff --git a/core/src/main/python/compare_model.py b/core/src/main/python/compare_model.py index 85bc8f3be..645a7254d 100644 --- a/core/src/main/python/compare_model.py +++ b/core/src/main/python/compare_model.py @@ -22,7 +22,6 @@ import java.io.IOException as JIOException import java.io.PrintWriter as JPrintWriter from java.lang import System -from java.lang import Throwable from oracle.weblogic.deploy.compare import CompareException from oracle.weblogic.deploy.exception import ExceptionHelper from oracle.weblogic.deploy.util import CLAException @@ -352,5 +351,5 @@ def format_message(key, *args): if __name__ == "__main__": try: main() - except (exceptions.Exception, Throwable), ex: + except (exceptions.Exception, java.lang.Exception), ex: exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, _logger) diff --git a/core/src/main/python/create.py b/core/src/main/python/create.py index 84e837e29..8a5fba5ac 100644 --- a/core/src/main/python/create.py +++ b/core/src/main/python/create.py @@ -12,7 +12,6 @@ from java.lang import IllegalArgumentException from java.lang import String from java.lang import System -from java.lang import Throwable from oracle.weblogic.deploy.create import CreateException from oracle.weblogic.deploy.deploy import DeployException from oracle.weblogic.deploy.util import CLAException @@ -381,6 +380,6 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) - except (exceptions.Exception, Throwable), ex: + except (exceptions.Exception, java.lang.Exception), ex: exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/deploy.py b/core/src/main/python/deploy.py index 4cd84fd96..a2d1b1282 100644 --- a/core/src/main/python/deploy.py +++ b/core/src/main/python/deploy.py @@ -8,8 +8,6 @@ import os import sys -from java.lang import Throwable - from oracle.weblogic.deploy.deploy import DeployException from oracle.weblogic.deploy.exception import BundleAwareException from oracle.weblogic.deploy.util import CLAException @@ -264,5 +262,5 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) - except (exceptions.Exception, Throwable), ex: + except (exceptions.Exception, java.lang.Exception), ex: exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/discover.py b/core/src/main/python/discover.py index b0b9b3684..3e0f26208 100644 --- a/core/src/main/python/discover.py +++ b/core/src/main/python/discover.py @@ -12,7 +12,6 @@ from java.io import IOException from java.lang import IllegalArgumentException from java.lang import IllegalStateException -from java.lang import Throwable from oracle.weblogic.deploy.aliases import AliasException from oracle.weblogic.deploy.discover import DiscoverException from oracle.weblogic.deploy.json import JsonException @@ -643,6 +642,6 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) - except (exceptions.Exception, Throwable), ex: + except (exceptions.Exception, java.lang.Exception), ex: exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/encrypt.py b/core/src/main/python/encrypt.py index 710867167..d6e433a9a 100644 --- a/core/src/main/python/encrypt.py +++ b/core/src/main/python/encrypt.py @@ -8,7 +8,7 @@ import sys from java.io import IOException -from java.lang import String, System, Throwable +from java.lang import String, System from oracle.weblogic.deploy.encrypt import EncryptionException from oracle.weblogic.deploy.util import CLAException @@ -256,5 +256,5 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) - except (exceptions.Exception, Throwable), ex: + except (exceptions.Exception, java.lang.Exception), ex: exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/extract_resource.py b/core/src/main/python/extract_resource.py index a8de24451..da293f576 100644 --- a/core/src/main/python/extract_resource.py +++ b/core/src/main/python/extract_resource.py @@ -7,7 +7,6 @@ import exceptions import sys -from java.lang import Throwable from oracle.weblogic.deploy.deploy import DeployException from oracle.weblogic.deploy.util import CLAException from oracle.weblogic.deploy.util import WebLogicDeployToolingVersion @@ -162,5 +161,5 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) - except (exceptions.Exception, Throwable), ex: + except (exceptions.Exception, java.lang.Exception), ex: exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/model_help.py b/core/src/main/python/model_help.py index 9ef4700c6..31afefa31 100644 --- a/core/src/main/python/model_help.py +++ b/core/src/main/python/model_help.py @@ -8,8 +8,6 @@ import os import sys -from java.lang import Throwable - from oracle.weblogic.deploy.util import CLAException from oracle.weblogic.deploy.util import WebLogicDeployToolingVersion @@ -139,5 +137,5 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) - except (exceptions.Exception, Throwable), ex: + except (exceptions.Exception, java.lang.Exception), ex: exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/prepare_model.py b/core/src/main/python/prepare_model.py index 56e64f2e9..aba70a2fb 100644 --- a/core/src/main/python/prepare_model.py +++ b/core/src/main/python/prepare_model.py @@ -11,8 +11,6 @@ import sys import traceback -from java.lang import Throwable - from oracle.weblogic.deploy.util import CLAException from oracle.weblogic.deploy.util import PyWLSTException from oracle.weblogic.deploy.util import WebLogicDeployToolingVersion @@ -115,5 +113,5 @@ def main(): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main() - except (exceptions.Exception, Throwable), ex: + except (exceptions.Exception, java.lang.Exception), ex: exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/update.py b/core/src/main/python/update.py index 76dd47c5d..949080f0c 100644 --- a/core/src/main/python/update.py +++ b/core/src/main/python/update.py @@ -8,8 +8,6 @@ import os import sys -from java.lang import Throwable - from oracle.weblogic.deploy.deploy import DeployException from oracle.weblogic.deploy.exception import BundleAwareException from oracle.weblogic.deploy.util import CLAException @@ -314,5 +312,5 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) - except (exceptions.Exception, Throwable), ex: + except (exceptions.Exception, java.lang.Exception), ex: exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/validate.py b/core/src/main/python/validate.py index d59538362..d8128c3b9 100644 --- a/core/src/main/python/validate.py +++ b/core/src/main/python/validate.py @@ -9,7 +9,6 @@ import exceptions import sys -from java.lang import Throwable from java.util.logging import Level from oracle.weblogic.deploy.logging import WLSDeployLogEndHandler @@ -202,5 +201,5 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) - except (exceptions.Exception, Throwable), ex: + except (exceptions.Exception, java.lang.Exception), ex: exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/variable_inject.py b/core/src/main/python/variable_inject.py index 82aa11ed2..dbf78398c 100644 --- a/core/src/main/python/variable_inject.py +++ b/core/src/main/python/variable_inject.py @@ -207,5 +207,5 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) - except (exceptions.Exception, Throwable), ex: + except (exceptions.Exception, java.lang.Exception), ex: exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) From c095f195bb2cf26f57b8dc96227002c6581cdf99 Mon Sep 17 00:00:00 2001 From: Jim Gish Date: Tue, 19 Jul 2022 21:05:23 +0000 Subject: [PATCH 7/8] JIRA WDT-638 - handle sys.exit(). Ensure exception type is always printed/logged. --- core/src/main/python/compare_model.py | 2 ++ core/src/main/python/create.py | 3 ++- core/src/main/python/deploy.py | 2 ++ core/src/main/python/discover.py | 3 ++- core/src/main/python/encrypt.py | 2 ++ core/src/main/python/extract_resource.py | 2 ++ core/src/main/python/model_help.py | 2 ++ core/src/main/python/prepare_model.py | 2 ++ core/src/main/python/update.py | 2 ++ core/src/main/python/validate.py | 2 ++ core/src/main/python/variable_inject.py | 2 ++ core/src/main/python/wlsdeploy/exception/exception_helper.py | 2 +- .../oracle/weblogic/deploy/messages/wlsdeploy_rb.properties | 2 +- 13 files changed, 24 insertions(+), 4 deletions(-) diff --git a/core/src/main/python/compare_model.py b/core/src/main/python/compare_model.py index 645a7254d..ac0f1c6e6 100644 --- a/core/src/main/python/compare_model.py +++ b/core/src/main/python/compare_model.py @@ -351,5 +351,7 @@ def format_message(key, *args): if __name__ == "__main__": try: main() + except exceptions.SystemExit, ex: + raise ex except (exceptions.Exception, java.lang.Exception), ex: exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, _logger) diff --git a/core/src/main/python/create.py b/core/src/main/python/create.py index 8a5fba5ac..03561ef5b 100644 --- a/core/src/main/python/create.py +++ b/core/src/main/python/create.py @@ -380,6 +380,7 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) + except exceptions.SystemExit, ex: + raise ex except (exceptions.Exception, java.lang.Exception), ex: exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) - diff --git a/core/src/main/python/deploy.py b/core/src/main/python/deploy.py index a2d1b1282..770005f1c 100644 --- a/core/src/main/python/deploy.py +++ b/core/src/main/python/deploy.py @@ -262,5 +262,7 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) + except exceptions.SystemExit, ex: + raise ex except (exceptions.Exception, java.lang.Exception), ex: exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/discover.py b/core/src/main/python/discover.py index 3e0f26208..5845bac7f 100644 --- a/core/src/main/python/discover.py +++ b/core/src/main/python/discover.py @@ -642,6 +642,7 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) + except exceptions.SystemExit, ex: + raise ex except (exceptions.Exception, java.lang.Exception), ex: exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) - diff --git a/core/src/main/python/encrypt.py b/core/src/main/python/encrypt.py index d6e433a9a..3666f22d8 100644 --- a/core/src/main/python/encrypt.py +++ b/core/src/main/python/encrypt.py @@ -256,5 +256,7 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) + except exceptions.SystemExit, ex: + raise ex except (exceptions.Exception, java.lang.Exception), ex: exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/extract_resource.py b/core/src/main/python/extract_resource.py index da293f576..9df5cdd7e 100644 --- a/core/src/main/python/extract_resource.py +++ b/core/src/main/python/extract_resource.py @@ -161,5 +161,7 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) + except exceptions.SystemExit, ex: + raise ex except (exceptions.Exception, java.lang.Exception), ex: exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/model_help.py b/core/src/main/python/model_help.py index 31afefa31..2535b24f1 100644 --- a/core/src/main/python/model_help.py +++ b/core/src/main/python/model_help.py @@ -137,5 +137,7 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) + except exceptions.SystemExit, ex: + raise ex except (exceptions.Exception, java.lang.Exception), ex: exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/prepare_model.py b/core/src/main/python/prepare_model.py index aba70a2fb..e533495bb 100644 --- a/core/src/main/python/prepare_model.py +++ b/core/src/main/python/prepare_model.py @@ -113,5 +113,7 @@ def main(): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main() + except exceptions.SystemExit, ex: + raise ex except (exceptions.Exception, java.lang.Exception), ex: exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/update.py b/core/src/main/python/update.py index 949080f0c..f11a3d17b 100644 --- a/core/src/main/python/update.py +++ b/core/src/main/python/update.py @@ -312,5 +312,7 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) + except exceptions.SystemExit, ex: + raise ex except (exceptions.Exception, java.lang.Exception), ex: exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/validate.py b/core/src/main/python/validate.py index d8128c3b9..7503d648c 100644 --- a/core/src/main/python/validate.py +++ b/core/src/main/python/validate.py @@ -201,5 +201,7 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) + except exceptions.SystemExit, ex: + raise ex except (exceptions.Exception, java.lang.Exception), ex: exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/variable_inject.py b/core/src/main/python/variable_inject.py index dbf78398c..30d679e51 100644 --- a/core/src/main/python/variable_inject.py +++ b/core/src/main/python/variable_inject.py @@ -207,5 +207,7 @@ def main(args): WebLogicDeployToolingVersion.logVersionInfo(_program_name) try: main(sys.argv) + except exceptions.SystemExit, ex: + raise ex except (exceptions.Exception, java.lang.Exception), ex: exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/wlsdeploy/exception/exception_helper.py b/core/src/main/python/wlsdeploy/exception/exception_helper.py index 1c095d7ef..f648a2b06 100644 --- a/core/src/main/python/wlsdeploy/exception/exception_helper.py +++ b/core/src/main/python/wlsdeploy/exception/exception_helper.py @@ -485,7 +485,7 @@ def __handleUnexpectedException(ex, program_name, class_name, logger): :param class_name: the class where it occurred :param logger: the logger to use """ - logger.severe('WLSDPLY-20035', program_name, ex) + logger.severe('WLSDPLY-20035', program_name, sys.exc_info()[0]) if hasattr(ex, 'stackTrace'): # this works best for java exceptions, and gets the full stacktrace all the way back to weblogic.WLST diff --git a/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties b/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties index 5889bbfe4..8cfffbe3e 100644 --- a/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties +++ b/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties @@ -1671,7 +1671,7 @@ WLSDPLY-20031={0} specified Variable File {1} is not a valid file: {2} WLSDPLY-20032=No model specified and no model in archive, no validation performed WLSDPLY-20033=Applying filter with name "{0}" WLSDPLY-20034=Applying filter with ID "{0}" -WLSDPLY-20035={0} encountered an unexpected runtime exception. Please file an issue on GitHub and attach the log file and stdout. Error: {1} +WLSDPLY-20035={0} encountered an unexpected runtime exception. Please file an issue on GitHub and attach the log file and stdout. Exception: {1} WLSDPLY-20036={0} encountered an unexpected runtime exception. Stacktrace: {1} # Messages for internal filters From 214aa7d23b5f70fb055066d4f3b3af863e90164f Mon Sep 17 00:00:00 2001 From: Jim Gish Date: Tue, 19 Jul 2022 21:51:37 +0000 Subject: [PATCH 8/8] JIRA WDT-638 - out with the camel names, in with the snake names --- core/src/main/python/compare_model.py | 2 +- core/src/main/python/create.py | 2 +- core/src/main/python/deploy.py | 2 +- core/src/main/python/discover.py | 2 +- core/src/main/python/encrypt.py | 2 +- core/src/main/python/extract_resource.py | 2 +- core/src/main/python/model_help.py | 2 +- core/src/main/python/prepare_model.py | 2 +- core/src/main/python/update.py | 2 +- core/src/main/python/validate.py | 2 +- core/src/main/python/variable_inject.py | 2 +- core/src/main/python/wlsdeploy/exception/exception_helper.py | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/core/src/main/python/compare_model.py b/core/src/main/python/compare_model.py index ac0f1c6e6..d92c01a9c 100644 --- a/core/src/main/python/compare_model.py +++ b/core/src/main/python/compare_model.py @@ -354,4 +354,4 @@ def format_message(key, *args): except exceptions.SystemExit, ex: raise ex except (exceptions.Exception, java.lang.Exception), ex: - exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, _logger) + exception_helper.__handle_unexpected_exception(ex, _program_name, _class_name, _logger) diff --git a/core/src/main/python/create.py b/core/src/main/python/create.py index 03561ef5b..40871764a 100644 --- a/core/src/main/python/create.py +++ b/core/src/main/python/create.py @@ -383,4 +383,4 @@ def main(args): except exceptions.SystemExit, ex: raise ex except (exceptions.Exception, java.lang.Exception), ex: - exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) + exception_helper.__handle_unexpected_exception(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/deploy.py b/core/src/main/python/deploy.py index 770005f1c..169a3f3bb 100644 --- a/core/src/main/python/deploy.py +++ b/core/src/main/python/deploy.py @@ -265,4 +265,4 @@ def main(args): except exceptions.SystemExit, ex: raise ex except (exceptions.Exception, java.lang.Exception), ex: - exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) + exception_helper.__handle_unexpected_exception(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/discover.py b/core/src/main/python/discover.py index 5845bac7f..dbbef950d 100644 --- a/core/src/main/python/discover.py +++ b/core/src/main/python/discover.py @@ -645,4 +645,4 @@ def main(args): except exceptions.SystemExit, ex: raise ex except (exceptions.Exception, java.lang.Exception), ex: - exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) + exception_helper.__handle_unexpected_exception(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/encrypt.py b/core/src/main/python/encrypt.py index 3666f22d8..35545af2f 100644 --- a/core/src/main/python/encrypt.py +++ b/core/src/main/python/encrypt.py @@ -259,4 +259,4 @@ def main(args): except exceptions.SystemExit, ex: raise ex except (exceptions.Exception, java.lang.Exception), ex: - exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) + exception_helper.__handle_unexpected_exception(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/extract_resource.py b/core/src/main/python/extract_resource.py index 9df5cdd7e..0e62280e9 100644 --- a/core/src/main/python/extract_resource.py +++ b/core/src/main/python/extract_resource.py @@ -164,4 +164,4 @@ def main(args): except exceptions.SystemExit, ex: raise ex except (exceptions.Exception, java.lang.Exception), ex: - exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) + exception_helper.__handle_unexpected_exception(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/model_help.py b/core/src/main/python/model_help.py index 2535b24f1..610eea7cf 100644 --- a/core/src/main/python/model_help.py +++ b/core/src/main/python/model_help.py @@ -140,4 +140,4 @@ def main(args): except exceptions.SystemExit, ex: raise ex except (exceptions.Exception, java.lang.Exception), ex: - exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) + exception_helper.__handle_unexpected_exception(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/prepare_model.py b/core/src/main/python/prepare_model.py index e533495bb..e32abad68 100644 --- a/core/src/main/python/prepare_model.py +++ b/core/src/main/python/prepare_model.py @@ -116,4 +116,4 @@ def main(): except exceptions.SystemExit, ex: raise ex except (exceptions.Exception, java.lang.Exception), ex: - exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) + exception_helper.__handle_unexpected_exception(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/update.py b/core/src/main/python/update.py index f11a3d17b..2cb67676b 100644 --- a/core/src/main/python/update.py +++ b/core/src/main/python/update.py @@ -315,4 +315,4 @@ def main(args): except exceptions.SystemExit, ex: raise ex except (exceptions.Exception, java.lang.Exception), ex: - exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) + exception_helper.__handle_unexpected_exception(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/validate.py b/core/src/main/python/validate.py index 7503d648c..6495750fd 100644 --- a/core/src/main/python/validate.py +++ b/core/src/main/python/validate.py @@ -204,4 +204,4 @@ def main(args): except exceptions.SystemExit, ex: raise ex except (exceptions.Exception, java.lang.Exception), ex: - exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) + exception_helper.__handle_unexpected_exception(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/variable_inject.py b/core/src/main/python/variable_inject.py index 30d679e51..961d292af 100644 --- a/core/src/main/python/variable_inject.py +++ b/core/src/main/python/variable_inject.py @@ -210,4 +210,4 @@ def main(args): except exceptions.SystemExit, ex: raise ex except (exceptions.Exception, java.lang.Exception), ex: - exception_helper.__handleUnexpectedException(ex, _program_name, _class_name, __logger) + exception_helper.__handle_unexpected_exception(ex, _program_name, _class_name, __logger) diff --git a/core/src/main/python/wlsdeploy/exception/exception_helper.py b/core/src/main/python/wlsdeploy/exception/exception_helper.py index f648a2b06..a85a8bbc5 100644 --- a/core/src/main/python/wlsdeploy/exception/exception_helper.py +++ b/core/src/main/python/wlsdeploy/exception/exception_helper.py @@ -475,7 +475,7 @@ def __log_and_exit(logger, exit_code, class_name): logger.exiting(result=exit_code, class_name=class_name, method_name=None) tool_exit.end(None, exit_code) -def __handleUnexpectedException(ex, program_name, class_name, logger): +def __handle_unexpected_exception(ex, program_name, class_name, logger): """ Helper method to log and unexpected exception with exiting message and call sys.exit() Note that the user sees the 'Unexpected' message along with the exception, but no stack trace.