From 1ea2c6f2066c1a35a31cfad377b6fb30f7650bf0 Mon Sep 17 00:00:00 2001 From: Stoyan Gradev Date: Mon, 2 Feb 2026 14:48:15 +0200 Subject: [PATCH] Refactor resource configuration for TomEE migration: update paths and properties in YAML and XML files. --- scenarios/tomee/README.md | 17 ++++++++------- scenarios/tomee/cf/mtad.yaml | 4 +++- .../src/main/webapp/META-INF/persistence.xml | 2 +- .../cf/src/main/webapp/META-INF/resources.xml | 9 -------- .../config/resource_configuration.yml | 2 +- .../cf/src/main/webapp/WEB-INF/resources.xml | 9 ++++++++ .../tomee/integration-test/mtad-template.yaml | 4 ++-- scenarios/tomee/integration-test/run-test.sh | 21 ++++++++++++++++++- 8 files changed, 46 insertions(+), 22 deletions(-) delete mode 100644 scenarios/tomee/cf/src/main/webapp/META-INF/resources.xml create mode 100644 scenarios/tomee/cf/src/main/webapp/WEB-INF/resources.xml diff --git a/scenarios/tomee/README.md b/scenarios/tomee/README.md index bb61f50..d7a32d9 100644 --- a/scenarios/tomee/README.md +++ b/scenarios/tomee/README.md @@ -105,24 +105,27 @@ resources: 4. Create the file structure `webapp/META-INF/sap_java_buildpack/config/resource_configuration.yml` with the following content: ```yaml --- -tomee/webapps/ROOT/META-INF/context.xml: +tomee/webapps/ROOT/WEB-INF/resources.xml: service_name_for_DefaultDB: ``` -5. Under `webapp/META-INF`, create a `resources.xml` file: + +5. Under `webapp/WEB-INF`, create a `resources.xml` file: ```xml - - + type="javax.sql.DataSource"> + service=${service_name_for_DefaultDB} + ``` 6. Add the following line to the application module's properties in the `mtad.yaml` file. This is how the name of the service instance is passed to the application. ```yaml -JBP_CONFIG_RESOURCE_CONFIGURATION: [ "tomee/webapps/ROOT/META-INF/context.xml": { "service_name_for_DefaultDB": "" } ] +JBP_CONFIG_RESOURCE_CONFIGURATION: + - tomee/webapps/ROOT/WEB-INF/resources.xml: + service_name_for_DefaultDB: ``` ## Related Information - [TomEE-10 documentation| SAP Help Portal](https://help.sap.com/docs/btp/sap-business-technology-platform/tomee-10) diff --git a/scenarios/tomee/cf/mtad.yaml b/scenarios/tomee/cf/mtad.yaml index c417435..75f14b9 100644 --- a/scenarios/tomee/cf/mtad.yaml +++ b/scenarios/tomee/cf/mtad.yaml @@ -12,7 +12,9 @@ modules: properties: TARGET_RUNTIME: tomee ENABLE_SECURITY_JAVA_API_V2: true - JBP_CONFIG_RESOURCE_CONFIGURATION: [ "tomee/webapps/ROOT/META-INF/context.xml": { "service_name_for_DefaultDB": "persistence-javaee10-app-hana" } ] + JBP_CONFIG_RESOURCE_CONFIGURATION: + - tomee/webapps/ROOT/WEB-INF/resources.xml: + service_name_for_DefaultDB: persistence-javaee10-app-hana SET_LOGGING_LEVEL: 'ROOT: INFO' requires: - name: persistence-javaee10-app-hana diff --git a/scenarios/tomee/cf/src/main/webapp/META-INF/persistence.xml b/scenarios/tomee/cf/src/main/webapp/META-INF/persistence.xml index 9d2c533..9eae58e 100644 --- a/scenarios/tomee/cf/src/main/webapp/META-INF/persistence.xml +++ b/scenarios/tomee/cf/src/main/webapp/META-INF/persistence.xml @@ -6,7 +6,7 @@ jdbc/DefaultDB com.sap.cloud.sample.persistence.Person - + diff --git a/scenarios/tomee/cf/src/main/webapp/META-INF/resources.xml b/scenarios/tomee/cf/src/main/webapp/META-INF/resources.xml deleted file mode 100644 index 872a4dd..0000000 --- a/scenarios/tomee/cf/src/main/webapp/META-INF/resources.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - \ No newline at end of file diff --git a/scenarios/tomee/cf/src/main/webapp/META-INF/sap_java_buildpack/config/resource_configuration.yml b/scenarios/tomee/cf/src/main/webapp/META-INF/sap_java_buildpack/config/resource_configuration.yml index d739f3c..d665d4e 100644 --- a/scenarios/tomee/cf/src/main/webapp/META-INF/sap_java_buildpack/config/resource_configuration.yml +++ b/scenarios/tomee/cf/src/main/webapp/META-INF/sap_java_buildpack/config/resource_configuration.yml @@ -1,3 +1,3 @@ --- -tomee/webapps/ROOT/META-INF/context.xml: +tomee/webapps/ROOT/WEB-INF/resources.xml: service_name_for_DefaultDB: persistence-javaee10-app-hana \ No newline at end of file diff --git a/scenarios/tomee/cf/src/main/webapp/WEB-INF/resources.xml b/scenarios/tomee/cf/src/main/webapp/WEB-INF/resources.xml new file mode 100644 index 0000000..974bda1 --- /dev/null +++ b/scenarios/tomee/cf/src/main/webapp/WEB-INF/resources.xml @@ -0,0 +1,9 @@ + + + + + service=${service_name_for_DefaultDB} + + \ No newline at end of file diff --git a/scenarios/tomee/integration-test/mtad-template.yaml b/scenarios/tomee/integration-test/mtad-template.yaml index 33ca721..c2ae888 100644 --- a/scenarios/tomee/integration-test/mtad-template.yaml +++ b/scenarios/tomee/integration-test/mtad-template.yaml @@ -13,8 +13,8 @@ modules: TARGET_RUNTIME: tomee ENABLE_SECURITY_JAVA_API_V2: true JBP_CONFIG_RESOURCE_CONFIGURATION: - - tomee/webapps/ROOT/META-INF/context.xml: - service_name_for_DefaultDB: ${APP_NAME}-hana + - tomee/webapps/ROOT/WEB-INF/resources.xml: + service_name_for_DefaultDB: ${APP_NAME}-hana SET_LOGGING_LEVEL: 'ROOT: INFO' requires: - name: ${APP_NAME}-hana diff --git a/scenarios/tomee/integration-test/run-test.sh b/scenarios/tomee/integration-test/run-test.sh index 25fdd5b..98a6d1e 100755 --- a/scenarios/tomee/integration-test/run-test.sh +++ b/scenarios/tomee/integration-test/run-test.sh @@ -15,14 +15,33 @@ function execute_tests() { echo "Maven test execution completed" } +# Regression test: Verify TomEE is using HANA, not HSQLDB +# If the HSQLDB folder exists, it means TomEE is misconfigured +function check_no_hsqldb() { + echo "Checking that TomEE is NOT using HSQLDB..." + local result + result=$(cf ssh "${APP_NAME}" -c "ls -la /home/vcap/app/META-INF/.sap_java_buildpack/tomee/data/hsqldb/ 2>/dev/null || echo 'No HSQLDB folder!'") + + if [[ "${result}" == *"No HSQLDB folder!"* ]]; then + echo "SUCCESS: No HSQLDB folder - TomEE is correctly using HANA" + else + echo "ERROR: HSQLDB folder found! TomEE is using HSQLDB instead of HANA." + echo "Check that WEB-INF/resources.xml exists and JBP_CONFIG_RESOURCE_CONFIGURATION" + echo "points to tomee/webapps/ROOT/WEB-INF/resources.xml" + echo "Folder contents: ${result}" + return 1 + fi +} + function main(){ if [[ -n "${DEBUG}" && "${DEBUG}" == "true" ]]; then set -x fi - validate_env APP_URL + validate_env APP_URL APP_NAME execute_tests + check_no_hsqldb } main "${@}" \ No newline at end of file