From 20e6d5a7031123afa9b36ef3714d3ece2a67ac35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Tichov?= Date: Sun, 18 Dec 2022 12:37:48 +0100 Subject: [PATCH 01/36] Implement tomee.mp.jwt.allow.no-exp property over mp.jwt.tomee.allow.no-exp --- docs/microprofile/jwt.adoc | 3 +- .../jwt/itest/AllowNoExpPropertyTest.java | 253 ++++++++++++++++++ .../JWTAuthConfigurationProperties.java | 15 +- 3 files changed, 268 insertions(+), 3 deletions(-) create mode 100644 itests/microprofile-jwt-itests/src/test/java/org/apache/tomee/microprofile/jwt/itest/AllowNoExpPropertyTest.java diff --git a/docs/microprofile/jwt.adoc b/docs/microprofile/jwt.adoc index 270be03e6ed..d1b2e948e00 100644 --- a/docs/microprofile/jwt.adoc +++ b/docs/microprofile/jwt.adoc @@ -81,7 +81,8 @@ In addition to the standard MicroProfile JWT configuration properties above, the | Property | Type | Description -| `mp.jwt.tomee.allow.no-exp` +| `mp.jwt.tomee.allow.no-exp` is deprecated please use `tomee.mp.jwt.allow.no-exp` property instead +| `tomee.mp.jwt.allow.no-exp` | Boolean | Disables enforcing the `exp` time of the JWT. Useful if JWTs are also verified by an API Gateway or proxy before reaching the server. The default value is `false` | `tomee.jwt.verify.publickey.cache` diff --git a/itests/microprofile-jwt-itests/src/test/java/org/apache/tomee/microprofile/jwt/itest/AllowNoExpPropertyTest.java b/itests/microprofile-jwt-itests/src/test/java/org/apache/tomee/microprofile/jwt/itest/AllowNoExpPropertyTest.java new file mode 100644 index 00000000000..467cc17a6de --- /dev/null +++ b/itests/microprofile-jwt-itests/src/test/java/org/apache/tomee/microprofile/jwt/itest/AllowNoExpPropertyTest.java @@ -0,0 +1,253 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.tomee.microprofile.jwt.itest; + +import jakarta.annotation.security.RolesAllowed; +import jakarta.enterprise.context.RequestScoped; +import jakarta.ws.rs.ApplicationPath; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.Application; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import java.io.File; +import java.net.URL; +import java.util.ArrayList; +import java.util.Base64; +import static java.util.Collections.singletonList; +import java.util.Optional; +import org.apache.cxf.feature.LoggingFeature; +import org.apache.cxf.jaxrs.client.WebClient; +import org.apache.johnzon.jaxrs.JohnzonProvider; +import org.apache.tomee.server.composer.Archive; +import org.apache.tomee.server.composer.TomEE; +import org.eclipse.microprofile.auth.LoginConfig; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import org.junit.Test; + + +public class AllowNoExpPropertyTest { + + @Test + public void testNewPropertyOverridesOld1() throws Exception { + final Tokens tokens = Tokens.rsa(2048, 256); + final File appJar = Archive.archive() + .add(AllowNoExpPropertyTest.class) + .add(ColorService.class) + .add(Api.class) + .add("META-INF/microprofile-config.properties", "#\n" + + "mp.jwt.verify.publickey=" + Base64.getEncoder().encodeToString(tokens.getPublicKey().getEncoded()) + + "\n" + "mp.jwt.tomee.allow.no-exp=false" + + "\n" + "tomee.mp.jwt.allow.no-exp=true") + .asJar(); + + final ArrayList output = new ArrayList<>(); + final TomEE tomee = TomEE.microprofile() + .add("webapps/test/WEB-INF/beans.xml", "") + .add("webapps/test/WEB-INF/lib/app.jar", appJar) + .watch("org.apache.tomee.microprofile.jwt.", "\n", output::add) + .build(); + + final WebClient webClient = createWebClient(tomee.toURI().resolve("/test").toURL()); + + final String claims = "{" + + " \"sub\":\"Jane Awesome\"" + + "}"; + + {// invalid token + final String token = tokens.asToken(claims); + final Response response = webClient.reset() + .path("/movies") + .header("Content-Type", "application/json") + .header("Authorization", "Bearer " + token) + .get(); + assertEquals(403, response.getStatus()); + } + + assertPresent(output , "mp.jwt.tomee.allow.no-exp property is deprecated"); + assertNotPresent(output, "rejected due to invalid claims"); + assertNotPresent(output, "No Expiration Time (exp) claim present."); + assertNotPresent(output, "\tat org."); // no stack traces + } + + @Test + public void testNewPropertyOverridesOld2() throws Exception { + final Tokens tokens = Tokens.rsa(2048, 256); + final File appJar = Archive.archive() + .add(AllowNoExpPropertyTest.class) + .add(ColorService.class) + .add(Api.class) + .add("META-INF/microprofile-config.properties", "#\n" + + "mp.jwt.verify.publickey=" + Base64.getEncoder().encodeToString(tokens.getPublicKey().getEncoded()) + + "\n" + "mp.jwt.tomee.allow.no-exp=true" + + "\n" + "tomee.mp.jwt.allow.no-exp=false") + .asJar(); + + final ArrayList output = new ArrayList<>(); + final TomEE tomee = TomEE.microprofile() + .add("webapps/test/WEB-INF/beans.xml", "") + .add("webapps/test/WEB-INF/lib/app.jar", appJar) + .watch("org.apache.tomee.microprofile.jwt.", "\n", output::add) + .build(); + + final WebClient webClient = createWebClient(tomee.toURI().resolve("/test").toURL()); + + final String claims = "{" + + " \"sub\":\"Jane Awesome\"" + + "}"; + + {// invalid token + final String token = tokens.asToken(claims); + final Response response = webClient.reset() + .path("/movies") + .header("Content-Type", "application/json") + .header("Authorization", "Bearer " + token) + .get(); + assertEquals(401, response.getStatus()); + } + + assertPresent(output , "mp.jwt.tomee.allow.no-exp property is deprecated"); + assertPresent(output, "rejected due to invalid claims"); + assertPresent(output, "No Expiration Time (exp) claim present."); + assertNotPresent(output, "\tat org."); // no stack traces + } + + @Test + public void testNewProperty() throws Exception { + final Tokens tokens = Tokens.rsa(2048, 256); + final File appJar = Archive.archive() + .add(AllowNoExpPropertyTest.class) + .add(ColorService.class) + .add(Api.class) + .add("META-INF/microprofile-config.properties", "#\n" + + "mp.jwt.verify.publickey=" + Base64.getEncoder().encodeToString(tokens.getPublicKey().getEncoded()) + + "\n" + "tomee.mp.jwt.allow.no-exp=true") + .asJar(); + + final ArrayList output = new ArrayList<>(); + final TomEE tomee = TomEE.microprofile() + .add("webapps/test/WEB-INF/beans.xml", "") + .add("webapps/test/WEB-INF/lib/app.jar", appJar) + .watch("org.apache.tomee.microprofile.jwt.", "\n", output::add) + .build(); + + final WebClient webClient = createWebClient(tomee.toURI().resolve("/test").toURL()); + + final String claims = "{" + + " \"sub\":\"Jane Awesome\"" + + "}"; + + {// invalid token + final String token = tokens.asToken(claims); + final Response response = webClient.reset() + .path("/movies") + .header("Content-Type", "application/json") + .header("Authorization", "Bearer " + token) + .get(); + assertEquals(403, response.getStatus()); + } + + assertNotPresent(output , "mp.jwt.tomee.allow.no-exp property is deprecated"); + assertNotPresent(output, "rejected due to invalid claims"); + assertNotPresent(output, "No Expiration Time (exp) claim present."); + assertNotPresent(output, "\tat org."); // no stack traces + } + + @Test + public void testOldProperty() throws Exception { + final Tokens tokens = Tokens.rsa(2048, 256); + final File appJar = Archive.archive() + .add(AllowNoExpPropertyTest.class) + .add(ColorService.class) + .add(Api.class) + .add("META-INF/microprofile-config.properties", "#\n" + + "mp.jwt.verify.publickey=" + Base64.getEncoder().encodeToString(tokens.getPublicKey().getEncoded()) + + "\n" + "mp.jwt.tomee.allow.no-exp=true") + .asJar(); + + final ArrayList output = new ArrayList<>(); + final TomEE tomee = TomEE.microprofile() + .add("webapps/test/WEB-INF/beans.xml", "") + .add("webapps/test/WEB-INF/lib/app.jar", appJar) + .watch("org.apache.tomee.microprofile.jwt.", "\n", output::add) + .build(); + + final WebClient webClient = createWebClient(tomee.toURI().resolve("/test").toURL()); + + final String claims = "{" + + " \"sub\":\"Jane Awesome\"" + + "}"; + + {// invalid token + final String token = tokens.asToken(claims); + final Response response = webClient.reset() + .path("/movies") + .header("Content-Type", "application/json") + .header("Authorization", "Bearer " + token) + .get(); + assertEquals(403, response.getStatus()); + } + + assertPresent(output , "mp.jwt.tomee.allow.no-exp property is deprecated"); + assertNotPresent(output, "rejected due to invalid claims"); + assertNotPresent(output, "No Expiration Time (exp) claim present."); + assertNotPresent(output, "\tat org."); // no stack traces + } + + public void assertPresent(final ArrayList output, final String s) { + final Optional actual = output.stream() + .filter(line -> line.contains(s)) + .findFirst(); + + assertTrue(actual.isPresent()); + } + public void assertNotPresent(final ArrayList output, final String s) { + final Optional actual = output.stream() + .filter(line -> line.contains(s)) + .findFirst(); + + assertTrue(!actual.isPresent()); + } + + private static WebClient createWebClient(final URL base) { + return WebClient.create(base.toExternalForm(), singletonList(new JohnzonProvider<>()), + singletonList(new LoggingFeature()), null); + } + + @ApplicationPath("/api") + @LoginConfig(authMethod = "MP-JWT") + public class Api extends Application { + } + + @Path("/movies") + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + @RequestScoped + public static class ColorService { + + @GET + @RolesAllowed({"manager", "user"}) + public String getAllMovies() { + return "Green"; + } + } + +} diff --git a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/JWTAuthConfigurationProperties.java b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/JWTAuthConfigurationProperties.java index e2f4823eefb..65fac639957 100644 --- a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/JWTAuthConfigurationProperties.java +++ b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/JWTAuthConfigurationProperties.java @@ -38,6 +38,7 @@ import java.util.Map; import java.util.Optional; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Supplier; import static org.eclipse.microprofile.jwt.config.Names.AUDIENCES; @@ -59,6 +60,7 @@ public class JWTAuthConfigurationProperties { public static final String PUBLIC_KEY_ERROR = "Could not read MicroProfile Public Key"; public static final String PUBLIC_KEY_ERROR_LOCATION = PUBLIC_KEY_ERROR + " from Location: "; + private static final Logger CONFIGURATION = Logger.getInstance(JWTLogCategories.CONFIG, JWTAuthConfigurationProperties.class); private Config config; private JWTAuthConfiguration jwtAuthConfiguration; @@ -104,8 +106,8 @@ private JWTAuthConfiguration createJWTAuthConfiguration() { final Supplier> publicKeys = Keys.VERIFY.configure(config); final Supplier> decryptKeys = Keys.DECRYPT.configure(config); - final Boolean allowNoExp = config.getOptionalValue("mp.jwt.tomee.allow.no-exp", Boolean.class).orElse(false); - + final Boolean allowNoExp = queryAllowExp(); + return new JWTAuthConfiguration( publicKeys, getIssuer().orElse(null), @@ -117,6 +119,15 @@ private JWTAuthConfiguration createJWTAuthConfiguration() { config.getOptionalValue("mp.jwt.decrypt.key.algorithm", String.class).orElse(null), config.getOptionalValue("mp.jwt.verify.publickey.algorithm", String.class).orElse(null)); } + + private Boolean queryAllowExp(){ + AtomicBoolean result = new AtomicBoolean(false); + config.getOptionalValue("mp.jwt.tomee.allow.no-exp", Boolean.class).ifPresent(value -> { + result.set(value); + CONFIGURATION.warning("mp.jwt.tomee.allow.no-exp property is deprecated, use tomee.mp.jwt.allow.no-exp propert instead."); + }); + return config.getOptionalValue("tomee.mp.jwt.allow.no-exp", Boolean.class).orElse(result.get()); + } enum Keys { VERIFY("mp.jwt.verify.publickey", "tomee.jwt.verify.publickey"), From 32c659e4ffd146c354ce77316f0d8ba12de32cf7 Mon Sep 17 00:00:00 2001 From: Jean-Louis Monteiro Date: Fri, 6 Jan 2023 12:24:17 +0100 Subject: [PATCH 02/36] TOMEE-4158 Setup BVal 3.0.1 TCK for Jakarta EE 10 --- tck/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tck/pom.xml b/tck/pom.xml index 5b1c2fc3870..52573b5aef7 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -29,7 +29,7 @@ 3.0.3 - 3.0.0 + 3.0.1 org.apache.bval.jsr.ApacheValidationProvider From 81080e83e2a5d36bf6c0c86e7494f8705605fd98 Mon Sep 17 00:00:00 2001 From: Jean-Louis Monteiro Date: Tue, 10 Jan 2023 12:38:51 +0100 Subject: [PATCH 03/36] TOMEE-4164 JSON-B TCK --- tck/jsonb-signature-test/pom.xml | 164 ++++++++++++++++++++++++++++++ tck/jsonb-standalone/pom.xml | 167 +++++++++++++++++++++++++++++++ tck/pom.xml | 2 + 3 files changed, 333 insertions(+) create mode 100644 tck/jsonb-signature-test/pom.xml create mode 100644 tck/jsonb-standalone/pom.xml diff --git a/tck/jsonb-signature-test/pom.xml b/tck/jsonb-signature-test/pom.xml new file mode 100644 index 00000000000..447cc11695c --- /dev/null +++ b/tck/jsonb-signature-test/pom.xml @@ -0,0 +1,164 @@ + + + + + tck + org.apache.tomee + 10.0.0-SNAPSHOT + + + 4.0.0 + jsonb-signature-test + TomEE :: TCK :: JSON-B Signature Tests + + + + org.apache.johnzon + johnzon-core + jakarta + + + org.apache.johnzon + * + + + org.apache.geronimo.specs + * + + + + + org.apache.johnzon + johnzon-mapper + jakarta + + + org.apache.johnzon + * + + + org.apache.geronimo.specs + * + + + + + org.apache.johnzon + johnzon-jsonb + jakarta + + + org.apache.johnzon + * + + + org.apache.geronimo.specs + * + + + + + + org.apache.tomee + jakartaee-api + + + + jakarta.json.bind + jakarta.json.bind-tck + 3.0.0 + test + + + + org.apache.openwebbeans + openwebbeans-se + 2.0.27 + jakarta + + + org.apache.openwebbeans + * + + + org.apache.geronimo.specs + * + + + + + org.apache.openwebbeans + openwebbeans-impl + 2.0.27 + jakarta + + + org.apache.openwebbeans + * + + + org.apache.geronimo.specs + * + + + + + org.apache.openwebbeans + openwebbeans-spi + 2.0.27 + jakarta + + + org.apache.openwebbeans + * + + + org.apache.geronimo.specs + * + + + + + + + + + src/test/resources + true + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${surefire.version} + + false + 1 + + jakarta.json.bind:jakarta.json.bind-tck + + + **/JSONBSigTest + + + + + + + \ No newline at end of file diff --git a/tck/jsonb-standalone/pom.xml b/tck/jsonb-standalone/pom.xml new file mode 100644 index 00000000000..418a7f4e5a4 --- /dev/null +++ b/tck/jsonb-standalone/pom.xml @@ -0,0 +1,167 @@ + + + + + tck + org.apache.tomee + 10.0.0-SNAPSHOT + + + 4.0.0 + jsonb-standalone + TomEE :: TCK :: JSON-B Standalone + + + + org.apache.johnzon + johnzon-core + jakarta + + + org.apache.johnzon + * + + + org.apache.geronimo.specs + * + + + + + org.apache.johnzon + johnzon-mapper + jakarta + + + org.apache.johnzon + * + + + org.apache.geronimo.specs + * + + + + + org.apache.johnzon + johnzon-jsonb + jakarta + + + org.apache.johnzon + * + + + org.apache.geronimo.specs + * + + + + + + org.apache.tomee + jakartaee-api + + + + jakarta.json.bind + jakarta.json.bind-tck + 3.0.0 + test + + + + org.apache.openwebbeans + openwebbeans-se + 2.0.27 + jakarta + + + org.apache.openwebbeans + * + + + org.apache.geronimo.specs + * + + + + + org.apache.openwebbeans + openwebbeans-impl + 2.0.27 + jakarta + + + org.apache.openwebbeans + * + + + org.apache.geronimo.specs + * + + + + + org.apache.openwebbeans + openwebbeans-spi + 2.0.27 + jakarta + + + org.apache.openwebbeans + * + + + org.apache.geronimo.specs + * + + + + + + + + + src/test/resources + true + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${surefire.version} + + false + 1 + + jakarta.json.bind:jakarta.json.bind-tck + + + ee.jakarta.tck.json.bind.** + + + **/JSONBSigTest + + + + + + + \ No newline at end of file diff --git a/tck/pom.xml b/tck/pom.xml index 5b1c2fc3870..3bba6d45c31 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -41,6 +41,8 @@ bval-embedded bval-tomee bval-signature-test + jsonb-standalone + jsonb-signature-test microprofile-tck From 7769a55a25a5a03986f2948537bfc207508c6a5f Mon Sep 17 00:00:00 2001 From: Jean-Louis Monteiro Date: Tue, 10 Jan 2023 13:10:37 +0100 Subject: [PATCH 04/36] TOMEE-4165 JSON-P TCK --- tck/jsonp-signature-test/pom.xml | 119 ++++++++++++++++++++++ tck/jsonp-standalone/pom.xml | 167 +++++++++++++++++++++++++++++++ tck/pom.xml | 2 + 3 files changed, 288 insertions(+) create mode 100644 tck/jsonp-signature-test/pom.xml create mode 100644 tck/jsonp-standalone/pom.xml diff --git a/tck/jsonp-signature-test/pom.xml b/tck/jsonp-signature-test/pom.xml new file mode 100644 index 00000000000..96befc4d8cb --- /dev/null +++ b/tck/jsonp-signature-test/pom.xml @@ -0,0 +1,119 @@ + + + + + tck + org.apache.tomee + 10.0.0-SNAPSHOT + + + 4.0.0 + jsonp-signature-test + TomEE :: TCK :: JSON-P Signature Tests + + + + + org.apache.tomee + jakartaee-api + + + + jakarta.json + jakarta.json-tck-tests + 2.1.1 + test + + + + org.apache.openwebbeans + openwebbeans-se + 2.0.27 + jakarta + + + org.apache.openwebbeans + * + + + org.apache.geronimo.specs + * + + + + + org.apache.openwebbeans + openwebbeans-impl + 2.0.27 + jakarta + + + org.apache.openwebbeans + * + + + org.apache.geronimo.specs + * + + + + + org.apache.openwebbeans + openwebbeans-spi + 2.0.27 + jakarta + + + org.apache.openwebbeans + * + + + org.apache.geronimo.specs + * + + + + + + + + + src/test/resources + true + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${surefire.version} + + false + 1 + + jakarta.json:jakarta.json-tck-tests + + + **/JSONPSigTest + + + + + + + \ No newline at end of file diff --git a/tck/jsonp-standalone/pom.xml b/tck/jsonp-standalone/pom.xml new file mode 100644 index 00000000000..ebdf7e97b89 --- /dev/null +++ b/tck/jsonp-standalone/pom.xml @@ -0,0 +1,167 @@ + + + + + tck + org.apache.tomee + 10.0.0-SNAPSHOT + + + 4.0.0 + jsonp-standalone + TomEE :: TCK :: JSON-P Standalone + + + + org.apache.johnzon + johnzon-core + jakarta + + + org.apache.johnzon + * + + + org.apache.geronimo.specs + * + + + + + org.apache.johnzon + johnzon-mapper + jakarta + + + org.apache.johnzon + * + + + org.apache.geronimo.specs + * + + + + + org.apache.johnzon + johnzon-jsonp-strict + jakarta + + + org.apache.johnzon + * + + + org.apache.geronimo.specs + * + + + + + + org.apache.tomee + jakartaee-api + + + + jakarta.json + jakarta.json-tck-tests + 2.1.1 + test + + + + org.apache.openwebbeans + openwebbeans-se + 2.0.27 + jakarta + + + org.apache.openwebbeans + * + + + org.apache.geronimo.specs + * + + + + + org.apache.openwebbeans + openwebbeans-impl + 2.0.27 + jakarta + + + org.apache.openwebbeans + * + + + org.apache.geronimo.specs + * + + + + + org.apache.openwebbeans + openwebbeans-spi + 2.0.27 + jakarta + + + org.apache.openwebbeans + * + + + org.apache.geronimo.specs + * + + + + + + + + + src/test/resources + true + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${surefire.version} + + false + 1 + + jakarta.json:jakarta.json-tck-tests + + + ee.jakarta.tck.jsonp.** + + + **/JSONPSigTest + + + + + + + \ No newline at end of file diff --git a/tck/pom.xml b/tck/pom.xml index 5b1c2fc3870..f6cac472c78 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -41,6 +41,8 @@ bval-embedded bval-tomee bval-signature-test + jsonp-standalone + jsonp-signature-test microprofile-tck From 945aa1368c7b47ea58f2433d62286b1cdca213c9 Mon Sep 17 00:00:00 2001 From: Jean-Louis Monteiro Date: Tue, 10 Jan 2023 13:14:38 +0100 Subject: [PATCH 05/36] TOMEE-4165 Add pluggability tests --- tck/jsonp-standalone/pom.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tck/jsonp-standalone/pom.xml b/tck/jsonp-standalone/pom.xml index ebdf7e97b89..0046700030a 100644 --- a/tck/jsonp-standalone/pom.xml +++ b/tck/jsonp-standalone/pom.xml @@ -84,6 +84,12 @@ 2.1.1 test + + jakarta.json + jakarta.json-tck-tests-pluggability + 2.1.1 + test + org.apache.openwebbeans @@ -152,6 +158,7 @@ 1 jakarta.json:jakarta.json-tck-tests + jakarta.json:jakarta.json-tck-tests-pluggability ee.jakarta.tck.jsonp.** From b76ed515097157bf2157f52c2bcee3d38cfc90b7 Mon Sep 17 00:00:00 2001 From: Jean-Louis Monteiro Date: Mon, 20 Nov 2023 10:03:04 +0100 Subject: [PATCH 06/36] feat(#TOMEE-4281): Better logging we can't load an application class --- .../openejb/config/AnnotationDeployer.java | 93 ++++++++++++------- .../openejb/config/rules/Messages.properties | 8 +- .../config/rules/Messages_hi.properties | 8 +- 3 files changed, 70 insertions(+), 39 deletions(-) diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java b/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java index aa00627d270..1f5beda408c 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java @@ -2059,8 +2059,12 @@ public ClientModule deploy(final ClientModule clientModule) throws OpenEJBExcept final AnnotationFinder annotationFinder = createFinder(clazz); buildAnnotatedRefs(client, annotationFinder, classLoader); - } catch (final ClassNotFoundException e) { - /** + } catch (final ClassNotFoundException | NoClassDefFoundError e) { + + logger.debug("Could not load main class {1} for client module {2} / {3}", + className, clientModule.getJarLocation(), clientModule.getFile().getName()); + + /* * Some ClientModule are discovered only because the jar uses a Main-Class * entry in the MANIFEST.MF file. Lots of jars do this that are not used as * java ee application clients, so lets not make this a failure unless it @@ -2081,7 +2085,10 @@ public ClientModule deploy(final ClientModule clientModule) throws OpenEJBExcept try { clazz = classLoader.loadClass(className); remoteClients.add(clazz); - } catch (final ClassNotFoundException e) { + } catch (final ClassNotFoundException | NoClassDefFoundError e) { + logger.debug("Could not load RemoteClient class {1} for client module {2} / {3}", + className, clientModule.getJarLocation(), clientModule.getFile().getName()); + throw new OpenEJBException("Unable to load RemoteClient class: " + className, e); } @@ -2095,7 +2102,9 @@ public ClientModule deploy(final ClientModule clientModule) throws OpenEJBExcept final Class clazz; try { clazz = classLoader.loadClass(className); - } catch (final ClassNotFoundException e) { + } catch (final ClassNotFoundException | NoClassDefFoundError e) { + logger.debug("Could not load LocalClient class {1} for client module {2} / {3}", + className, clientModule.getJarLocation(), clientModule.getFile().getName()); throw new OpenEJBException("Unable to load LocalClient class: " + className, e); } @@ -2224,7 +2233,9 @@ public WebModule deploy(final WebModule webModule) throws OpenEJBException { try { clazz = classLoader.loadClass(application); classes.add(clazz); - } catch (final ClassNotFoundException e) { + } catch (final ClassNotFoundException | NoClassDefFoundError e) { + logger.debug("Could not load rest Application class {1} for module {2} / {3}", + application, webModule.getJarLocation(), webModule.getFile().getName()); throw new OpenEJBException("Unable to load Application class: " + application, e); } if (Modifier.isAbstract(clazz.getModifiers())) { @@ -2296,7 +2307,9 @@ public WebModule deploy(final WebModule webModule) throws OpenEJBException { if (servlet.getServletClass() == null) { servlet.setServletClass(servletClass); } - } catch (final ClassNotFoundException e) { + } catch (final ClassNotFoundException | NoClassDefFoundError e) { + logger.debug("Could not load Servlet class {1} for web module {2} / {3}", + servletClass, webModule.getJarLocation(), webModule.getFile().getName()); if (servlet.getServletClass() != null) { throw new OpenEJBException("Unable to load servlet class: " + servletClass, e); } else { @@ -2325,7 +2338,9 @@ public WebModule deploy(final WebModule webModule) throws OpenEJBException { try { final Class clazz = classLoader.loadClass(filterClass); classes.add(clazz); - } catch (final ClassNotFoundException e) { + } catch (final ClassNotFoundException | NoClassDefFoundError e) { + logger.debug("Could not load Servlet Filter class {1} for web module {2} / {3}", + filterClass, webModule.getJarLocation(), webModule.getFile().getName()); throw new OpenEJBException("Unable to load servlet filter class: " + filterClass, e); } } @@ -2340,7 +2355,9 @@ public WebModule deploy(final WebModule webModule) throws OpenEJBException { try { final Class clazz = classLoader.loadClass(listenerClass); classes.add(clazz); - } catch (final ClassNotFoundException e) { + } catch (final ClassNotFoundException | NoClassDefFoundError e) { + logger.debug("Could not load Servlet listener class {1} for web module {2} / {3}", + listenerClass, webModule.getJarLocation(), webModule.getFile().getName()); throw new OpenEJBException("Unable to load servlet listener class: " + listenerClass, e); } } @@ -2356,7 +2373,9 @@ public WebModule deploy(final WebModule webModule) throws OpenEJBException { try { final Class clazz = classLoader.loadClass(listenerClass); classes.add(clazz); - } catch (final ClassNotFoundException e) { + } catch (final ClassNotFoundException | NoClassDefFoundError e) { + logger.debug("Could not load TagLib listener class {1} for web module {2} / {3}", + listenerClass, webModule.getJarLocation(), webModule.getFile().getName()); logger.error("Unable to load tag library servlet listener class: " + listenerClass); } } @@ -2371,7 +2390,9 @@ public WebModule deploy(final WebModule webModule) throws OpenEJBException { try { final Class clazz = classLoader.loadClass(tagClass); classes.add(clazz); - } catch (final ClassNotFoundException e) { + } catch (final ClassNotFoundException | NoClassDefFoundError e) { + logger.debug("Could not load tag class {1} for web module {2} / {3}", + tagClass, webModule.getJarLocation(), webModule.getFile().getName()); logger.error("Unable to load tag library tag class: " + tagClass); } } @@ -2399,7 +2420,9 @@ public WebModule deploy(final WebModule webModule) throws OpenEJBException { try { final Class clazz = classLoader.loadClass(handlerClass); classes.add(clazz); - } catch (final ClassNotFoundException e) { + } catch (final ClassNotFoundException | NoClassDefFoundError e) { + logger.debug("Could not load web service handler class {1} for web module {2} / {3}", + handlerClass, webModule.getJarLocation(), webModule.getFile().getName()); throw new OpenEJBException("Unable to load webservice handler class: " + handlerClass, e); } } @@ -2419,7 +2442,9 @@ public WebModule deploy(final WebModule webModule) throws OpenEJBException { try { final Class clazz = classLoader.loadClass(managedBeanClass); classes.add(clazz); - } catch (final ClassNotFoundException e) { + } catch (final ClassNotFoundException | NoClassDefFoundError e) { + logger.debug("Could not load Faces managed bean class {1} for web module {2} / {3}", + managedBeanClass, webModule.getJarLocation(), webModule.getFile().getName()); logger.error("Unable to load JSF managed bean class: " + managedBeanClass); } } @@ -2969,6 +2994,9 @@ public EjbModule deploy(final EjbModule ejbModule) throws OpenEJBException { try { clazz = classLoader.loadClass(realClassName(interceptor.getInterceptorClass())); } catch (final ClassNotFoundException e) { + logger.debug("Could not load interceptor class {1} for enterprise beans module {2} / {3}", + interceptor.getInterceptorClass(), ejbModule.getJarLocation(), ejbModule.getFile().getName()); + throw new OpenEJBException("Unable to load interceptor class: " + interceptor.getInterceptorClass(), e); } @@ -3012,7 +3040,7 @@ public EjbModule deploy(final EjbModule ejbModule) throws OpenEJBException { processWebServiceClientHandlers(interceptor, annotationFinder, classLoader); - /** + /* * Interceptors do not have their own section in ejb-jar.xml for resource references * so we add them to the references of each ejb. A bit backwards but more or less * mandated by the design of the spec. @@ -3116,7 +3144,7 @@ private void processSessionInterfaces(final SessionBean sessionBean, final Class sessionBean.setLocalBean(new Empty()); } - /** + /* * Anything declared as both and is invalid in strict mode */ if (strict) { @@ -3127,7 +3155,7 @@ private void processSessionInterfaces(final SessionBean sessionBean, final Class } } - /** + /* * Merge the xml declared business interfaces into the complete set */ final BusinessInterfaces all = new BusinessInterfaces(); @@ -3195,15 +3223,15 @@ private void processSessionInterfaces(final SessionBean sessionBean, final Class } } - /** - * Anything discovered and delcared in a previous loop + /* + * Anything discovered and declared in a previous loop * or at the beginning in the deployment descriptor is - * not eligable to be redefined. + * not eligible to be redefined. */ interfaces.removeAll(all.local); interfaces.removeAll(all.remote); - /** + /* * OK, now start checking the class metadata */ final Local local = clazz.getAnnotation(Local.class); @@ -3212,7 +3240,7 @@ private void processSessionInterfaces(final SessionBean sessionBean, final Class final boolean impliedLocal = local != null && local.value().length == 0; final boolean impliedRemote = remote != null && remote.value().length == 0; - /** + /* * This set holds the values of @Local and @Remote * when applied to the bean class itself * @@ -3235,7 +3263,7 @@ private void processSessionInterfaces(final SessionBean sessionBean, final Class } } - /** + /* * Anything listed explicitly via @Local or @Remote * on the bean class does not need to be investigated. * We do not need to check these interfaces for @Local or @Remote @@ -3245,7 +3273,7 @@ private void processSessionInterfaces(final SessionBean sessionBean, final Class if (impliedLocal || impliedRemote) { if (interfaces.size() != 1) { - /** + /* * Cannot imply either @Local or @Remote and list multiple interfaces */ // Need to extract the class names and append .class to them to show proper validation level 3 message @@ -3261,21 +3289,21 @@ private void processSessionInterfaces(final SessionBean sessionBean, final Class // we don't go out to let be deployed } else if (impliedLocal) { validation.fail(ejbName, "ann.local.noAttributes", Join.join(", ", interfaceNames)); - /** + /* * This bean is invalid, so do not bother looking at the other interfaces or the superclass */ return; } if (impliedRemote) { validation.fail(ejbName, "ann.remote.noAttributes", Join.join(", ", interfaceNames)); - /** + /* * This bean is invalid, so do not bother looking at the other interfaces or the superclass */ return; } } else if (strict && impliedLocal && impliedRemote) { final Class interfce = interfaces.remove(0); - /** + /* * Cannot imply @Local and @Remote at the same time with strict mode on */ validation.fail(ejbName, "ann.localRemote.ambiguous", interfce.getName()); @@ -4120,7 +4148,7 @@ private void buildEjbRef(final JndiConsumer consumer, final EJB ejb, final Membe // TODO: Looks like we aren't looking for an existing ejb-ref or ejb-local-ref // we need to do this to support overriding. - /** + /* * Was @EJB used at a class level witout specifying the 'name' or 'beanInterface' attributes? */ final String name = consumer.getJndiConsumerName(); @@ -4342,7 +4370,7 @@ private void fail(final String component, final String key, final Object... deta */ private void buildResource(final JndiConsumer consumer, final Resource resource, final Member member) { - /** + /* * Was @Resource used at a class level without specifying the 'name' or 'beanInterface' attributes? */ if (member == null) { @@ -4363,7 +4391,7 @@ private void buildResource(final JndiConsumer consumer, final Resource resource, JndiReference reference = consumer.getEnvEntryMap().get(refName); if (reference == null) { - /** + /* * Was @Resource mistakenly used when either @PersistenceContext or @PersistenceUnit should have been used? */ if (member != null) { // Little quick validation for common mistake @@ -4657,7 +4685,7 @@ private void buildPersistenceContext(final JndiConsumer consumer, final Persiste String refName = persistenceContext.name(); if (refName.length() == 0) { - /** + /* * Was @PersistenceContext used at a class level without specifying the 'name' attribute? */ if (member == null) { @@ -4726,14 +4754,14 @@ private void buildPersistenceContext(final JndiConsumer consumer, final Persiste if (EntityManagerFactory.class.isAssignableFrom(type)) { failIfCdiProducer(member, "EntityManager"); - /** + /* * Was @PersistenceContext mistakenly used when @PersistenceUnit should have been used? */ fail(consumer.getJndiConsumerName(), "persistenceContextAnnotation.onEntityManagerFactory", persistenceContextRef.getName()); } else if (!EntityManager.class.isAssignableFrom(type)) { failIfCdiProducer(member, "EntityManager"); - /** + /* * Was @PersistenceContext mistakenly used for something that isn't an EntityManager? */ fail(consumer.getJndiConsumerName(), "persistenceContextAnnotation.onNonEntityManager", persistenceContextRef.getName()); @@ -5545,6 +5573,9 @@ private static void addRestClassesToScannedClasses(final WebModule webModule, fi clazz = classLoader.loadClass(className); classes.add(clazz); } catch (final ClassNotFoundException e) { + logger.debug("Could not load REST class {1} for web module {2} / {3}", + className, webModule.getJarLocation(), webModule.getFile().getName()); + throw new OpenEJBException("Unable to load REST class: " + className, e); } } diff --git a/container/openejb-core/src/main/resources/org/apache/openejb/config/rules/Messages.properties b/container/openejb-core/src/main/resources/org/apache/openejb/config/rules/Messages.properties index 6d81819043f..371549a9068 100644 --- a/container/openejb-core/src/main/resources/org/apache/openejb/config/rules/Messages.properties +++ b/container/openejb-core/src/main/resources/org/apache/openejb/config/rules/Messages.properties @@ -301,16 +301,16 @@ 3.asynchronous.badExceptionType = asynchronous method {0} in class {1} should not throw ApplicationException "{2}" while its return type is void. # warn("Asynchronous", "asynchronous.methodignored", beanClass.getName(), methodName); -1.asynchronous.methodignored = non-public method {1} in class {0} is ignored, although the class is annoated with @Asynchronous -2.asynchronous.methodignored = non-public method {1} in class {0} is ignored, although the class is annoated with @Asynchronous -3.asynchronous.methodignored = non-public method {1} in class {0} is ignored, although the class is annoated with @Asynchronous +1.asynchronous.methodignored = non-public method {1} in class {0} is ignored, although the class is annotated with @Asynchronous +2.asynchronous.methodignored = non-public method {1} in class {0} is ignored, although the class is annotated with @Asynchronous +3.asynchronous.methodignored = non-public method {1} in class {0} is ignored, although the class is annotated with @Asynchronous # AnnotationDeployer.java # warn("client.missingMainClass", className) # fail("client.missingMainClass", className) 1.client.missingMainClass = Missing Main-Class 2.client.missingMainClass = Missing Main-Class: {0} -3.client.missingMainClass = The Main-Class {0} specified in the MANIFEST.MF file does not exist in the jar. +3.client.missingMainClass = The Main-Class {0} specified in the MANIFEST.MF file does not exist in the jar {1}. # fail(ejbName, "xml.localRemote.conflict", interfce); 1.xml.localRemote.conflict = Interface illegally declared as both and . diff --git a/container/openejb-core/src/main/resources/org/apache/openejb/config/rules/Messages_hi.properties b/container/openejb-core/src/main/resources/org/apache/openejb/config/rules/Messages_hi.properties index 637751a7393..dc9c0a901e9 100644 --- a/container/openejb-core/src/main/resources/org/apache/openejb/config/rules/Messages_hi.properties +++ b/container/openejb-core/src/main/resources/org/apache/openejb/config/rules/Messages_hi.properties @@ -295,16 +295,16 @@ 3.asynchronous.badExceptionType = asynchronous method {0} in class {1} should not throw ApplicationException "{2}" while its return type is void. # warn("Asynchronous", "asynchronous.methodignored", beanClass.getName(), methodName); -1.asynchronous.methodignored = non-public method {1} in class {0} is ignored, although the class is annoated with @Asynchronous -2.asynchronous.methodignored = non-public method {1} in class {0} is ignored, although the class is annoated with @Asynchronous -3.asynchronous.methodignored = non-public method {1} in class {0} is ignored, although the class is annoated with @Asynchronous +1.asynchronous.methodignored = non-public method {1} in class {0} is ignored, although the class is annotated with @Asynchronous +2.asynchronous.methodignored = non-public method {1} in class {0} is ignored, although the class is annotated with @Asynchronous +3.asynchronous.methodignored = non-public method {1} in class {0} is ignored, although the class is annotated with @Asynchronous # AnnotationDeployer.java # warn("client.missingMainClass", className) # fail("client.missingMainClass", className) 1.client.missingMainClass = Missing Main-Class 2.client.missingMainClass = Missing Main-Class: {0} -3.client.missingMainClass = The Main-Class {0} specified in the MANIFEST.MF file does not exist in the jar. +3.client.missingMainClass = The Main-Class {0} specified in the MANIFEST.MF file does not exist in the jar {1}. # fail(ejbName, "xml.localRemote.conflict", interfce); 1.xml.localRemote.conflict = Interface illegally declared as both and . From b9becb288ef01c4b5346eeaa1c4124f4aaae0873 Mon Sep 17 00:00:00 2001 From: Richard Zowalla Date: Tue, 21 Nov 2023 11:15:31 +0100 Subject: [PATCH 07/36] Merge with latest changes from main --- tck/jsonb-signature-test/pom.xml | 77 +------------------------------ tck/jsonb-standalone/pom.xml | 78 +------------------------------- tck/pom.xml | 1 + 3 files changed, 5 insertions(+), 151 deletions(-) diff --git a/tck/jsonb-signature-test/pom.xml b/tck/jsonb-signature-test/pom.xml index 447cc11695c..6ec60a97a67 100644 --- a/tck/jsonb-signature-test/pom.xml +++ b/tck/jsonb-signature-test/pom.xml @@ -19,7 +19,7 @@ tck org.apache.tomee - 10.0.0-SNAPSHOT + 10.0.0-M1-SNAPSHOT 4.0.0 @@ -30,47 +30,14 @@ org.apache.johnzon johnzon-core - jakarta - - - org.apache.johnzon - * - - - org.apache.geronimo.specs - * - - org.apache.johnzon johnzon-mapper - jakarta - - - org.apache.johnzon - * - - - org.apache.geronimo.specs - * - - org.apache.johnzon johnzon-jsonb - jakarta - - - org.apache.johnzon - * - - - org.apache.geronimo.specs - * - - @@ -81,57 +48,17 @@ jakarta.json.bind jakarta.json.bind-tck - 3.0.0 + ${jsonb-tck.version} test - - org.apache.openwebbeans - openwebbeans-se - 2.0.27 - jakarta - - - org.apache.openwebbeans - * - - - org.apache.geronimo.specs - * - - - org.apache.openwebbeans openwebbeans-impl - 2.0.27 - jakarta - - - org.apache.openwebbeans - * - - - org.apache.geronimo.specs - * - - org.apache.openwebbeans openwebbeans-spi - 2.0.27 - jakarta - - - org.apache.openwebbeans - * - - - org.apache.geronimo.specs - * - - diff --git a/tck/jsonb-standalone/pom.xml b/tck/jsonb-standalone/pom.xml index 418a7f4e5a4..2a23e72589c 100644 --- a/tck/jsonb-standalone/pom.xml +++ b/tck/jsonb-standalone/pom.xml @@ -19,7 +19,7 @@ tck org.apache.tomee - 10.0.0-SNAPSHOT + 10.0.0-M1-SNAPSHOT 4.0.0 @@ -30,47 +30,14 @@ org.apache.johnzon johnzon-core - jakarta - - - org.apache.johnzon - * - - - org.apache.geronimo.specs - * - - org.apache.johnzon johnzon-mapper - jakarta - - - org.apache.johnzon - * - - - org.apache.geronimo.specs - * - - org.apache.johnzon johnzon-jsonb - jakarta - - - org.apache.johnzon - * - - - org.apache.geronimo.specs - * - - @@ -81,57 +48,16 @@ jakarta.json.bind jakarta.json.bind-tck - 3.0.0 + ${jsonb-tck.version} test - - - org.apache.openwebbeans - openwebbeans-se - 2.0.27 - jakarta - - - org.apache.openwebbeans - * - - - org.apache.geronimo.specs - * - - - org.apache.openwebbeans openwebbeans-impl - 2.0.27 - jakarta - - - org.apache.openwebbeans - * - - - org.apache.geronimo.specs - * - - org.apache.openwebbeans openwebbeans-spi - 2.0.27 - jakarta - - - org.apache.openwebbeans - * - - - org.apache.geronimo.specs - * - - diff --git a/tck/pom.xml b/tck/pom.xml index 4874f704b7e..c8d38e70e40 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -29,6 +29,7 @@ 4.0.11 3.0.1 + 3.0.0 org.apache.bval.jsr.ApacheValidationProvider From f4b359b689773ff427b04eeaaacc3724bf80ecf5 Mon Sep 17 00:00:00 2001 From: Richard Zowalla Date: Tue, 21 Nov 2023 11:27:28 +0100 Subject: [PATCH 08/36] Merge latest changes fron main --- tck/jsonp-signature-test/pom.xml | 61 +++++--------- tck/jsonp-standalone/pom.xml | 134 ++++++++++--------------------- tck/pom.xml | 2 +- 3 files changed, 63 insertions(+), 134 deletions(-) diff --git a/tck/jsonp-signature-test/pom.xml b/tck/jsonp-signature-test/pom.xml index 96befc4d8cb..c36256a045b 100644 --- a/tck/jsonp-signature-test/pom.xml +++ b/tck/jsonp-signature-test/pom.xml @@ -19,7 +19,7 @@ tck org.apache.tomee - 10.0.0-SNAPSHOT + 10.0.0-M1-SNAPSHOT 4.0.0 @@ -36,57 +36,24 @@ jakarta.json jakarta.json-tck-tests - 2.1.1 + ${jsonp-tck.version} test - - org.apache.openwebbeans - openwebbeans-se - 2.0.27 - jakarta - - - org.apache.openwebbeans - * - - - org.apache.geronimo.specs - * - - - org.apache.openwebbeans openwebbeans-impl - 2.0.27 - jakarta - - - org.apache.openwebbeans - * - - - org.apache.geronimo.specs - * - - org.apache.openwebbeans openwebbeans-spi - 2.0.27 - jakarta - - - org.apache.openwebbeans - * - - - org.apache.geronimo.specs - * - - + + + + org.netbeans.tools + sigtest-maven-plugin + 1.6 + test @@ -98,6 +65,11 @@ + + + org.apache.maven.plugins + maven-dependency-plugin + org.apache.maven.plugins maven-surefire-plugin @@ -105,6 +77,10 @@ false 1 + + ${project.build.directory}/jimage + ${project.build.directory}/signaturedirectory/jakarta.json-api.jar:${project.build.directory}/jimage/java.base:${project.build.directory}/jimage/java.rmi:${project.build.directory}/jimage/java.sql:${project.build.directory}/jimage/java.naming + jakarta.json:jakarta.json-tck-tests @@ -112,6 +88,7 @@ **/JSONPSigTest + diff --git a/tck/jsonp-standalone/pom.xml b/tck/jsonp-standalone/pom.xml index 0046700030a..50b7b0341aa 100644 --- a/tck/jsonp-standalone/pom.xml +++ b/tck/jsonp-standalone/pom.xml @@ -19,7 +19,7 @@ tck org.apache.tomee - 10.0.0-SNAPSHOT + 10.0.0-M1-SNAPSHOT 4.0.0 @@ -30,47 +30,6 @@ org.apache.johnzon johnzon-core - jakarta - - - org.apache.johnzon - * - - - org.apache.geronimo.specs - * - - - - - org.apache.johnzon - johnzon-mapper - jakarta - - - org.apache.johnzon - * - - - org.apache.geronimo.specs - * - - - - - org.apache.johnzon - johnzon-jsonp-strict - jakarta - - - org.apache.johnzon - * - - - org.apache.geronimo.specs - * - - @@ -81,64 +40,33 @@ jakarta.json jakarta.json-tck-tests - 2.1.1 + ${jsonp-tck.version} test + jakarta.json jakarta.json-tck-tests-pluggability - 2.1.1 + ${jsonp-tck.version} test org.apache.openwebbeans openwebbeans-se - 2.0.27 - jakarta - - - org.apache.openwebbeans - * - - - org.apache.geronimo.specs - * - - + ${version.openwebbeans} + org.apache.openwebbeans openwebbeans-impl - 2.0.27 - jakarta - - - org.apache.openwebbeans - * - - - org.apache.geronimo.specs - * - - + org.apache.openwebbeans openwebbeans-spi - 2.0.27 - jakarta - - - org.apache.openwebbeans - * - - - org.apache.geronimo.specs - * - - + @@ -149,6 +77,10 @@ + + org.apache.maven.plugins + maven-dependency-plugin + org.apache.maven.plugins maven-surefire-plugin @@ -156,19 +88,39 @@ false 1 - - jakarta.json:jakarta.json-tck-tests - jakarta.json:jakarta.json-tck-tests-pluggability - - - ee.jakarta.tck.jsonp.** - - - **/JSONPSigTest - + + + + tck + + test + + + jakarta.json:jakarta.json-tck-tests + + **/JSONPSigTest + + + jakarta.json:jakarta.json-tck-tests-pluggability + + + + + tck-pluggability + + test + + + jakarta.json:jakarta.json-tck-tests-pluggability + + jakarta.json:jakarta.json-tck-tests + + + + - \ No newline at end of file diff --git a/tck/pom.xml b/tck/pom.xml index fdcb7602b6d..7bc3dc6c0b3 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -29,7 +29,7 @@ 4.0.11 3.0.1 - + 2.1.1 org.apache.bval.jsr.ApacheValidationProvider From ec304f1af6d11d29e486cb291a5a424b13ba089a Mon Sep 17 00:00:00 2001 From: Richard Zowalla Date: Tue, 21 Nov 2023 11:31:45 +0100 Subject: [PATCH 09/36] Enhances config for JSONB tests --- tck/jsonb-signature-test/pom.xml | 17 +++++++++++++++++ tck/jsonb-standalone/pom.xml | 30 +++++++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/tck/jsonb-signature-test/pom.xml b/tck/jsonb-signature-test/pom.xml index 6ec60a97a67..935299a1c3d 100644 --- a/tck/jsonb-signature-test/pom.xml +++ b/tck/jsonb-signature-test/pom.xml @@ -52,6 +52,11 @@ test + + org.apache.openwebbeans + openwebbeans-se + ${version.openwebbeans} + org.apache.openwebbeans openwebbeans-impl @@ -60,6 +65,13 @@ org.apache.openwebbeans openwebbeans-spi + + + org.netbeans.tools + sigtest-maven-plugin + 1.6 + test + @@ -83,8 +95,13 @@ **/JSONBSigTest + + ${project.build.directory}/jimage + ${project.build.directory}/signaturedirectory/jakarta.json.bind-api.jar:${project.build.directory}/jimage/java.base:${project.build.directory}/jimage/java.rmi:${project.build.directory}/jimage/java.sql:${project.build.directory}/jimage/java.naming + + diff --git a/tck/jsonb-standalone/pom.xml b/tck/jsonb-standalone/pom.xml index 2a23e72589c..055d80f665c 100644 --- a/tck/jsonb-standalone/pom.xml +++ b/tck/jsonb-standalone/pom.xml @@ -51,6 +51,11 @@ ${jsonb-tck.version} test + + org.apache.openwebbeans + openwebbeans-se + ${version.openwebbeans} + org.apache.openwebbeans openwebbeans-impl @@ -69,6 +74,11 @@ + + org.apache.maven.plugins + maven-dependency-plugin + + org.apache.maven.plugins maven-surefire-plugin @@ -79,12 +89,26 @@ jakarta.json.bind:jakarta.json.bind-tck - - ee.jakarta.tck.json.bind.** - + + + **/SerializersCustomizationCDITest + + + **/AnnotationTypeInfoTest + **/JSONBSigTest + + + + false + false + + + COMPAT + + -Duser.language=en -Duser.region=US From 5e3baa49a463a28195564c6545d689ff7632cc7a Mon Sep 17 00:00:00 2001 From: Richard Zowalla Date: Tue, 21 Nov 2023 11:41:03 +0100 Subject: [PATCH 10/36] Add the api jar for signature tests --- tck/jsonp-signature-test/pom.xml | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tck/jsonp-signature-test/pom.xml b/tck/jsonp-signature-test/pom.xml index c36256a045b..b9318a57625 100644 --- a/tck/jsonp-signature-test/pom.xml +++ b/tck/jsonp-signature-test/pom.xml @@ -65,10 +65,32 @@ - org.apache.maven.plugins maven-dependency-plugin + + + copy + generate-test-resources + + copy + + + + + + org.apache.tomee + jakartaee-api + ${version.jakartaee-api} + jar + true + ${project.build.directory}/signaturedirectory + jakartaee-api.jar + + + + + org.apache.maven.plugins From c7859cce11aa855eb3606fb4dcf7ec211971149b Mon Sep 17 00:00:00 2001 From: Richard Zowalla Date: Tue, 21 Nov 2023 11:42:53 +0100 Subject: [PATCH 11/36] Fix signature tests --- tck/jsonb-signature-test/pom.xml | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/tck/jsonb-signature-test/pom.xml b/tck/jsonb-signature-test/pom.xml index 935299a1c3d..e35d9d82627 100644 --- a/tck/jsonb-signature-test/pom.xml +++ b/tck/jsonb-signature-test/pom.xml @@ -82,6 +82,33 @@ + + org.apache.maven.plugins + maven-dependency-plugin + + + copy + generate-test-resources + + copy + + + + + + org.apache.tomee + jakartaee-api + ${version.jakartaee-api} + jar + true + ${project.build.directory}/signaturedirectory + jakartaee-api.jar + + + + + + org.apache.maven.plugins maven-surefire-plugin @@ -97,7 +124,7 @@ ${project.build.directory}/jimage - ${project.build.directory}/signaturedirectory/jakarta.json.bind-api.jar:${project.build.directory}/jimage/java.base:${project.build.directory}/jimage/java.rmi:${project.build.directory}/jimage/java.sql:${project.build.directory}/jimage/java.naming + ${project.build.directory}/signaturedirectory/jakartaee-api.jar:${project.build.directory}/jimage/java.base:${project.build.directory}/jimage/java.rmi:${project.build.directory}/jimage/java.sql:${project.build.directory}/jimage/java.naming From 65ab79670530951a901d695b973af8e0f91fb130 Mon Sep 17 00:00:00 2001 From: Richard Zowalla Date: Tue, 21 Nov 2023 11:44:14 +0100 Subject: [PATCH 12/36] Setup signature tests --- tck/jsonp-signature-test/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tck/jsonp-signature-test/pom.xml b/tck/jsonp-signature-test/pom.xml index b9318a57625..64609c97e74 100644 --- a/tck/jsonp-signature-test/pom.xml +++ b/tck/jsonp-signature-test/pom.xml @@ -101,7 +101,7 @@ 1 ${project.build.directory}/jimage - ${project.build.directory}/signaturedirectory/jakarta.json-api.jar:${project.build.directory}/jimage/java.base:${project.build.directory}/jimage/java.rmi:${project.build.directory}/jimage/java.sql:${project.build.directory}/jimage/java.naming + ${project.build.directory}/signaturedirectory/jakartaee-api.jar:${project.build.directory}/jimage/java.base:${project.build.directory}/jimage/java.rmi:${project.build.directory}/jimage/java.sql:${project.build.directory}/jimage/java.naming jakarta.json:jakarta.json-tck-tests From 7284bf5771580235c35ea863def84dc24fa84ac3 Mon Sep 17 00:00:00 2001 From: Richard Zowalla Date: Tue, 21 Nov 2023 12:35:42 +0100 Subject: [PATCH 13/36] Passes standalone jsonb standalone --- tck/jsonb-standalone/pom.xml | 4 +++ .../tomee/jsonb/tck/TomEEOwbCDIProvider.java | 34 +++++++++++++++++++ .../jakarta.enterprise.inject.spi.CDIProvider | 1 + 3 files changed, 39 insertions(+) create mode 100644 tck/jsonb-standalone/src/test/java/org/apache/tomee/jsonb/tck/TomEEOwbCDIProvider.java create mode 100644 tck/jsonb-standalone/src/test/resources/META-INF/services/jakarta.enterprise.inject.spi.CDIProvider diff --git a/tck/jsonb-standalone/pom.xml b/tck/jsonb-standalone/pom.xml index 055d80f665c..02380f1a1cb 100644 --- a/tck/jsonb-standalone/pom.xml +++ b/tck/jsonb-standalone/pom.xml @@ -64,6 +64,10 @@ org.apache.openwebbeans openwebbeans-spi + + org.apache.xbean + xbean-finder-shaded + diff --git a/tck/jsonb-standalone/src/test/java/org/apache/tomee/jsonb/tck/TomEEOwbCDIProvider.java b/tck/jsonb-standalone/src/test/java/org/apache/tomee/jsonb/tck/TomEEOwbCDIProvider.java new file mode 100644 index 00000000000..17c491c7cf0 --- /dev/null +++ b/tck/jsonb-standalone/src/test/java/org/apache/tomee/jsonb/tck/TomEEOwbCDIProvider.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tomee.jsonb.tck; + +import jakarta.enterprise.inject.spi.CDI; +import org.apache.webbeans.container.OwbCDIProvider; + +// CDI Integration TCKs rely on undefined CDI behaviour: they expect that calling CDI.current() throws an Exception when CDI is not started +// OWB doesn't do that, so we try to achieve this here as a workaround by calling CDI#getBeanManager before returning CDI +public class TomEEOwbCDIProvider extends OwbCDIProvider { + @Override + public CDI getCDI() { + CDI cdi = super.getCDI(); + cdi.getBeanManager(); + + return cdi; + } +} \ No newline at end of file diff --git a/tck/jsonb-standalone/src/test/resources/META-INF/services/jakarta.enterprise.inject.spi.CDIProvider b/tck/jsonb-standalone/src/test/resources/META-INF/services/jakarta.enterprise.inject.spi.CDIProvider new file mode 100644 index 00000000000..2e9b93bd152 --- /dev/null +++ b/tck/jsonb-standalone/src/test/resources/META-INF/services/jakarta.enterprise.inject.spi.CDIProvider @@ -0,0 +1 @@ +org.apache.tomee.jsonb.tck.TomEEOwbCDIProvider \ No newline at end of file From 965bbcd9b7eca63fcd9d23093a127cb4afbe1c18 Mon Sep 17 00:00:00 2001 From: Richard Zowalla Date: Tue, 21 Nov 2023 13:02:48 +0100 Subject: [PATCH 14/36] JSONP Standalone should now be ok --- tck/jsonp-standalone/pom.xml | 125 ++++++++++++++++++----------------- 1 file changed, 64 insertions(+), 61 deletions(-) diff --git a/tck/jsonp-standalone/pom.xml b/tck/jsonp-standalone/pom.xml index 50b7b0341aa..e10db7da16d 100644 --- a/tck/jsonp-standalone/pom.xml +++ b/tck/jsonp-standalone/pom.xml @@ -27,11 +27,6 @@ TomEE :: TCK :: JSON-P Standalone - - org.apache.johnzon - johnzon-core - - org.apache.tomee jakartaee-api @@ -51,76 +46,84 @@ test + + org.apache.johnzon + johnzon-core + + org.apache.openwebbeans openwebbeans-se ${version.openwebbeans} - org.apache.openwebbeans openwebbeans-impl - org.apache.openwebbeans openwebbeans-spi - - - - src/test/resources - true - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - org.apache.maven.plugins - maven-surefire-plugin - ${surefire.version} - - false - 1 - - - - - tck - - test - - - jakarta.json:jakarta.json-tck-tests - - **/JSONPSigTest - - - jakarta.json:jakarta.json-tck-tests-pluggability - - - - - tck-pluggability - - test - - - jakarta.json:jakarta.json-tck-tests-pluggability - - jakarta.json:jakarta.json-tck-tests - - - - - - - + + + src/test/resources + true + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${surefire.version} + + false + 1 + + + + + + tck-pluggability + + + test + + + + jakarta.json:jakarta.json-tck-tests-pluggability + + + jakarta.json:jakarta.json-tck-tests + + + + + + + tck + + + test + + + + jakarta.json:jakarta.json-tck-tests + + + jakarta.json:jakarta.json-tck-tests-pluggability + + + + **/JSONPSigTest + + + + + + + \ No newline at end of file From 5278e49c18d72e10fd7f20847e58a1a1f190047d Mon Sep 17 00:00:00 2001 From: Richard Zowalla Date: Tue, 21 Nov 2023 13:05:41 +0100 Subject: [PATCH 15/36] Setup signature tests --- tck/jsonp-signature-test/pom.xml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tck/jsonp-signature-test/pom.xml b/tck/jsonp-signature-test/pom.xml index 64609c97e74..c20cb4b1b74 100644 --- a/tck/jsonp-signature-test/pom.xml +++ b/tck/jsonp-signature-test/pom.xml @@ -27,7 +27,6 @@ TomEE :: TCK :: JSON-P Signature Tests - org.apache.tomee jakartaee-api @@ -40,10 +39,22 @@ test + + org.apache.johnzon + johnzon-core + + + + org.apache.openwebbeans + openwebbeans-se + ${version.openwebbeans} + + org.apache.openwebbeans openwebbeans-impl + org.apache.openwebbeans openwebbeans-spi From 81e9459a07c3559f3e85057a112177ffd03ed212 Mon Sep 17 00:00:00 2001 From: Richard Zowalla Date: Tue, 21 Nov 2023 13:54:36 +0100 Subject: [PATCH 16/36] Fix signature tests --- tck/jsonp-signature-test/pom.xml | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tck/jsonp-signature-test/pom.xml b/tck/jsonp-signature-test/pom.xml index c20cb4b1b74..050e1142439 100644 --- a/tck/jsonp-signature-test/pom.xml +++ b/tck/jsonp-signature-test/pom.xml @@ -103,6 +103,39 @@ + + org.apache.maven.plugins + maven-antrun-plugin + 3.1.0 + + + setup-project + test-compile + + run + + + + Removing jakarta.json.bind classes from the jakartaee-api.jar (we cannot exclude that package them from the sigtests). + + + + + + + + + + + + + + + + + + + org.apache.maven.plugins maven-surefire-plugin From 0d2eb42eacdf28ae2625e0671266a7c58514d9de Mon Sep 17 00:00:00 2001 From: Richard Zowalla Date: Wed, 29 Nov 2023 08:32:55 +0100 Subject: [PATCH 17/36] TOMEE-4283 - OWB 4.0.1 TOMEE-4282 - Tomcat 10.1.16 --- boms/tomee-microprofile/pom.xml | 16 ++++++++-------- boms/tomee-plume/pom.xml | 16 ++++++++-------- boms/tomee-plus/pom.xml | 16 ++++++++-------- boms/tomee-webprofile/pom.xml | 16 ++++++++-------- pom.xml | 4 ++-- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/boms/tomee-microprofile/pom.xml b/boms/tomee-microprofile/pom.xml index 0d212bddbd7..d05b32e6d2f 100644 --- a/boms/tomee-microprofile/pom.xml +++ b/boms/tomee-microprofile/pom.xml @@ -884,7 +884,7 @@ org.apache.openwebbeans openwebbeans-ee-common - 4.0.0 + 4.0.1 * @@ -895,7 +895,7 @@ org.apache.openwebbeans openwebbeans-ee - 4.0.0 + 4.0.1 * @@ -906,7 +906,7 @@ org.apache.openwebbeans openwebbeans-ejb - 4.0.0 + 4.0.1 * @@ -917,7 +917,7 @@ org.apache.openwebbeans openwebbeans-el22 - 4.0.0 + 4.0.1 * @@ -928,7 +928,7 @@ org.apache.openwebbeans openwebbeans-impl - 4.0.0 + 4.0.1 * @@ -939,7 +939,7 @@ org.apache.openwebbeans openwebbeans-jsf - 4.0.0 + 4.0.1 * @@ -950,7 +950,7 @@ org.apache.openwebbeans openwebbeans-spi - 4.0.0 + 4.0.1 * @@ -961,7 +961,7 @@ org.apache.openwebbeans openwebbeans-web - 4.0.0 + 4.0.1 * diff --git a/boms/tomee-plume/pom.xml b/boms/tomee-plume/pom.xml index b3e10c0172e..57d33bfe7de 100644 --- a/boms/tomee-plume/pom.xml +++ b/boms/tomee-plume/pom.xml @@ -972,7 +972,7 @@ org.apache.openwebbeans openwebbeans-ee-common - 4.0.0 + 4.0.1 * @@ -983,7 +983,7 @@ org.apache.openwebbeans openwebbeans-ee - 4.0.0 + 4.0.1 * @@ -994,7 +994,7 @@ org.apache.openwebbeans openwebbeans-ejb - 4.0.0 + 4.0.1 * @@ -1005,7 +1005,7 @@ org.apache.openwebbeans openwebbeans-el22 - 4.0.0 + 4.0.1 * @@ -1016,7 +1016,7 @@ org.apache.openwebbeans openwebbeans-impl - 4.0.0 + 4.0.1 * @@ -1027,7 +1027,7 @@ org.apache.openwebbeans openwebbeans-jsf - 4.0.0 + 4.0.1 * @@ -1038,7 +1038,7 @@ org.apache.openwebbeans openwebbeans-spi - 4.0.0 + 4.0.1 * @@ -1049,7 +1049,7 @@ org.apache.openwebbeans openwebbeans-web - 4.0.0 + 4.0.1 * diff --git a/boms/tomee-plus/pom.xml b/boms/tomee-plus/pom.xml index c76a82c952a..6230bb0e3c1 100644 --- a/boms/tomee-plus/pom.xml +++ b/boms/tomee-plus/pom.xml @@ -994,7 +994,7 @@ org.apache.openwebbeans openwebbeans-ee-common - 4.0.0 + 4.0.1 * @@ -1005,7 +1005,7 @@ org.apache.openwebbeans openwebbeans-ee - 4.0.0 + 4.0.1 * @@ -1016,7 +1016,7 @@ org.apache.openwebbeans openwebbeans-ejb - 4.0.0 + 4.0.1 * @@ -1027,7 +1027,7 @@ org.apache.openwebbeans openwebbeans-el22 - 4.0.0 + 4.0.1 * @@ -1038,7 +1038,7 @@ org.apache.openwebbeans openwebbeans-impl - 4.0.0 + 4.0.1 * @@ -1049,7 +1049,7 @@ org.apache.openwebbeans openwebbeans-jsf - 4.0.0 + 4.0.1 * @@ -1060,7 +1060,7 @@ org.apache.openwebbeans openwebbeans-spi - 4.0.0 + 4.0.1 * @@ -1071,7 +1071,7 @@ org.apache.openwebbeans openwebbeans-web - 4.0.0 + 4.0.1 * diff --git a/boms/tomee-webprofile/pom.xml b/boms/tomee-webprofile/pom.xml index db6af523305..f797d716379 100644 --- a/boms/tomee-webprofile/pom.xml +++ b/boms/tomee-webprofile/pom.xml @@ -532,7 +532,7 @@ org.apache.openwebbeans openwebbeans-ee-common - 4.0.0 + 4.0.1 * @@ -543,7 +543,7 @@ org.apache.openwebbeans openwebbeans-ee - 4.0.0 + 4.0.1 * @@ -554,7 +554,7 @@ org.apache.openwebbeans openwebbeans-ejb - 4.0.0 + 4.0.1 * @@ -565,7 +565,7 @@ org.apache.openwebbeans openwebbeans-el22 - 4.0.0 + 4.0.1 * @@ -576,7 +576,7 @@ org.apache.openwebbeans openwebbeans-impl - 4.0.0 + 4.0.1 * @@ -587,7 +587,7 @@ org.apache.openwebbeans openwebbeans-jsf - 4.0.0 + 4.0.1 * @@ -598,7 +598,7 @@ org.apache.openwebbeans openwebbeans-spi - 4.0.0 + 4.0.1 * @@ -609,7 +609,7 @@ org.apache.openwebbeans openwebbeans-web - 4.0.0 + 4.0.1 * diff --git a/pom.xml b/pom.xml index 3c5437ae19d..22757f1a371 100644 --- a/pom.xml +++ b/pom.xml @@ -204,7 +204,7 @@ 1.0.0-M1 - 10.1.15 + 10.1.16 2.0.1 @@ -218,7 +218,7 @@ 2.0.0 4.0.1 4.0.0-SNAPSHOT - 4.0.0 + 4.0.1 3.0.3 From 914e9cf4efa161f8c455136b86f861ca4f1a910c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Tichov?= Date: Sun, 3 Dec 2023 22:25:26 +0100 Subject: [PATCH 18/36] Implement tomee.mp.jwt.allow.no-exp property over mp.jwt.tomee.allow.no-exp --- .../jwt/itest/AllowNoExpPropertyTest.java | 2 +- .../config/JWTAuthConfigurationProperties.java | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/itests/microprofile-jwt-itests/src/test/java/org/apache/tomee/microprofile/jwt/itest/AllowNoExpPropertyTest.java b/itests/microprofile-jwt-itests/src/test/java/org/apache/tomee/microprofile/jwt/itest/AllowNoExpPropertyTest.java index 467cc17a6de..17003fb50d6 100644 --- a/itests/microprofile-jwt-itests/src/test/java/org/apache/tomee/microprofile/jwt/itest/AllowNoExpPropertyTest.java +++ b/itests/microprofile-jwt-itests/src/test/java/org/apache/tomee/microprofile/jwt/itest/AllowNoExpPropertyTest.java @@ -45,7 +45,7 @@ public class AllowNoExpPropertyTest { - + @Test public void testNewPropertyOverridesOld1() throws Exception { final Tokens tokens = Tokens.rsa(2048, 256); diff --git a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/JWTAuthConfigurationProperties.java b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/JWTAuthConfigurationProperties.java index 65fac639957..f258d8f4cab 100644 --- a/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/JWTAuthConfigurationProperties.java +++ b/mp-jwt/src/main/java/org/apache/tomee/microprofile/jwt/config/JWTAuthConfigurationProperties.java @@ -121,14 +121,15 @@ private JWTAuthConfiguration createJWTAuthConfiguration() { } private Boolean queryAllowExp(){ - AtomicBoolean result = new AtomicBoolean(false); - config.getOptionalValue("mp.jwt.tomee.allow.no-exp", Boolean.class).ifPresent(value -> { - result.set(value); - CONFIGURATION.warning("mp.jwt.tomee.allow.no-exp property is deprecated, use tomee.mp.jwt.allow.no-exp propert instead."); - }); - return config.getOptionalValue("tomee.mp.jwt.allow.no-exp", Boolean.class).orElse(result.get()); + return config.getOptionalValue("tomee.mp.jwt.allow.no-exp", Boolean.class) + .or(() -> config.getOptionalValue("mp.jwt.tomee.allow.no-exp", Boolean.class) + .map(value -> { + CONFIGURATION.warning("mp.jwt.tomee.allow.no-exp property is deprecated, use tomee.mp.jwt.allow.no-exp propert instead."); + return value; + })) + .orElse(false); } - + enum Keys { VERIFY("mp.jwt.verify.publickey", "tomee.jwt.verify.publickey"), DECRYPT("mp.jwt.decrypt.key", "tomee.jwt.decrypt.key"); From 2a17f9dd3f4820f2f98a5c8deb82a53193cc955e Mon Sep 17 00:00:00 2001 From: Jonathan Gallimore Date: Tue, 5 Dec 2023 14:37:02 +0000 Subject: [PATCH 19/36] TOMEE-4286 look at http:// in the namespace as well as https:// --- .../src/main/java/org/apache/openejb/jee/JaxbJavaee.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/container/openejb-jee/src/main/java/org/apache/openejb/jee/JaxbJavaee.java b/container/openejb-jee/src/main/java/org/apache/openejb/jee/JaxbJavaee.java index 7b39e9e5704..487dfcd209f 100644 --- a/container/openejb-jee/src/main/java/org/apache/openejb/jee/JaxbJavaee.java +++ b/container/openejb-jee/src/main/java/org/apache/openejb/jee/JaxbJavaee.java @@ -352,7 +352,7 @@ public NoSourceFilter(final XMLReader xmlReader) { protected String eeUri(final String uri) { // if ee 7 or jakarta ee then switch back on ee 6 to not break compatibility - to rework surely when we'll be fully ee 7 or jakarta ee - if ("http://xmlns.jcp.org/xml/ns/javaee".equals(uri) || "https://jakarta.ee/xml/ns/jakartaee".equals(uri)){ + if ("http://xmlns.jcp.org/xml/ns/javaee".equals(uri) || "https://jakarta.ee/xml/ns/jakartaee".equals(uri) || "http://jakarta.ee/xml/ns/jakartaee".equals(uri)){ return "http://java.sun.com/xml/ns/javaee"; } return uri; From aa185a5d8356d722c0289c196e6b1f5aa44dfb62 Mon Sep 17 00:00:00 2001 From: Frank Jung Date: Tue, 19 Dec 2023 14:29:47 +0100 Subject: [PATCH 20/36] Dependency Update EclipseLink 3.0.4 --- boms/tomee-plume/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/boms/tomee-plume/pom.xml b/boms/tomee-plume/pom.xml index 57d33bfe7de..8f64bcf4f60 100644 --- a/boms/tomee-plume/pom.xml +++ b/boms/tomee-plume/pom.xml @@ -2105,7 +2105,7 @@ org.eclipse.persistence eclipselink - 3.0.3 + 3.0.4 * diff --git a/pom.xml b/pom.xml index 22757f1a371..4d726ac80d6 100644 --- a/pom.xml +++ b/pom.xml @@ -220,7 +220,7 @@ 4.0.0-SNAPSHOT 4.0.1 - 3.0.3 + 3.0.4 4.0.1 From e29bfd7765257bb954c93edb7ca3320a0f378220 Mon Sep 17 00:00:00 2001 From: Jonathan Gallimore Date: Fri, 5 Jan 2024 16:47:27 +0000 Subject: [PATCH 21/36] TOMEE-4294 exclude CDI 4 as a transitive dependency from SmallRye Fault Tolerance --- tomee/tomee-microprofile/mp-common/pom.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tomee/tomee-microprofile/mp-common/pom.xml b/tomee/tomee-microprofile/mp-common/pom.xml index 2341854ef5e..e818ccc998d 100644 --- a/tomee/tomee-microprofile/mp-common/pom.xml +++ b/tomee/tomee-microprofile/mp-common/pom.xml @@ -220,6 +220,10 @@ io.smallrye smallrye-fault-tolerance + + jakarta.enterprise + jakarta.enterprise.cdi-api + * microprofile-fault-tolerance-api From 26a079e7a42dfdf16305c935c8f6fcbe4397071f Mon Sep 17 00:00:00 2001 From: Jonathan Gallimore Date: Wed, 13 Apr 2022 11:37:11 +0100 Subject: [PATCH 22/36] TOMEE-3902: Allow properties to be injected into any activation properties --- .../apache/openejb/core/mdb/MdbContainer.java | 45 ++++- .../core/mdb/ActivationConfigTest.java | 131 +++++++++++++++ .../MdbContainerClientIdActivationTest.java | 159 ++++++++++++++++++ .../tomee/itests/ejb/MessageCounter.java | 37 ++++ .../tomee/itests/ejb/MessageReceiver.java | 38 +++++ .../tomee/itests/ejb/MessageResource.java | 53 ++++++ .../tomee/itests/ejb/MessageSender.java | 54 ++++++ .../ejb/MultiTomEETopicSubscriberTest.java | 115 +++++++++++++ itests/itest-common/pom.xml | 1 - itests/pom.xml | 1 + 10 files changed, 624 insertions(+), 10 deletions(-) create mode 100644 container/openejb-core/src/test/java/org/apache/openejb/core/mdb/ActivationConfigTest.java create mode 100644 container/openejb-core/src/test/java/org/apache/openejb/core/mdb/MdbContainerClientIdActivationTest.java create mode 100644 itests/ejb/src/test/java/org/apache/tomee/itests/ejb/MessageCounter.java create mode 100644 itests/ejb/src/test/java/org/apache/tomee/itests/ejb/MessageReceiver.java create mode 100644 itests/ejb/src/test/java/org/apache/tomee/itests/ejb/MessageResource.java create mode 100644 itests/ejb/src/test/java/org/apache/tomee/itests/ejb/MessageSender.java create mode 100644 itests/ejb/src/test/java/org/apache/tomee/itests/ejb/MultiTomEETopicSubscriberTest.java diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContainer.java b/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContainer.java index 898e7858d00..bda66db61d5 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContainer.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContainer.java @@ -38,6 +38,7 @@ import org.apache.openejb.spi.SecurityService; import org.apache.openejb.util.LogCategory; import org.apache.openejb.util.Logger; +import org.apache.openejb.util.StringTemplate; import org.apache.xbean.recipe.ObjectRecipe; import org.apache.xbean.recipe.Option; @@ -67,12 +68,9 @@ import jakarta.validation.Validator; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; -import java.util.TreeSet; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicBoolean; @@ -274,17 +272,46 @@ public void deploy(final BeanContext beanContext) throws OpenEJBException { } } - private ActivationSpec createActivationSpec(final BeanContext beanContext) throws OpenEJBException { + // visibility to allow unit testing + public ActivationSpec createActivationSpec(final BeanContext beanContext) throws OpenEJBException { try { // initialize the object recipe final ObjectRecipe objectRecipe = new ObjectRecipe(activationSpecClass); objectRecipe.allow(Option.IGNORE_MISSING_PROPERTIES); objectRecipe.disallow(Option.FIELD_INJECTION); - final Map activationProperties = beanContext.getActivationProperties(); + + final Map context = new HashMap<>(); + context.put("ejbJarId", beanContext.getModuleContext().getId()); + context.put("ejbName", beanContext.getEjbName()); + context.put("appId", beanContext.getModuleContext().getAppContext().getId()); + + String hostname; + try { + hostname = InetAddress.getLocalHost().getHostName(); + } catch (UnknownHostException e) { + hostname = "hostname-unknown"; + } + + context.put("hostName", hostname); + + String uniqueId = Long.toString(System.currentTimeMillis()); + try { + Class idGen = Class.forName("org.apache.activemq.util.IdGenerator"); + final Object generator = idGen.getConstructor().newInstance(); + final Method generateId = idGen.getDeclaredMethod("generateId"); + final Object ID = generateId.invoke(generator); + + uniqueId = ID.toString(); + } catch (Exception e) { + // ignore and use the timestamp + } + + context.put("uniqueId", uniqueId); + for (final Map.Entry entry : activationProperties.entrySet()) { - objectRecipe.setMethodProperty(entry.getKey(), entry.getValue()); + objectRecipe.setMethodProperty(entry.getKey(), new StringTemplate(entry.getValue()).apply(context)); } objectRecipe.setMethodProperty("beanClass", beanContext.getBeanClass()); diff --git a/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/ActivationConfigTest.java b/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/ActivationConfigTest.java new file mode 100644 index 00000000000..519912b93d1 --- /dev/null +++ b/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/ActivationConfigTest.java @@ -0,0 +1,131 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.core.mdb; + +import org.apache.activemq.ra.ActiveMQActivationSpec; +import org.apache.activemq.ra.ActiveMQResourceAdapter; +import org.apache.openejb.AppContext; +import org.apache.openejb.BeanContext; +import org.apache.openejb.ModuleContext; +import org.apache.openejb.core.ivm.naming.IvmContext; +import org.apache.openejb.loader.SystemInstance; +import org.junit.Assert; +import org.junit.Test; + +import jakarta.jms.Message; +import jakarta.jms.MessageListener; +import jakarta.resource.spi.ActivationSpec; +import jakarta.resource.spi.ResourceAdapter; +import jakarta.validation.ConstraintViolation; +import jakarta.validation.Validator; +import jakarta.validation.executable.ExecutableValidator; +import jakarta.validation.metadata.BeanDescriptor; +import java.net.InetAddress; +import java.net.URI; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.regex.Pattern; + +public class ActivationConfigTest { + + @Test + public void testShouldResolvePlaceHolder() throws Exception { + final ResourceAdapter ra = new ActiveMQResourceAdapter(); + final MdbContainer container = new MdbContainer("TestMdbContainer", null, ra, MessageListener.class, ActiveMQActivationSpec.class, 10, false); + + + final Map properties = new HashMap<>(); + properties.put("clientId", "{appId}#{ejbJarId}#{ejbName}#{hostName}#{uniqueId}"); + properties.put("subscriptionName", "subscription-{appId}#{ejbJarId}#{ejbName}#{hostName}#{uniqueId}"); + properties.put("destination", "MyTopic"); + properties.put("destinationType", "jakarta.jms.Topic"); + + final BeanContext beanContext = getMockBeanContext(properties); + + final ActivationSpec activationSpec = container.createActivationSpec(beanContext); + Assert.assertTrue(activationSpec instanceof ActiveMQActivationSpec); + + ActiveMQActivationSpec spec = (ActiveMQActivationSpec) activationSpec; + + final String clientId = spec.getClientId(); + final String[] parts = clientId.split("#"); + + final String hostname = (InetAddress.getLocalHost()).getHostName(); + + Assert.assertEquals("appId", parts[0]); + Assert.assertEquals("moduleId", parts[1]); + Assert.assertEquals("MyEjb", parts[2]); + Assert.assertEquals(hostname, parts[3]); + + final Pattern pattern = Pattern.compile("ID:.*?-\\d+-\\d+-\\d+:\\d"); + Assert.assertTrue(pattern.matcher(parts[4]).matches()); + } + + private BeanContext getMockBeanContext(final Map properties) throws Exception { + final IvmContext context = new IvmContext(); + context.bind("comp/Validator", new NoOpValidator()); + + final AppContext mockAppContext = new AppContext("appId", SystemInstance.get(), this.getClass().getClassLoader(), context, context, false); + final ModuleContext mockModuleContext = new ModuleContext("moduleId", new URI(""), "uniqueId", mockAppContext, context, this.getClass().getClassLoader()); + final BeanContext mockBeanContext = new BeanContext("test", context, mockModuleContext, MyListener.class, MessageListener.class, properties); + mockBeanContext.setEjbName("MyEjb"); + + return mockBeanContext; + } + + public static class MyListener implements MessageListener { + + @Override + public void onMessage(Message message) { + + } + } + + public static class NoOpValidator implements Validator { + @Override + public Set> validate(T object, Class... groups) { + return Collections.emptySet(); + } + + @Override + public Set> validateProperty(T object, String propertyName, Class... groups) { + return Collections.emptySet(); + } + + @Override + public Set> validateValue(Class beanType, String propertyName, Object value, Class... groups) { + return Collections.emptySet(); + } + + @Override + public BeanDescriptor getConstraintsForClass(Class clazz) { + return null; + } + + @Override + public T unwrap(Class type) { + return null; + } + + @Override + public ExecutableValidator forExecutables() { + return null; + } + } +} diff --git a/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/MdbContainerClientIdActivationTest.java b/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/MdbContainerClientIdActivationTest.java new file mode 100644 index 00000000000..19f12acb75b --- /dev/null +++ b/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/MdbContainerClientIdActivationTest.java @@ -0,0 +1,159 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.core.mdb; + +import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.broker.TransportConnector; +import org.apache.activemq.broker.region.Destination; +import org.apache.activemq.broker.region.Subscription; +import org.apache.activemq.command.ActiveMQTopic; +import org.apache.openejb.jee.MessageDrivenBean; +import org.apache.openejb.junit.ApplicationComposer; +import org.apache.openejb.testing.Configuration; +import org.apache.openejb.testing.Module; +import org.apache.openejb.testng.PropertiesBuilder; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; + +import jakarta.annotation.Resource; +import jakarta.ejb.ActivationConfigProperty; +import jakarta.ejb.MessageDriven; +import jakarta.jms.*; +import javax.management.MBeanServer; +import javax.management.ObjectName; +import java.lang.management.ManagementFactory; +import java.util.Properties; +import java.util.Set; +import java.util.concurrent.CountDownLatch; +import java.util.regex.Pattern; + +@RunWith(ApplicationComposer.class) +public class MdbContainerClientIdActivationTest { + + private static BrokerService broker; + + @Resource(name = "target") + private Topic destination; + + @Resource(name = "cf") + private ConnectionFactory cf; + + @Configuration + public Properties config() throws Exception{ + final TransportConnector tc = broker.getTransportConnectors().iterator().next(); + final int port = tc.getConnectUri().getPort(); + + return new PropertiesBuilder() + + .p("amq", "new://Resource?type=ActiveMQResourceAdapter") + + .p("amq.DataSource", "") + .p("amq.BrokerXmlConfig", "") //connect to an external broker + .p("amq.ServerUrl", "tcp://localhost:" + port) + + .p("target", "new://Resource?type=Topic") + + .p("mdbs", "new://Container?type=MESSAGE") + .p("mdbs.ResourceAdapter", "amq") + .p("mdbs.pool", "false") + .p("cf", "new://Resource?type=" + ConnectionFactory.class.getName()) + .p("cf.ResourceAdapter", "amq") + + .p("mdb.activation.clientId", "{ejbName}-{uniqueId}") + + .build(); + } + + @Module + public MessageDrivenBean jar() { + return new MessageDrivenBean(Listener.class); + } + + @BeforeClass + public static void beforeClass() throws Exception { + broker = new BrokerService(); + broker.setPersistent(false); + broker.setUseJmx(true); + broker.addConnector("tcp://localhost:0"); // pick a random available port + + broker.start(); + } + + @AfterClass + public static void afterClass() throws Exception { + broker.stop(); + } + + @Test + public void shouldHaveAUniqueClientID() throws Exception { + final Connection connection = cf.createConnection(); + connection.start(); + + final Session session = connection.createSession(); + final MessageProducer producer = session.createProducer(this.destination); + final TextMessage msg = session.createTextMessage("Hello"); + producer.send(msg); + producer.close(); + session.close(); + connection.close(); + + Listener.latch.await(); + + + final MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer(); + final Set objectNames = platformMBeanServer.queryNames(new ObjectName("org.apache.activemq:type=Broker,brokerName=localhost,destinationType=Topic,destinationName=target,endpoint=Consumer,*"), null); + + ObjectName match = null; + + for (final ObjectName objectName : objectNames) { + if (objectName.getKeyProperty("clientId").startsWith("testMDB")) { + match = objectName; + break; + } + } + + Assert.assertNotNull(match); + + final String clientId = match.getKeyProperty("clientId"); + final String uniquePart = clientId.substring(8); + + Assert.assertNotNull(clientId); + Assert.assertNotNull(uniquePart); + + final Pattern pattern = Pattern.compile("ID_.*?-\\d+-\\d+-\\d+_\\d"); + Assert.assertTrue(pattern.matcher(uniquePart).matches()); + } + + @MessageDriven(name="testMDB", activationConfig = { + @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "jakarta.jms.Topic"), + @ActivationConfigProperty(propertyName = "destination", propertyValue = "target") + }) + public static class Listener implements MessageListener { + public static CountDownLatch latch = new CountDownLatch(1); + + @Override + public void onMessage(final Message message) { + latch.countDown(); + } + + + } + +} \ No newline at end of file diff --git a/itests/ejb/src/test/java/org/apache/tomee/itests/ejb/MessageCounter.java b/itests/ejb/src/test/java/org/apache/tomee/itests/ejb/MessageCounter.java new file mode 100644 index 00000000000..2a2ff2589b4 --- /dev/null +++ b/itests/ejb/src/test/java/org/apache/tomee/itests/ejb/MessageCounter.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tomee.itests.ejb; + +import jakarta.ejb.Lock; +import jakarta.ejb.LockType; +import jakarta.ejb.Singleton; +import java.util.concurrent.atomic.AtomicInteger; + +@Singleton +@Lock(LockType.READ) +public class MessageCounter { + + private static final AtomicInteger COUNTER = new AtomicInteger(); + + public void increment() { + COUNTER.incrementAndGet(); + } + + public int getCount() { + return COUNTER.get(); + } +} diff --git a/itests/ejb/src/test/java/org/apache/tomee/itests/ejb/MessageReceiver.java b/itests/ejb/src/test/java/org/apache/tomee/itests/ejb/MessageReceiver.java new file mode 100644 index 00000000000..284272bef82 --- /dev/null +++ b/itests/ejb/src/test/java/org/apache/tomee/itests/ejb/MessageReceiver.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tomee.itests.ejb; + +import jakarta.ejb.ActivationConfigProperty; +import jakarta.ejb.EJB; +import jakarta.ejb.MessageDriven; +import jakarta.jms.Message; +import jakarta.jms.MessageListener; + +@MessageDriven(name="Receiver", activationConfig = { + @ActivationConfigProperty(propertyName = "destination", propertyValue = "target"), + @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "jakarta.jms.Topic") +}) +public class MessageReceiver implements MessageListener { + + @EJB + private MessageCounter counter; + + @Override + public void onMessage(Message message) { + counter.increment(); + } +} diff --git a/itests/ejb/src/test/java/org/apache/tomee/itests/ejb/MessageResource.java b/itests/ejb/src/test/java/org/apache/tomee/itests/ejb/MessageResource.java new file mode 100644 index 00000000000..ffe3d60701f --- /dev/null +++ b/itests/ejb/src/test/java/org/apache/tomee/itests/ejb/MessageResource.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tomee.itests.ejb; + +import jakarta.ejb.EJB; +import jakarta.ejb.Lock; +import jakarta.ejb.LockType; +import jakarta.ejb.Singleton; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; + +@Singleton +@Lock(LockType.READ) +@Path("api/messages") +public class MessageResource { + + @EJB + private MessageCounter counter; + + @EJB + private MessageSender sender; + + @GET + @Path("count") + @Produces(MediaType.TEXT_PLAIN) + public Response count() { + return Response.ok(counter.getCount()).build(); + } + + @GET + @Path("test") + public void sendTestMessages() { + sender.sendMessage(); + } + +} diff --git a/itests/ejb/src/test/java/org/apache/tomee/itests/ejb/MessageSender.java b/itests/ejb/src/test/java/org/apache/tomee/itests/ejb/MessageSender.java new file mode 100644 index 00000000000..bc699b2d8c7 --- /dev/null +++ b/itests/ejb/src/test/java/org/apache/tomee/itests/ejb/MessageSender.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tomee.itests.ejb; + +import jakarta.annotation.Resource; +import jakarta.ejb.Lock; +import jakarta.ejb.LockType; +import jakarta.ejb.Singleton; +import jakarta.inject.Inject; +import jakarta.jms.ConnectionFactory; +import jakarta.jms.JMSContext; +import jakarta.jms.Topic; +import java.util.concurrent.atomic.AtomicInteger; + +@Singleton +@Lock(LockType.READ) +public class MessageSender { + + @Resource + private ConnectionFactory cf; + + @Inject + private JMSContext jmsContext; + + @Resource(name = "target") + private Topic eventTopic; + + + public void sendMessage() { + final String message = "hello world"; + for (int i = 0; i < 1000; i++) { + sendMessage(eventTopic, message); + } + } + + private void sendMessage(final Topic topic, final String message) { + jmsContext.createProducer().send(topic, jmsContext.createTextMessage(message)); + } + +} diff --git a/itests/ejb/src/test/java/org/apache/tomee/itests/ejb/MultiTomEETopicSubscriberTest.java b/itests/ejb/src/test/java/org/apache/tomee/itests/ejb/MultiTomEETopicSubscriberTest.java new file mode 100644 index 00000000000..bb9520e04a8 --- /dev/null +++ b/itests/ejb/src/test/java/org/apache/tomee/itests/ejb/MultiTomEETopicSubscriberTest.java @@ -0,0 +1,115 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tomee.itests.ejb; + +import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.broker.TransportConnector; +import org.apache.tomee.server.composer.Archive; +import org.apache.tomee.server.composer.TomEE; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.tomitribe.util.Files; +import org.tomitribe.util.IO; + +import jakarta.jms.ConnectionFactory; +import java.io.File; +import java.io.IOException; +import java.net.URL; + +public class MultiTomEETopicSubscriberTest { + + private BrokerService broker; + + @Before + public void setUp() throws Exception { + // start an ActiveMQ broker + broker = new BrokerService(); + broker.setPersistent(false); + broker.setUseJmx(true); + broker.addConnector("tcp://localhost:0"); // pick a random available port + + broker.start(); + } + + @After + public void tearDown() throws Exception { + broker.stop(); + } + + @Test + public void test() throws Exception { + // get the ActiveMQ OpenWire port + final TransportConnector tc = broker.getTransportConnectors().iterator().next(); + final int port = tc.getConnectUri().getPort(); + + // start 2 TomEE servers + final TomEE tomee1 = buildTomEE(port); + final TomEE tomee2 = buildTomEE(port); + + // the key thing here is that both of these servers should be able to subscribe to the topic + // from their respective MDBs without exceptions. + + // lets send some test messages from 1 of the servers + IO.slurp(new URL("http://localhost:" + tomee1.getPort() + "/test/api/messages/test")); + Thread.sleep(5000); + + // and check that all the messages were received on both servers + final String result1 = IO.slurp(new URL("http://localhost:" + tomee1.getPort() + "/test/api/messages/count")); + final String result2 = IO.slurp(new URL("http://localhost:" + tomee2.getPort() + "/test/api/messages/count")); + + Assert.assertEquals(1000, Integer.parseInt(result1)); + Assert.assertEquals(1000, Integer.parseInt(result2)); + } + + private TomEE buildTomEE(final int activemqPort) throws Exception { + return TomEE.plus() + .add("webapps/test/WEB-INF/lib/app.jar", Archive.archive() + .add(MessageCounter.class) + .add(MessageReceiver.class) + .add(MessageResource.class) + .add(MessageSender.class) + .asJar()) + .home(h -> updateSystemProperties(h, activemqPort)) + .build(); + } + + private void updateSystemProperties(final File home, final int activemqPort) { + try { + final File systemProps = Files.file(home, "conf", "system.properties"); + String props = IO.slurp(systemProps); + + props = props + "\namq=new://Resource?type=ActiveMQResourceAdapter" + + "\namq.DataSource=" + + "\namq.BrokerXmlConfig=" + + "\namq.ServerUrl=tcp://localhost:" + activemqPort + + "\ntarget=new://Resource?type=Topic" + + "\nmdbs=new://Container?type=MESSAGE" + + "\nmdbs.ResourceAdapter=amq" + + "\nmdbs.pool=false" + + "\ncf=new://Resource?type=" + ConnectionFactory.class.getName() + + "\ncf.ResourceAdapter=amq" + + "\nmdb.activation.clientId={ejbName}-{uniqueId}"; + + IO.copy(IO.read(props), systemProps); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + +} \ No newline at end of file diff --git a/itests/itest-common/pom.xml b/itests/itest-common/pom.xml index cf3121d9be4..1869b5e9fb0 100644 --- a/itests/itest-common/pom.xml +++ b/itests/itest-common/pom.xml @@ -62,4 +62,3 @@ - diff --git a/itests/pom.xml b/itests/pom.xml index 534a846c389..e6a2f930375 100644 --- a/itests/pom.xml +++ b/itests/pom.xml @@ -47,6 +47,7 @@ openejb-itests-servlets openejb-itests-web jaxrs + ejb itest-common itest-util tomee-security-itests From a7ebec3cfb589ad948a646a1c739317eb2321f72 Mon Sep 17 00:00:00 2001 From: Jonathan Gallimore Date: Wed, 10 Jan 2024 23:01:18 +0000 Subject: [PATCH 23/36] TOMEE-3902 missed on last commit --- itests/ejb/pom.xml | 90 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 itests/ejb/pom.xml diff --git a/itests/ejb/pom.xml b/itests/ejb/pom.xml new file mode 100644 index 00000000000..cd7602c2f9e --- /dev/null +++ b/itests/ejb/pom.xml @@ -0,0 +1,90 @@ + + + + + 4.0.0 + + + itests + org.apache.tomee + 9.1.3-SNAPSHOT + + + org.apache.tomee.itests + ejb + jar + TomEE :: iTests :: EJB + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + ${project.version} + + + + + + + + + org.apache.tomee + tomee-server-composer + ${project.version} + + + org.apache.tomee + apache-tomee + ${project.version} + tar.gz + microprofile + + + * + * + + + + + org.apache.tomee.bom + tomee-webprofile-api + ${project.version} + provided + + + org.apache.tomee + openejb-client + ${project.version} + provided + + + org.apache.activemq + activemq-broker + ${version.activemq} + test + + + junit + junit + + + From 76e2be8aea8531749af1cb05ca89eeba3486c07c Mon Sep 17 00:00:00 2001 From: Thomas Andraschko Date: Mon, 15 Jan 2024 17:59:03 +0100 Subject: [PATCH 24/36] Fixed version and build --- itests/ejb/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/itests/ejb/pom.xml b/itests/ejb/pom.xml index cd7602c2f9e..c3fa3fd254a 100644 --- a/itests/ejb/pom.xml +++ b/itests/ejb/pom.xml @@ -23,7 +23,7 @@ itests org.apache.tomee - 9.1.3-SNAPSHOT + 10.0.0-M1-SNAPSHOT org.apache.tomee.itests From be59561ccbb2b7451530164899f795154dfc927b Mon Sep 17 00:00:00 2001 From: Thomas Andraschko Date: Mon, 15 Jan 2024 18:30:22 +0100 Subject: [PATCH 25/36] Fixed exclusions (related to TOMEE-4294) (#1092) * Fixed exclusions (related to TOMEE-4294) * Fixed exclusions (related to TOMEE-4294) --- tomee/tomee-microprofile/mp-common/pom.xml | 30 ++++++++-------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/tomee/tomee-microprofile/mp-common/pom.xml b/tomee/tomee-microprofile/mp-common/pom.xml index e818ccc998d..fb4623153e2 100644 --- a/tomee/tomee-microprofile/mp-common/pom.xml +++ b/tomee/tomee-microprofile/mp-common/pom.xml @@ -149,10 +149,7 @@ org.eclipse.microprofile.health microprofile-health-api - - javax.inject - javax.inject - + @@ -180,10 +177,7 @@ org.eclipse.microprofile.rest.client microprofile-rest-client-api - - javax.inject - javax.inject - + @@ -235,6 +229,14 @@ io.smallrye smallrye-health + + jakarta.enterprise + jakarta.enterprise.cdi-api + + + jakarta.json + jakarta.json-api + * microprofile-health-api @@ -313,22 +315,10 @@ org.glassfish.jaxb jaxb-xjc - - javax.json - javax.json-api - - - javax.ws.rs - javax.ws.rs-api - jakarta.ws.rs jakarta.ws.rs-api - - javax.annotation - javax.annotation-api - jakarta.activation jakarta.activation-api From 728aab6c56081863b61ab362a5279575b4253b91 Mon Sep 17 00:00:00 2001 From: Thomas Andraschko Date: Tue, 16 Jan 2024 09:24:21 +0100 Subject: [PATCH 26/36] Improve failed startup follow-up exceptions and back to OWB snapshot (#1093) --- pom.xml | 2 +- .../tomee/microprofile/health/MPHealthCDIExtension.java | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 4d726ac80d6..729c2bc8a52 100644 --- a/pom.xml +++ b/pom.xml @@ -218,7 +218,7 @@ 2.0.0 4.0.1 4.0.0-SNAPSHOT - 4.0.1 + 4.0.2-SNAPSHOT 3.0.4 diff --git a/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/health/MPHealthCDIExtension.java b/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/health/MPHealthCDIExtension.java index f205a29dd9a..2151c72b08b 100644 --- a/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/health/MPHealthCDIExtension.java +++ b/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/health/MPHealthCDIExtension.java @@ -121,6 +121,11 @@ private void addHealthChecks( * Remove all the instances of {@link HealthCheck} from the {@link MicroProfileHealthReporter}. */ public void beforeShutdown(@Observes final BeforeShutdown bs) { + // in case when CDI startup failed + if (reporter == null) + { + return; + } removeHealthCheck(livenessChecks, reporter::removeLivenessCheck); removeHealthCheck(readinessChecks, reporter::removeReadinessCheck); removeHealthCheck(startupChecks, reporter::removeStartupCheck); @@ -182,4 +187,4 @@ public HealthCheckResponse call() { .build(); } } -} \ No newline at end of file +} From 5e223f95bcbb8ef7d6065ea511606e9e0e43fb85 Mon Sep 17 00:00:00 2001 From: Richard Zowalla Date: Tue, 16 Jan 2024 09:25:14 +0100 Subject: [PATCH 27/36] Re-enable test after https://github.com/apache/tomee/pull/1093 --- .../org/superbiz/moviefun/MoviesHtmlUnitTest.java | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/arquillian/arquillian-tomee-moviefun-example/src/test/java/org/superbiz/moviefun/MoviesHtmlUnitTest.java b/arquillian/arquillian-tomee-moviefun-example/src/test/java/org/superbiz/moviefun/MoviesHtmlUnitTest.java index 236d798a25d..33c9c56aa09 100644 --- a/arquillian/arquillian-tomee-moviefun-example/src/test/java/org/superbiz/moviefun/MoviesHtmlUnitTest.java +++ b/arquillian/arquillian-tomee-moviefun-example/src/test/java/org/superbiz/moviefun/MoviesHtmlUnitTest.java @@ -76,21 +76,6 @@ private static File createWebApp() throws IOException { } @Test - @Ignore("This test fails due to a change in OWB-4 to pass the TCK related to dotted EL names: " + - "https://github.com/apache/openwebbeans/commit/4e4962a69064585d146c71bb387a8395455e88b5" + - "Until this is fixed, we disable this test. Related stacktrace is added below.") - /* - jakarta.el.PropertyNotFoundException: The class 'org.apache.webbeans.el22.WrappedValueExpressionNode' does not have the property 'title'. - at jakarta.el.BeanELResolver.getBeanProperty(BeanELResolver.java:626) - at jakarta.el.BeanELResolver.getValue(BeanELResolver.java:338) - at org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:129) - at org.apache.el.parser.AstValue.getValue(AstValue.java:169) - at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:190) - at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:701) - at org.apache.jsp.WEB_002dINF.setup_jsp._jspx_meth_c_005fout_005f0(setup_jsp.java:247) - at org.apache.jsp.WEB_002dINF.setup_jsp._jspx_meth_c_005fforEach_005f0(setup_jsp.java:198) - at org.apache.jsp.WEB_002dINF.setup_jsp._jspService(setup_jsp.java:150) - */ public void testShouldMakeSureWebappIsWorking() throws Exception { WebClient webClient = new WebClient(); HtmlPage page = webClient.getPage("http://localhost:9999/moviefun/setup"); From 9eadc7e9280bcd70e42f0dd29fe8e2b8b122948d Mon Sep 17 00:00:00 2001 From: rzo1 Date: Tue, 16 Jan 2024 08:32:08 +0000 Subject: [PATCH 28/36] Minor: Regenerated BOMs for 5e223f95bcbb8ef7d6065ea511606e9e0e43fb85 Signed-off-by: GitHub --- boms/tomee-microprofile/pom.xml | 16 ++++++++-------- boms/tomee-plume/pom.xml | 16 ++++++++-------- boms/tomee-plus/pom.xml | 16 ++++++++-------- boms/tomee-webprofile/pom.xml | 16 ++++++++-------- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/boms/tomee-microprofile/pom.xml b/boms/tomee-microprofile/pom.xml index d05b32e6d2f..a6b93496e63 100644 --- a/boms/tomee-microprofile/pom.xml +++ b/boms/tomee-microprofile/pom.xml @@ -884,7 +884,7 @@ org.apache.openwebbeans openwebbeans-ee-common - 4.0.1 + 4.0.2-SNAPSHOT * @@ -895,7 +895,7 @@ org.apache.openwebbeans openwebbeans-ee - 4.0.1 + 4.0.2-SNAPSHOT * @@ -906,7 +906,7 @@ org.apache.openwebbeans openwebbeans-ejb - 4.0.1 + 4.0.2-SNAPSHOT * @@ -917,7 +917,7 @@ org.apache.openwebbeans openwebbeans-el22 - 4.0.1 + 4.0.2-SNAPSHOT * @@ -928,7 +928,7 @@ org.apache.openwebbeans openwebbeans-impl - 4.0.1 + 4.0.2-SNAPSHOT * @@ -939,7 +939,7 @@ org.apache.openwebbeans openwebbeans-jsf - 4.0.1 + 4.0.2-SNAPSHOT * @@ -950,7 +950,7 @@ org.apache.openwebbeans openwebbeans-spi - 4.0.1 + 4.0.2-SNAPSHOT * @@ -961,7 +961,7 @@ org.apache.openwebbeans openwebbeans-web - 4.0.1 + 4.0.2-SNAPSHOT * diff --git a/boms/tomee-plume/pom.xml b/boms/tomee-plume/pom.xml index 8f64bcf4f60..cfd3338217b 100644 --- a/boms/tomee-plume/pom.xml +++ b/boms/tomee-plume/pom.xml @@ -972,7 +972,7 @@ org.apache.openwebbeans openwebbeans-ee-common - 4.0.1 + 4.0.2-SNAPSHOT * @@ -983,7 +983,7 @@ org.apache.openwebbeans openwebbeans-ee - 4.0.1 + 4.0.2-SNAPSHOT * @@ -994,7 +994,7 @@ org.apache.openwebbeans openwebbeans-ejb - 4.0.1 + 4.0.2-SNAPSHOT * @@ -1005,7 +1005,7 @@ org.apache.openwebbeans openwebbeans-el22 - 4.0.1 + 4.0.2-SNAPSHOT * @@ -1016,7 +1016,7 @@ org.apache.openwebbeans openwebbeans-impl - 4.0.1 + 4.0.2-SNAPSHOT * @@ -1027,7 +1027,7 @@ org.apache.openwebbeans openwebbeans-jsf - 4.0.1 + 4.0.2-SNAPSHOT * @@ -1038,7 +1038,7 @@ org.apache.openwebbeans openwebbeans-spi - 4.0.1 + 4.0.2-SNAPSHOT * @@ -1049,7 +1049,7 @@ org.apache.openwebbeans openwebbeans-web - 4.0.1 + 4.0.2-SNAPSHOT * diff --git a/boms/tomee-plus/pom.xml b/boms/tomee-plus/pom.xml index 6230bb0e3c1..17d417d6ef3 100644 --- a/boms/tomee-plus/pom.xml +++ b/boms/tomee-plus/pom.xml @@ -994,7 +994,7 @@ org.apache.openwebbeans openwebbeans-ee-common - 4.0.1 + 4.0.2-SNAPSHOT * @@ -1005,7 +1005,7 @@ org.apache.openwebbeans openwebbeans-ee - 4.0.1 + 4.0.2-SNAPSHOT * @@ -1016,7 +1016,7 @@ org.apache.openwebbeans openwebbeans-ejb - 4.0.1 + 4.0.2-SNAPSHOT * @@ -1027,7 +1027,7 @@ org.apache.openwebbeans openwebbeans-el22 - 4.0.1 + 4.0.2-SNAPSHOT * @@ -1038,7 +1038,7 @@ org.apache.openwebbeans openwebbeans-impl - 4.0.1 + 4.0.2-SNAPSHOT * @@ -1049,7 +1049,7 @@ org.apache.openwebbeans openwebbeans-jsf - 4.0.1 + 4.0.2-SNAPSHOT * @@ -1060,7 +1060,7 @@ org.apache.openwebbeans openwebbeans-spi - 4.0.1 + 4.0.2-SNAPSHOT * @@ -1071,7 +1071,7 @@ org.apache.openwebbeans openwebbeans-web - 4.0.1 + 4.0.2-SNAPSHOT * diff --git a/boms/tomee-webprofile/pom.xml b/boms/tomee-webprofile/pom.xml index f797d716379..27be0bde924 100644 --- a/boms/tomee-webprofile/pom.xml +++ b/boms/tomee-webprofile/pom.xml @@ -532,7 +532,7 @@ org.apache.openwebbeans openwebbeans-ee-common - 4.0.1 + 4.0.2-SNAPSHOT * @@ -543,7 +543,7 @@ org.apache.openwebbeans openwebbeans-ee - 4.0.1 + 4.0.2-SNAPSHOT * @@ -554,7 +554,7 @@ org.apache.openwebbeans openwebbeans-ejb - 4.0.1 + 4.0.2-SNAPSHOT * @@ -565,7 +565,7 @@ org.apache.openwebbeans openwebbeans-el22 - 4.0.1 + 4.0.2-SNAPSHOT * @@ -576,7 +576,7 @@ org.apache.openwebbeans openwebbeans-impl - 4.0.1 + 4.0.2-SNAPSHOT * @@ -587,7 +587,7 @@ org.apache.openwebbeans openwebbeans-jsf - 4.0.1 + 4.0.2-SNAPSHOT * @@ -598,7 +598,7 @@ org.apache.openwebbeans openwebbeans-spi - 4.0.1 + 4.0.2-SNAPSHOT * @@ -609,7 +609,7 @@ org.apache.openwebbeans openwebbeans-web - 4.0.1 + 4.0.2-SNAPSHOT * From c80e1918904e5abd2b67337c72490a926f4d36c6 Mon Sep 17 00:00:00 2001 From: Thomas Andraschko Date: Tue, 16 Jan 2024 13:06:32 +0100 Subject: [PATCH 29/36] Fixed dependency exclusions + enhanced logging (#1095) --- .../ReloadableEntityManagerFactory.java | 4 + pom.xml | 101 ++++++++++++++---- tomee/pom.xml | 38 ++++++- 3 files changed, 121 insertions(+), 22 deletions(-) diff --git a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ReloadableEntityManagerFactory.java b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ReloadableEntityManagerFactory.java index dbf809b3a88..f3701f6a921 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ReloadableEntityManagerFactory.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ReloadableEntityManagerFactory.java @@ -162,6 +162,10 @@ public EntityManager createEntityManager() { try { em = delegate().createEntityManager(); } catch (final LinkageError le) { + if (delegate == null) { + LOGGER.error("Could not initialize EntityManagerFactory delegate", le); + throw le; // it's already a OpenEJBRuntimeException + } em = delegate.createEntityManager(); } diff --git a/pom.xml b/pom.xml index 729c2bc8a52..3df5e305c48 100644 --- a/pom.xml +++ b/pom.xml @@ -224,7 +224,7 @@ 4.0.1 - 6.3.1.Final + 6.4.1.Final 7.0.5.Final @@ -1455,6 +1455,10 @@ org.apache.activemq activemq-broker + + jakarta.jms + jakarta.jms-api + @@ -1483,8 +1487,12 @@ ${version.geronimo.components} - org.apache.geronimo.specs - * + jakarta.resource + jakarta.resource-api + + + jakarta.validation + jakarta.validation-api org.objectweb.howl @@ -1498,8 +1506,12 @@ ${version.geronimo.components} - org.apache.geronimo.specs - * + jakarta.resource + jakarta.resource-api + + + jakarta.transaction + jakarta.transaction-api org.objectweb.howl @@ -1532,6 +1544,24 @@ org.apache.openjpa openjpa ${version.openjpa} + + + jakarta.jms + jakarta.jms-api + + + jakarta.persistence + jakarta.persistence-api + + + jakarta.annotation + jakarta.annotation-api + + + jakarta.transaction + jakarta.transaction-api + + @@ -1780,6 +1810,14 @@ org.apache.xbean xbean-finder-shaded + + jakarta.enterprise + jakarta.enterprise.cdi-api + + + jakarta.inject + jakarta.inject-api + @@ -1793,8 +1831,8 @@ ${version.openwebbeans} - org.apache.geronimo.specs - * + jakarta.enterprise + jakarta.enterprise.cdi-api @@ -1803,24 +1841,29 @@ openwebbeans-ejb ${version.openwebbeans} - - org.apache.geronimo.specs - * - + org.apache.openwebbeans openwebbeans-ee ${version.openwebbeans} - + - org.apache.geronimo.specs - geronimo-el_2.2_spec + jakarta.el + jakarta.el-api - org.apache.geronimo.specs - * + jakarta.enterprise + jakarta.enterprise.cdi-api + + + jakarta.inject + jakarta.inject-api + + + jakarta.transaction + jakarta.transaction-api @@ -1833,12 +1876,30 @@ org.apache.xbean xbean-finder-shaded + + jakarta.enterprise + jakarta.enterprise.cdi-api + + + jakarta.inject + jakarta.inject-api + org.apache.openwebbeans openwebbeans-el22 ${version.openwebbeans} + + + jakarta.inject + jakarta.inject-api + + + jakarta.enterprise + jakarta.enterprise.cdi-api + + openwebbeans-ee-common @@ -1846,12 +1907,12 @@ ${version.openwebbeans} - org.apache.geronimo.specs - geronimo-atinject_1.0_spec + jakarta.enterprise + jakarta.enterprise.cdi-api - org.apache.geronimo.specs - * + jakarta.inject + jakarta.inject-api diff --git a/tomee/pom.xml b/tomee/pom.xml index 24456665731..6ce1ef27b64 100644 --- a/tomee/pom.xml +++ b/tomee/pom.xml @@ -222,6 +222,18 @@ org.apache.geronimo.specs * + + org.apache.tomcat + * + + + jakarta.enterprise + jakarta.enterprise.cdi-api + + + jakarta.inject + jakarta.inject-api + @@ -231,16 +243,32 @@ org.apache.geronimo.specs - geronimo-jcdi_1.0_spec + * - org.apache.geronimo.specs + org.apache.tomcat * commons-beanutils commons-beanutils + + jakarta.validation + jakarta.validation-api + + + jakarta.annotation + jakarta.annotation-api + + + jakarta.enterprise + jakarta.enterprise.cdi-api + + + jakarta.inject + jakarta.inject-api + @@ -308,6 +336,12 @@ org.glassfish jakarta.faces ${version.mojarra} + + + jakarta.annotation + jakarta.annotation-api + + ${project.groupId} From 16e85fadb5640d5286f742cc576cb6a2a550922f Mon Sep 17 00:00:00 2001 From: Thomas Andraschko Date: Tue, 16 Jan 2024 15:38:45 +0100 Subject: [PATCH 30/36] use MyFaces SNAPSHOT for now (#1098) * Fixed exclusions (related to TOMEE-4294) * Fixed exclusions (related to TOMEE-4294) * Avoid NPE during cancelled startup * Back to OWB SNAPSHOT * style * Fixed swalloped exception * Updaded Hibernate + fixed exclusions (geronimo -> jakarta) * Updated exclusions (geronimo -> jakarta) * rollback * rollback * Use MyFaces SNAPSHOT --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3df5e305c48..4cadee3b949 100644 --- a/pom.xml +++ b/pom.xml @@ -216,7 +216,7 @@ 1.0.0 2.0.0 - 4.0.1 + 4.0.2-SNAPSHOT 4.0.0-SNAPSHOT 4.0.2-SNAPSHOT From ebc0521cfd2af7baa4ae160d010acea3d2435d96 Mon Sep 17 00:00:00 2001 From: rzo1 Date: Tue, 16 Jan 2024 14:46:07 +0000 Subject: [PATCH 31/36] Minor: Regenerated BOMs for 16e85fadb5640d5286f742cc576cb6a2a550922f Signed-off-by: GitHub --- boms/tomee-microprofile-api/pom.xml | 2 +- boms/tomee-microprofile/pom.xml | 4 ++-- boms/tomee-plus-api/pom.xml | 2 +- boms/tomee-plus/pom.xml | 4 ++-- boms/tomee-webprofile-api/pom.xml | 2 +- boms/tomee-webprofile/pom.xml | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/boms/tomee-microprofile-api/pom.xml b/boms/tomee-microprofile-api/pom.xml index 735c6925e0d..82e8f211811 100644 --- a/boms/tomee-microprofile-api/pom.xml +++ b/boms/tomee-microprofile-api/pom.xml @@ -65,7 +65,7 @@ org.apache.myfaces.core myfaces-api - 4.0.1 + 4.0.2-SNAPSHOT * diff --git a/boms/tomee-microprofile/pom.xml b/boms/tomee-microprofile/pom.xml index a6b93496e63..912418f6069 100644 --- a/boms/tomee-microprofile/pom.xml +++ b/boms/tomee-microprofile/pom.xml @@ -829,7 +829,7 @@ org.apache.myfaces.core myfaces-api - 4.0.1 + 4.0.2-SNAPSHOT * @@ -840,7 +840,7 @@ org.apache.myfaces.core myfaces-impl - 4.0.1 + 4.0.2-SNAPSHOT * diff --git a/boms/tomee-plus-api/pom.xml b/boms/tomee-plus-api/pom.xml index abfd5142642..972aea21ec5 100644 --- a/boms/tomee-plus-api/pom.xml +++ b/boms/tomee-plus-api/pom.xml @@ -76,7 +76,7 @@ org.apache.myfaces.core myfaces-api - 4.0.1 + 4.0.2-SNAPSHOT * diff --git a/boms/tomee-plus/pom.xml b/boms/tomee-plus/pom.xml index 17d417d6ef3..03ab63e9808 100644 --- a/boms/tomee-plus/pom.xml +++ b/boms/tomee-plus/pom.xml @@ -939,7 +939,7 @@ org.apache.myfaces.core myfaces-api - 4.0.1 + 4.0.2-SNAPSHOT * @@ -950,7 +950,7 @@ org.apache.myfaces.core myfaces-impl - 4.0.1 + 4.0.2-SNAPSHOT * diff --git a/boms/tomee-webprofile-api/pom.xml b/boms/tomee-webprofile-api/pom.xml index 446323b1b8a..7d5e4b0d716 100644 --- a/boms/tomee-webprofile-api/pom.xml +++ b/boms/tomee-webprofile-api/pom.xml @@ -54,7 +54,7 @@ org.apache.myfaces.core myfaces-api - 4.0.1 + 4.0.2-SNAPSHOT * diff --git a/boms/tomee-webprofile/pom.xml b/boms/tomee-webprofile/pom.xml index 27be0bde924..a18fc4eb1a1 100644 --- a/boms/tomee-webprofile/pom.xml +++ b/boms/tomee-webprofile/pom.xml @@ -477,7 +477,7 @@ org.apache.myfaces.core myfaces-api - 4.0.1 + 4.0.2-SNAPSHOT * @@ -488,7 +488,7 @@ org.apache.myfaces.core myfaces-impl - 4.0.1 + 4.0.2-SNAPSHOT * From 03139fcb74d2a6222e2ef4eec9dc1d610239c58f Mon Sep 17 00:00:00 2001 From: Thomas Andraschko Date: Wed, 17 Jan 2024 10:23:04 +0100 Subject: [PATCH 32/36] small faces cleanup --- .../openejb/config/AnnotationDeployer.java | 30 ------------------- 1 file changed, 30 deletions(-) diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java b/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java index 1f5beda408c..750890f8a2e 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java @@ -56,8 +56,6 @@ import org.apache.openejb.jee.EnterpriseBean; import org.apache.openejb.jee.EnvEntry; import org.apache.openejb.jee.ExcludeList; -import org.apache.openejb.jee.FacesConfig; -import org.apache.openejb.jee.FacesManagedBean; import org.apache.openejb.jee.Filter; import org.apache.openejb.jee.Handler; import org.apache.openejb.jee.HandlerChains; @@ -288,15 +286,6 @@ public class AnnotationDeployer implements DynamicDeployer { private static final String[] JSF_CLASSES = new String[]{ "jakarta.faces.application.ResourceDependencies", "jakarta.faces.application.ResourceDependency", - "jakarta.faces.bean.ApplicationScoped", - "jakarta.faces.bean.CustomScoped", - "jakarta.faces.bean.ManagedBean", - "jakarta.faces.bean.ManagedProperty", - "jakarta.faces.bean.NoneScoped", - "jakarta.faces.bean.ReferencedBean", - "jakarta.faces.bean.RequestScoped", - "jakarta.faces.bean.SessionScoped", - "jakarta.faces.bean.ViewScoped", "jakarta.faces.component.FacesComponent", "jakarta.faces.component.UIComponent", "jakarta.faces.convert.Converter", @@ -2432,25 +2421,6 @@ public WebModule deploy(final WebModule webModule) throws OpenEJBException { } } - /* - * JSF ManagedBean classes are scanned - */ - for (final FacesConfig facesConfig : webModule.getFacesConfigs()) { - for (final FacesManagedBean bean : facesConfig.getManagedBean()) { - final String managedBeanClass = realClassName(bean.getManagedBeanClass().trim()); - if (managedBeanClass != null) { - try { - final Class clazz = classLoader.loadClass(managedBeanClass); - classes.add(clazz); - } catch (final ClassNotFoundException | NoClassDefFoundError e) { - logger.debug("Could not load Faces managed bean class {1} for web module {2} / {3}", - managedBeanClass, webModule.getJarLocation(), webModule.getFile().getName()); - logger.error("Unable to load JSF managed bean class: " + managedBeanClass); - } - } - } - } - final IAnnotationFinder finder = webModule.getFinder(); if (finder != null) { From 035d38623b3455a54b09ca5c33b9aa872d16abaa Mon Sep 17 00:00:00 2001 From: Thomas Andraschko Date: Thu, 18 Jan 2024 09:20:21 +0100 Subject: [PATCH 33/36] also removed JSF ManagedBeans from tests (#1101) * small faces cleanup * removed JSF ManagedBeans also in XML parser test --- .../org/apache/openejb/jee/jsf/JsfTest.java | 30 ------------------- 1 file changed, 30 deletions(-) diff --git a/container/openejb-jee/src/test/java/org/apache/openejb/jee/jsf/JsfTest.java b/container/openejb-jee/src/test/java/org/apache/openejb/jee/jsf/JsfTest.java index 09663c8c1e0..00d2b8b4d4c 100644 --- a/container/openejb-jee/src/test/java/org/apache/openejb/jee/jsf/JsfTest.java +++ b/container/openejb-jee/src/test/java/org/apache/openejb/jee/jsf/JsfTest.java @@ -22,13 +22,6 @@ import junit.framework.TestCase; import org.apache.openejb.jee.FacesConfig; -import org.apache.openejb.jee.FacesManagedBean; -import org.apache.openejb.jee.JaxbJavaee; - -import jakarta.xml.bind.JAXBElement; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; import static org.apache.openejb.jee.JeeTest.marshalAndUnmarshal; @@ -37,29 +30,6 @@ */ public class JsfTest extends TestCase { - /** - * This test requires that there are three managed beans in faces-config.xml. It will ask JaxbJavaee to load faces-config.xml - * and then assert if it found the three managed beans and checks if the class names are correct - * - * @throws Exception - */ - public void testFacesConfig() throws Exception { - final List managedBeanClasses = new ArrayList(); - managedBeanClasses.add("org.apache.openejb.faces.EmployeeBean"); - managedBeanClasses.add("org.apache.openejb.faces.OneBean"); - managedBeanClasses.add("org.apache.openejb.faces.TwoBean"); - final InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("jsf/faces-config.xml"); - final FacesConfig facesConfig = (FacesConfig) JaxbJavaee.unmarshalJavaee(FacesConfig.class, inputStream); - final List managedBean = facesConfig.getManagedBean(); - - for (final FacesManagedBean bean : managedBean) { - assertTrue(managedBeanClasses.contains(bean.getManagedBeanClass().trim())); - } - assertEquals(3, managedBean.size()); - - marshalAndUnmarshal(FacesConfig.class, "jsf/faces-config.xml", null); - } - public void test10() throws Exception { marshalAndUnmarshal(FacesConfig.class, "jsf/1_0_dtd/faces-config-simple-src.xml", "jsf/1_0_dtd/faces-config-simple-expected.xml"); marshalAndUnmarshal(FacesConfig.class, "jsf/1_0_dtd/faces-config-moderate-src.xml", "jsf/1_0_dtd/faces-config-moderate-expected.xml"); From 52710e8d983cb56833fbcae301aea78d2e430425 Mon Sep 17 00:00:00 2001 From: Richard Zowalla Date: Fri, 19 Jan 2024 08:33:17 +0100 Subject: [PATCH 34/36] Fix failing arquillian test after EL expressions were fixed in OWB SNAPSHOT and test was re-enabled. --- arquillian/arquillian-tomee-moviefun-example/pom.xml | 11 +++++------ .../org/superbiz/moviefun/MoviesHtmlUnitTest.java | 5 +++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/arquillian/arquillian-tomee-moviefun-example/pom.xml b/arquillian/arquillian-tomee-moviefun-example/pom.xml index 67d518cc450..fcd9cc461a6 100644 --- a/arquillian/arquillian-tomee-moviefun-example/pom.xml +++ b/arquillian/arquillian-tomee-moviefun-example/pom.xml @@ -24,8 +24,8 @@ TomEE :: Arquillian Adaptors Parent :: Sample :: Moviefun - 2.40.0 - 1.3.0.Final + 2.53.1 + 1.3.1.Final @@ -81,12 +81,12 @@ org.apache.myfaces.core myfaces-api - 4.0.1 + ${version.myfaces} org.apache.tomee taglibs-shade - 10.0.0-M1-SNAPSHOT + ${project.version} @@ -121,7 +121,6 @@ org.apache.tomee taglibs-shade - 10.0.0-M1-SNAPSHOT junit @@ -258,7 +257,7 @@ net.sourceforge.htmlunit htmlunit - 2.12 + 2.70.0 jar test diff --git a/arquillian/arquillian-tomee-moviefun-example/src/test/java/org/superbiz/moviefun/MoviesHtmlUnitTest.java b/arquillian/arquillian-tomee-moviefun-example/src/test/java/org/superbiz/moviefun/MoviesHtmlUnitTest.java index 33c9c56aa09..68d81782243 100644 --- a/arquillian/arquillian-tomee-moviefun-example/src/test/java/org/superbiz/moviefun/MoviesHtmlUnitTest.java +++ b/arquillian/arquillian-tomee-moviefun-example/src/test/java/org/superbiz/moviefun/MoviesHtmlUnitTest.java @@ -78,6 +78,7 @@ private static File createWebApp() throws IOException { @Test public void testShouldMakeSureWebappIsWorking() throws Exception { WebClient webClient = new WebClient(); + webClient.getOptions().setThrowExceptionOnScriptError(false); HtmlPage page = webClient.getPage("http://localhost:9999/moviefun/setup"); assertMoviesPresent(page); @@ -90,11 +91,11 @@ public void testShouldMakeSureWebappIsWorking() throws Exception { } assertMoviesPresent(page); - webClient.closeAllWindows(); + webClient.close(); } private void assertMoviesPresent(HtmlPage page) { - String pageAsText = page.asText(); + String pageAsText = page.asNormalizedText(); assertTrue(pageAsText.contains("Wedding Crashers")); assertTrue(pageAsText.contains("Starsky & Hutch")); assertTrue(pageAsText.contains("Shanghai Knights")); From d1b7edd22de85a1f57235de55539f97d8d17e37f Mon Sep 17 00:00:00 2001 From: Richard Zowalla Date: Fri, 19 Jan 2024 08:41:00 +0100 Subject: [PATCH 35/36] Remove jetty dependency, which isn't avaialble in that version anymore (not needed anyway) --- pom.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pom.xml b/pom.xml index 4cadee3b949..8cb0013bcee 100644 --- a/pom.xml +++ b/pom.xml @@ -1140,11 +1140,6 @@ jetty-server ${version.jetty} - - org.eclipse.jetty - jetty-continuation - ${version.jetty} - org.eclipse.jetty jetty-jsp-2.1 From 6b385205a330778c06877226a1c3ab809ff096f9 Mon Sep 17 00:00:00 2001 From: Richard Zowalla Date: Fri, 19 Jan 2024 08:50:51 +0100 Subject: [PATCH 36/36] Fix signature tests --- tck/bval-signature-test/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tck/bval-signature-test/pom.xml b/tck/bval-signature-test/pom.xml index 339461b592b..d64f7b0acee 100644 --- a/tck/bval-signature-test/pom.xml +++ b/tck/bval-signature-test/pom.xml @@ -112,7 +112,7 @@ org.netbeans.tools sigtest-maven-plugin - 1.0 + 1.5