From e2805a0528232d8744c97e5a51fa9a64ef3a2a46 Mon Sep 17 00:00:00 2001 From: "Erdle, Tobias" Date: Mon, 12 Apr 2021 21:01:11 +0200 Subject: [PATCH 1/7] Remove CXF module from project Signed-off-by: Erdle, Tobias --- cxf/pom.xml | 118 ------------------ .../http/CXFHttpCommunicationUnwrapper.java | 65 ---------- ...ipse.krazo.core.HttpCommunicationUnwrapper | 1 - pom.xml | 1 - 4 files changed, 185 deletions(-) delete mode 100644 cxf/pom.xml delete mode 100644 cxf/src/main/java/org/eclipse/krazo/cxf/http/CXFHttpCommunicationUnwrapper.java delete mode 100644 cxf/src/main/resources/META-INF/services/org.eclipse.krazo.core.HttpCommunicationUnwrapper diff --git a/cxf/pom.xml b/cxf/pom.xml deleted file mode 100644 index e3a68989..00000000 --- a/cxf/pom.xml +++ /dev/null @@ -1,118 +0,0 @@ - - - - 4.0.0 - - - org.eclipse.krazo - krazo-parent - 2.1.0-SNAPSHOT - - - krazo-cxf - Eclipse Krazo CXF - - - 3.4.1 - - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - - - - org.apache.felix - maven-bundle-plugin - true - - - bundle-manifest - process-classes - - manifest - - - - - - org.eclipse.krazo.cxf - org.eclipse.krazo.cxf.* - - - - - - - - - - - - jakarta.mvc - jakarta.mvc-api - ${spec.version} - compile - - - - - org.eclipse.krazo - krazo-core - ${project.version} - compile - - - - - org.apache.cxf - cxf-rt-frontend-jaxrs - ${cxf.version} - provided - - - - - jakarta.servlet - jakarta.servlet-api - 5.0.0 - provided - - - - jakarta.annotation - jakarta.annotation-api - 2.0.0 - provided - - - - - diff --git a/cxf/src/main/java/org/eclipse/krazo/cxf/http/CXFHttpCommunicationUnwrapper.java b/cxf/src/main/java/org/eclipse/krazo/cxf/http/CXFHttpCommunicationUnwrapper.java deleted file mode 100644 index 93c86187..00000000 --- a/cxf/src/main/java/org/eclipse/krazo/cxf/http/CXFHttpCommunicationUnwrapper.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2020 Eclipse Krazo committers and contributors - * - * Licensed 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. - * - * SPDX-License-Identifier: Apache-2.0 - */ - -package org.eclipse.krazo.cxf.http; - -import org.eclipse.krazo.core.HttpCommunicationUnwrapper; - -import jakarta.annotation.Priority; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; -import java.lang.reflect.InvocationTargetException; - -/** - * Unwrapper for CXF which extracts the original {@link HttpServletRequest} and / or {@link HttpServletResponse} - * from the wrapper which are used e.g. by Liberty. This is required because the wrappers don't use the official wrapper base classes - * and therefore Liberty fails to forward such requests because unwrapping isn't possible. - *

- * Instances of this class are put directly before the {@link org.eclipse.krazo.core.DefaultHttpCommunicationUnwrapper} to ensure, that - * they are executed before user created ones. - */ -@Priority(1) -public class CXFHttpCommunicationUnwrapper implements HttpCommunicationUnwrapper { - - @Override - public boolean supports(final Object obj) { - final String implName = obj.getClass().getName(); - return implName.equals("org.apache.cxf.jaxrs.impl.tl.ThreadLocalHttpServletRequest") - || implName.equals("org.apache.cxf.jaxrs.impl.tl.ThreadLocalHttpServletResponse"); - } - - @Override - public HttpServletRequest unwrapRequest(final HttpServletRequest obj, final Class type) { - return unwrap(obj, type); - } - - @Override - public HttpServletResponse unwrapResponse(final HttpServletResponse obj, final Class type) { - return unwrap(obj, type); - } - - private T unwrap(final T obj, final Class type) { - try { - return type.cast( - obj.getClass().getMethod("get").invoke(obj) - ); - } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { - throw new IllegalStateException("Failed to unwrap", e); - } - } -} diff --git a/cxf/src/main/resources/META-INF/services/org.eclipse.krazo.core.HttpCommunicationUnwrapper b/cxf/src/main/resources/META-INF/services/org.eclipse.krazo.core.HttpCommunicationUnwrapper deleted file mode 100644 index 581a989c..00000000 --- a/cxf/src/main/resources/META-INF/services/org.eclipse.krazo.core.HttpCommunicationUnwrapper +++ /dev/null @@ -1 +0,0 @@ -org.eclipse.krazo.cxf.http.CXFHttpCommunicationUnwrapper diff --git a/pom.xml b/pom.xml index c18f89cd..df41a417 100644 --- a/pom.xml +++ b/pom.xml @@ -56,7 +56,6 @@ core jersey resteasy - cxf tck ext examples From 3a9f93a8ac964147e557727ec79ad42a26e13c9b Mon Sep 17 00:00:00 2001 From: "Erdle, Tobias" Date: Mon, 12 Apr 2021 21:14:58 +0200 Subject: [PATCH 2/7] Document CXF removal and remove it as supported Signed-off-by: Erdle, Tobias --- CONTRIBUTING.md | 2 +- README.md | 24 +----- documentation/src/main/asciidoc/_intro.adoc | 2 +- .../src/main/asciidoc/_quickstart.adoc | 84 +++++++------------ 4 files changed, 32 insertions(+), 80 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6ae5b3a3..49d1fba3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,7 +5,7 @@ Thanks for your interest in this project. ## Project description Eclipse Krazo is an implementation of action-based MVC specifiec by MVC 1.0 (JSR-371). -It builds on top of JAX-RS and currently contains support for RESTEasy, Jersey and CXF +It builds on top of JAX-RS and currently contains support for RESTEasy and Jersey with a well-defined SPI for other implementations. ## Developer resources diff --git a/README.md b/README.md index c5b72da2..81a96a29 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ # Eclipse Krazo Eclipse Krazo is an implementation of action-based MVC specified by Jakarta MVC 2.0. It builds on top of Jakarta RESTful Webservices -and currently contains support for RESTEasy, Jersey and CXF with a well-defined SPI for other implementations. +and currently contains support for RESTEasy and Jersey with a well-defined SPI for other implementations. ## Running the testsuite @@ -12,8 +12,6 @@ The following sections describe how you test Eclipse Krazo against them. At the - Glassfish 8 - WildFly 22.x.x -- TomEE 10.x -- OpenLiberty 20.0.0.12 ### Preconditions - JDK 11 @@ -33,26 +31,6 @@ To run the Krazo testsuite with WildFly, you need to follow these steps: 2. Start WildFly with `sh standalone.sh --debug`. This enables you to remote-debug the Arquillian tests. 3. Go into the `testsuite` package of Eclipse Krazo and execute `mvn clean integration-test -Ptestsuite-wildfly` -### TomEE -To run the Krazo testsuite with TomEE, you need to follow these steps: -1. Download TomEE from the TomEE [download page](https://tomee.apache.org/download-ng.html) and unzip it somewhere you'll find it again. -2. Overwrite or enable the following settings in `${TOMEE_HOME}/conf/system.properties` to get Arquillian to run: -``` -tomee.remote.support=true -tomee.serialization.class.blacklist=- -openejb.system.apps = true -``` -3. Start TomEE with `sh catalina.sh jpda start`. This enables you to remote-debug the Arquillian tests. -4. Go into the `testsuite` package of Eclipse Krazo and execute `mvn clean integration-test -Ptestsuite-tomee` - -### OpenLiberty -To run the Krazo testsuite with OpenLiberty, you need to follow these steps. Please note that this process has been tested with 20.x only. - -1. Download OpenLiberty from the [official download page](https://openliberty.io/downloads/) and unzip it. -2. Replace the file `wlp/templates/servers/defaultServer/server.xml` with `.travis/wlp-server-template.xml` from the Eclipse Krazo repository. -3. Go into the `testsuite` package of Eclipse Krazo and execute `mvn clean integration-test -Ptestsuite-glassfish -Dliberty.home=c:/somewhere/wlp/`. - Please make sure to replace `c:/somewhere/wlp/` with the absolute path to the unpacked OpenLiberty distribution. - ### Troubleshooting #### Tests are failing locally but not in Jenkins diff --git a/documentation/src/main/asciidoc/_intro.adoc b/documentation/src/main/asciidoc/_intro.adoc index 28c0f4be..abcfb79e 100644 --- a/documentation/src/main/asciidoc/_intro.adoc +++ b/documentation/src/main/asciidoc/_intro.adoc @@ -20,7 +20,7 @@ == Introduction Eclipse Krazo is an implementation of action-based MVC specified by MVC 1.0 (JSR-371). -It builds on top of JAX-RS and currently contains support for RESTEasy, Jersey and CXF +It builds on top of JAX-RS and currently contains support for RESTEasy and Jersey with a well-defined SPI for other implementations. This is user guide for Eclipse Krazo {krazo-version}. diff --git a/documentation/src/main/asciidoc/_quickstart.adoc b/documentation/src/main/asciidoc/_quickstart.adoc index 016a6e13..a18460fa 100644 --- a/documentation/src/main/asciidoc/_quickstart.adoc +++ b/documentation/src/main/asciidoc/_quickstart.adoc @@ -64,26 +64,9 @@ mvn archetype:generate \ .... ====== TomEE / OpenLiberty (CXF) +Krazo won't support CXF anymore. As OpenLiberty is going to switch to RESTEasy until it supports Jakarta REST Web Services 3.0, this change is only relevant for TomEE in general and older versions of OpenLiberty. -[source, subs="attributes"] -.... -mvn archetype:generate \ --DarchetypeGroupId=org.eclipse.krazo \ --DarchetypeArtifactId=krazo-jakartaee8-archetype \ --DarchetypeVersion={krazo-version} \ --DgroupId=YOUR GROUP ID \ --DartifactId=YOUR ARTIFACT ID \ --DkrazoImpl=cxf -.... - -===== Manual setup -If you can't or just don't want to use the archetype, you can set up Krazo easily by yourself. Please follow the guides below for -your server. The dependencies you need to add to your `pom.xml` file depend on which application server your are using. - -====== Glassfish/Payara - -Glassfish comes with Jersey as its JAX-RS implementation. Please add the following dependencies to your -application: +To use Krazo on those servers anyway, you can add e.g. RESTEasy as a compile time dependency to your artifact: [source,xml] ---- @@ -94,14 +77,31 @@ application: org.eclipse.krazo - krazo-jersey + krazo-resteasy {{versions.krazo.latest}} + + org.jboss.resteasy + resteasy-cdi + 3.6.1.Final + + + org.jboss.resteasy + resteasy-servlet-initializer + 3.6.1.Final + + + org.jboss.resteasy + resteasy-validator-provider-11 + 3.6.1.Final + ---- -====== Wildfly and JBoss EAP -Wildfly is using RESTEasy for JAX-RS. So you need the Eclipse Krazo RESTEasy integration module: +====== Glassfish/Payara + +Glassfish comes with Jersey as its JAX-RS implementation. Please add the following dependencies to your +application: [source,xml] ---- @@ -112,18 +112,14 @@ Wildfly is using RESTEasy for JAX-RS. So you need the Eclipse Krazo RESTEasy int org.eclipse.krazo - krazo-resteasy + krazo-jersey {{versions.krazo.latest}} ---- -====== Apache TomEE - -Apache TomEE uses CXF as the JAX-RS implementation. Unfortunately there are some known bugs in CXF -which are causing trouble for Eclipse Krazo. The latest CXF release should fix these issues, but -Apache TomEE currently ships with an older CXF release. +====== Wildfly and JBoss EAP -If you want to give Eclipse Krazo on Apache TomEE a try, add the following dependencies to your `pom.xml`: +Wildfly is using RESTEasy for JAX-RS. So you need the Eclipse Krazo RESTEasy integration module: [source,xml] ---- @@ -134,13 +130,14 @@ If you want to give Eclipse Krazo on Apache TomEE a try, add the following depen org.eclipse.krazo - krazo-core + krazo-resteasy {{versions.krazo.latest}} ---- -If using CXF with Eclipse Krazo is causing trouble, you can also manually add RESTEasy to your application and -use this instead of CXF. To do so, use the following dependencies instead. +====== Apache TomEE + +To use Krazo on TomEE, you can add RESTEasy as a compile time dependency, as CXF isn't supported anymore by Krazo. [source,xml] ---- @@ -341,29 +338,6 @@ with Eclipse Krazo, you have to consider following configurations. You don't need additional configuration, as Krazo is auto-loaded by implementation-specific SPIs. -===== CXF - -As CXF doesn't provide any SPI to enforce the initialization of Eclipse Krazo, you need to configure all necessary -providers manually in `Application#getClasses`. Please have a look into the snippet below, which shows an example -implementation of `Application#getClasses`. - -.... -public class MyApplication extends Application { - - @Override - public Set> getClasses() { - final Set> classes = new HashSet<>(); - - ... - - // Add Krazo features - classes.addAll(org.eclipse.krazo.bootstrap.DefaultConfigProvider.PROVIDERS); - - return classes; - } -} -.... - === Creating you first controller The following steps will show you how to create your first Controller using Eclipse Krazo. It assumes, that you've set up a project like we described before. From e8043b890fe23015ed968714befba19f7905452d Mon Sep 17 00:00:00 2001 From: "Erdle, Tobias" Date: Mon, 12 Apr 2021 21:23:37 +0200 Subject: [PATCH 3/7] Remove CXF option from archetype Signed-off-by: Erdle, Tobias --- archetype/src/main/resources/archetype-resources/pom.xml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/archetype/src/main/resources/archetype-resources/pom.xml b/archetype/src/main/resources/archetype-resources/pom.xml index 45905401..e3b75450 100644 --- a/archetype/src/main/resources/archetype-resources/pom.xml +++ b/archetype/src/main/resources/archetype-resources/pom.xml @@ -36,12 +36,6 @@ krazo-resteasy \${krazo.version} - #elseif (${krazoImpl} == 'cxf') - - org.eclipse.krazo - krazo-cxf - \${krazo.version} - #else org.eclipse.krazo From 486d08c9e5b22e4b50eb6b30f99b7641af06f4e7 Mon Sep 17 00:00:00 2001 From: "Erdle, Tobias" Date: Mon, 12 Apr 2021 21:27:31 +0200 Subject: [PATCH 4/7] Remove CXF workarounds from core module Signed-off-by: Erdle, Tobias --- .../eclipse/krazo/bootstrap/CoreFeature.java | 8 +---- .../bootstrap/DefaultConfigProvider.java | 36 ++++--------------- .../eclipse/krazo/bootstrap/Initializer.java | 12 +++---- .../krazo/core/ViewResponseFilter.java | 12 +++---- .../jaxrs/PostMatchingRequestFilter.java | 13 ++----- .../krazo/jaxrs/PreMatchingRequestFilter.java | 10 ++---- .../eclipse/krazo/util/ServiceLoaders.java | 18 ++-------- 7 files changed, 26 insertions(+), 83 deletions(-) diff --git a/core/src/main/java/org/eclipse/krazo/bootstrap/CoreFeature.java b/core/src/main/java/org/eclipse/krazo/bootstrap/CoreFeature.java index f0ae7160..97aa389a 100644 --- a/core/src/main/java/org/eclipse/krazo/bootstrap/CoreFeature.java +++ b/core/src/main/java/org/eclipse/krazo/bootstrap/CoreFeature.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019 Eclipse Krazo committers and contributors + * Copyright (c) 2018, 2021 Eclipse Krazo committers and contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,12 +47,6 @@ public boolean configure(FeatureContext context) { // RESTEasy seems to ignore @ConstrainedTo in some cases if (context.getConfiguration().getRuntimeType() == RuntimeType.SERVER) { - // https://issues.apache.org/jira/browse/CXF-7501 - // https://issues.apache.org/jira/browse/TOMEE-2122 - if (servletContext == null) { - log.warning("The ServletContext wasn't injected into the JAX-RS Feature class"); - } - Initializer.initialize(context, servletContext); return true; diff --git a/core/src/main/java/org/eclipse/krazo/bootstrap/DefaultConfigProvider.java b/core/src/main/java/org/eclipse/krazo/bootstrap/DefaultConfigProvider.java index c7dec4d4..69d85a25 100644 --- a/core/src/main/java/org/eclipse/krazo/bootstrap/DefaultConfigProvider.java +++ b/core/src/main/java/org/eclipse/krazo/bootstrap/DefaultConfigProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019 Eclipse Krazo committers and contributors + * Copyright (c) 2018, 2021 Eclipse Krazo committers and contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,10 @@ */ package org.eclipse.krazo.bootstrap; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + import org.eclipse.krazo.binding.convert.MvcConverterProvider; import org.eclipse.krazo.core.ViewResponseFilter; import org.eclipse.krazo.core.ViewableWriter; @@ -26,13 +30,8 @@ import org.eclipse.krazo.security.CsrfExceptionMapper; import org.eclipse.krazo.security.CsrfProtectFilter; import org.eclipse.krazo.security.CsrfValidateFilter; -import org.eclipse.krazo.util.CdiUtils; import jakarta.ws.rs.core.FeatureContext; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; /** * Implementation of ConfigProvider which registers all providers of the core module. @@ -61,30 +60,7 @@ public void configure(FeatureContext context) { } private void register(FeatureContext context, Class providerClass) { - - boolean isCxf = context.getClass().getName().startsWith("org.apache.cxf"); - - /* - * With CXF there is no CDI injection if JAX-RS providers are registered via - * context.register(Class). So we try to lookup provider instances from CDI - * and register them instead. - * See: https://issues.apache.org/jira/browse/CXF-7501 - */ - if (isCxf) { - List providerInstances = CdiUtils.getApplicationBeans(providerClass); - if (!providerInstances.isEmpty()) { - context.register(providerInstances.get(0)); - } else { - context.register(providerClass); - } - } - - // will work for all other containers - else { - context.register(providerClass); - } - - + context.register(providerClass); } } diff --git a/core/src/main/java/org/eclipse/krazo/bootstrap/Initializer.java b/core/src/main/java/org/eclipse/krazo/bootstrap/Initializer.java index ee114a10..c3165ec9 100644 --- a/core/src/main/java/org/eclipse/krazo/bootstrap/Initializer.java +++ b/core/src/main/java/org/eclipse/krazo/bootstrap/Initializer.java @@ -17,6 +17,11 @@ */ package org.eclipse.krazo.bootstrap; +import java.util.Objects; +import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; + import org.eclipse.krazo.core.ViewResponseFilter; import org.eclipse.krazo.servlet.KrazoContainerInitializer; import org.eclipse.krazo.util.ServiceLoaders; @@ -24,10 +29,6 @@ import jakarta.servlet.ServletContext; import jakarta.ws.rs.core.Configuration; import jakarta.ws.rs.core.FeatureContext; -import java.util.Objects; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; /** * Main class for triggering initialization of Eclipse Krazo @@ -71,9 +72,6 @@ private static boolean isAlreadyInitialized(Configuration config) { return config.isRegistered(ViewResponseFilter.class); } - /** - * Note: ServletContext may be null here, because CXF doesn't inject it correctly - */ private static boolean isMvcApplication(ServletContext servletContext) { // we fall back to enable Krazo if detection didn't work diff --git a/core/src/main/java/org/eclipse/krazo/core/ViewResponseFilter.java b/core/src/main/java/org/eclipse/krazo/core/ViewResponseFilter.java index 4215e318..29bcc38c 100644 --- a/core/src/main/java/org/eclipse/krazo/core/ViewResponseFilter.java +++ b/core/src/main/java/org/eclipse/krazo/core/ViewResponseFilter.java @@ -28,7 +28,6 @@ import static org.eclipse.krazo.util.PathUtils.noPrefix; import static org.eclipse.krazo.util.PathUtils.noStartingSlash; -import java.io.IOException; import java.lang.reflect.Method; import java.net.URI; import java.util.Arrays; @@ -37,6 +36,11 @@ import java.util.logging.Logger; import java.util.stream.Collectors; +import org.eclipse.krazo.KrazoConfig; +import org.eclipse.krazo.engine.Viewable; +import org.eclipse.krazo.event.ControllerRedirectEventImpl; +import org.eclipse.krazo.lifecycle.RequestLifecycle; + import jakarta.annotation.Priority; import jakarta.enterprise.event.Event; import jakarta.inject.Inject; @@ -60,11 +64,6 @@ import jakarta.ws.rs.core.UriInfo; import jakarta.ws.rs.core.Variant; -import org.eclipse.krazo.KrazoConfig; -import org.eclipse.krazo.engine.Viewable; -import org.eclipse.krazo.event.ControllerRedirectEventImpl; -import org.eclipse.krazo.lifecycle.RequestLifecycle; - /** *

A JAX-RS response filter that fires a {@link jakarta.mvc.event.AfterControllerEvent} * event. It also verifies the static return type of the controller method is correct, @@ -155,7 +154,6 @@ public void filter(ContainerRequestContext requestContext, // If the entity is null the status will be set to 204 by Jersey. For void methods we need to // set the status to 200 unless no other status was set by e.g. throwing an Exception. - // Don't use equals() on the result of getStatusInfo(), because it doesn't work on CXF if (responseContext.getStatusInfo().getStatusCode() == Response.Status.NO_CONTENT.getStatusCode()) { responseContext.setStatusInfo(Response.Status.OK); } diff --git a/core/src/main/java/org/eclipse/krazo/jaxrs/PostMatchingRequestFilter.java b/core/src/main/java/org/eclipse/krazo/jaxrs/PostMatchingRequestFilter.java index 312574e6..25ad1626 100644 --- a/core/src/main/java/org/eclipse/krazo/jaxrs/PostMatchingRequestFilter.java +++ b/core/src/main/java/org/eclipse/krazo/jaxrs/PostMatchingRequestFilter.java @@ -17,8 +17,6 @@ */ package org.eclipse.krazo.jaxrs; -import org.eclipse.krazo.util.CdiUtils; - import jakarta.annotation.Priority; import jakarta.mvc.Controller; import jakarta.servlet.http.HttpServletRequest; @@ -30,7 +28,6 @@ import jakarta.ws.rs.core.Configuration; import jakarta.ws.rs.core.Context; import jakarta.ws.rs.core.UriInfo; -import java.io.IOException; /** * Post-Matching ContainerRequestFilter @@ -59,16 +56,12 @@ public class PostMatchingRequestFilter implements ContainerRequestFilter { @Context private ResourceInfo resourceInfo; + @Context + private JaxRsContextProducer contextProducer; + @Override public void filter(ContainerRequestContext requestContext) { - /* - * Please note that we CANNOT inject JaxRsContextProducer here, because this will - * fail on TomEE/CXF/OWB because processing @Context fails for some reason. - */ - JaxRsContextProducer contextProducer = CdiUtils.getApplicationBean(JaxRsContextProducer.class) - .orElseThrow(() -> new IllegalStateException("Cannot find CDI managed JaxRsContextProducer")); - // store JAX-RS context objects so we can produce them via CDI contextProducer.setConfiguration(configuration); contextProducer.setRequest(request); diff --git a/core/src/main/java/org/eclipse/krazo/jaxrs/PreMatchingRequestFilter.java b/core/src/main/java/org/eclipse/krazo/jaxrs/PreMatchingRequestFilter.java index 5a32ee52..6c2a677d 100644 --- a/core/src/main/java/org/eclipse/krazo/jaxrs/PreMatchingRequestFilter.java +++ b/core/src/main/java/org/eclipse/krazo/jaxrs/PreMatchingRequestFilter.java @@ -56,16 +56,12 @@ public class PreMatchingRequestFilter implements ContainerRequestFilter { @Context private UriInfo uriInfo; + @Context + private JaxRsContextProducer contextProducer; + @Override public void filter(ContainerRequestContext requestContext) { - /* - * Please note that we CANNOT inject JaxRsContextProducer here, because this will - * fail on TomEE/CXF/OWB because processing @Context fails for some reason. - */ - JaxRsContextProducer contextProducer = CdiUtils.getApplicationBean(JaxRsContextProducer.class) - .orElseThrow(() -> new IllegalStateException("Cannot find CDI managed JaxRsContextProducer")); - // store JAX-RS context objects so we can produce them via CDI contextProducer.setConfiguration(configuration); contextProducer.setRequest(request); diff --git a/core/src/main/java/org/eclipse/krazo/util/ServiceLoaders.java b/core/src/main/java/org/eclipse/krazo/util/ServiceLoaders.java index e80676cf..56c3f036 100644 --- a/core/src/main/java/org/eclipse/krazo/util/ServiceLoaders.java +++ b/core/src/main/java/org/eclipse/krazo/util/ServiceLoaders.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019 Eclipse Krazo committers and contributors + * Copyright (c) 2018, 2021 Eclipse Krazo committers and contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,15 +17,14 @@ */ package org.eclipse.krazo.util; -import org.eclipse.krazo.bootstrap.ConfigProvider; - -import jakarta.annotation.Priority; import java.util.Comparator; import java.util.List; import java.util.ServiceLoader; import java.util.stream.Collectors; import java.util.stream.StreamSupport; +import jakarta.annotation.Priority; + /** * Utility code for the {@link ServiceLoader} class. * @@ -42,15 +41,6 @@ public static List list(Class type) { // classloader to use for ServiceLoader lookups ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); - /* - * Special workaround for TomEE . The context classloader is an instance of CxfContainerClassLoader - * and NOT the TomEEWebappClassLoader, which seems to break when redeploying apps into a running - * container for some reason. - */ - if (classLoader.getClass().getName().contains("CxfContainerClassLoader")) { - classLoader = ConfigProvider.class.getClassLoader(); - } - // return the SPI implementations as a list return StreamSupport.stream(ServiceLoader.load(type, classLoader).spliterator(), false) .sorted(new PriorityComparator()) @@ -76,6 +66,4 @@ private int getPriority(Object o) { } } } - - } From f0b3e32508faddff1afbc426cdd0455f8cbe876e Mon Sep 17 00:00:00 2001 From: "Erdle, Tobias" Date: Mon, 12 Apr 2021 21:30:02 +0200 Subject: [PATCH 5/7] Remove CXF from testsuite and TCK Be aware that the Liberty profile is only commented out, as we will support this server again, as soon as they use RESTEasy. Because of this, the archive creator is adapted to use RESTEasy, so later we only need to remove the comments from the profiles and adapt the dependecies within the pom.xml. Signed-off-by: Erdle, Tobias --- tck/pom.xml | 98 ++++++++-------- .../krazo/tck/AbstractArchiveProvider.java | 4 - .../tck/liberty/LibertyArchiveProvider.java | 2 +- .../krazo/tck/tomee/TomeeArchiveProvider.java | 36 ------ .../tck/tomee/TomeeDevArchiveProvider.java | 47 -------- testsuite/pom.xml | 109 ++++++------------ 6 files changed, 83 insertions(+), 213 deletions(-) delete mode 100644 tck/src/main/java/org/eclipse/krazo/tck/tomee/TomeeArchiveProvider.java delete mode 100644 tck/src/main/java/org/eclipse/krazo/tck/tomee/TomeeDevArchiveProvider.java diff --git a/tck/pom.xml b/tck/pom.xml index 3f40140c..20f7a539 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -103,12 +103,6 @@ krazo-resteasy ${project.version} - - org.eclipse.krazo - krazo-cxf - ${project.version} - - @@ -266,53 +260,53 @@ - - tck-liberty - - - tck-env - liberty - - - - - - maven-surefire-plugin - - jakarta.mvc.tck:mvc-tck-tests - - liberty - - org.eclipse.krazo.tck.liberty.LibertyArchiveProvider - - - - - - - - - io.openliberty.arquillian - arquillian-liberty-managed-jakarta - 2.0.0-M1 - test - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - sonatype-oss-snapshots - Sonatype OSS Nexus Snapshots - https://oss.sonatype.org/content/repositories/snapshots/ - - false - - - true - - - - + + + + + + + + + + + + + + diff --git a/tck/src/main/java/org/eclipse/krazo/tck/AbstractArchiveProvider.java b/tck/src/main/java/org/eclipse/krazo/tck/AbstractArchiveProvider.java index a2e91a92..9bd91632 100644 --- a/tck/src/main/java/org/eclipse/krazo/tck/AbstractArchiveProvider.java +++ b/tck/src/main/java/org/eclipse/krazo/tck/AbstractArchiveProvider.java @@ -72,10 +72,6 @@ protected File[] resolveKrazoRestEasy() { return resolveKrazoModule("org.eclipse.krazo", "krazo-resteasy"); } - protected File[] resolveKrazoCxf() { - return resolveKrazoModule("org.eclipse.krazo", "krazo-cxf"); - } - protected File[] resolveKrazoCore() { return resolveKrazoModule("org.eclipse.krazo", "krazo-core"); } diff --git a/tck/src/main/java/org/eclipse/krazo/tck/liberty/LibertyArchiveProvider.java b/tck/src/main/java/org/eclipse/krazo/tck/liberty/LibertyArchiveProvider.java index 50e803d4..4f9570f8 100644 --- a/tck/src/main/java/org/eclipse/krazo/tck/liberty/LibertyArchiveProvider.java +++ b/tck/src/main/java/org/eclipse/krazo/tck/liberty/LibertyArchiveProvider.java @@ -30,7 +30,7 @@ public class LibertyArchiveProvider extends AbstractArchiveProvider { public WebArchive getBaseArchive() { return ShrinkWrap.create(WebArchive.class) .addAsLibraries(resolveMvcSpecJar()) - .addAsLibraries(resolveKrazoCxf()); + .addAsLibraries(resolveKrazoRestEasy()); } } diff --git a/tck/src/main/java/org/eclipse/krazo/tck/tomee/TomeeArchiveProvider.java b/tck/src/main/java/org/eclipse/krazo/tck/tomee/TomeeArchiveProvider.java deleted file mode 100644 index 77b0c91e..00000000 --- a/tck/src/main/java/org/eclipse/krazo/tck/tomee/TomeeArchiveProvider.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2018, 2019 Eclipse Krazo committers and contributors - * - * Licensed 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. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package org.eclipse.krazo.tck.tomee; - -import org.jboss.shrinkwrap.api.ShrinkWrap; -import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.eclipse.krazo.tck.AbstractArchiveProvider; - -/** - * BaseArchiveProvider implementation for running TCK against TomEE - */ -public class TomeeArchiveProvider extends AbstractArchiveProvider { - - @Override - public WebArchive getBaseArchive() { - return ShrinkWrap.create(WebArchive.class) - .addAsLibraries(resolveMvcSpecJar()) - .addAsLibraries(resolveKrazoCxf()); - } - -} diff --git a/tck/src/main/java/org/eclipse/krazo/tck/tomee/TomeeDevArchiveProvider.java b/tck/src/main/java/org/eclipse/krazo/tck/tomee/TomeeDevArchiveProvider.java deleted file mode 100644 index 43d91bee..00000000 --- a/tck/src/main/java/org/eclipse/krazo/tck/tomee/TomeeDevArchiveProvider.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2019 Eclipse Krazo committers and contributors - * - * Licensed 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. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package org.eclipse.krazo.tck.tomee; - -import org.eclipse.krazo.tck.AbstractArchiveProvider; -import org.jboss.shrinkwrap.api.ShrinkWrap; -import org.jboss.shrinkwrap.api.importer.ExplodedImporter; -import org.jboss.shrinkwrap.api.spec.JavaArchive; -import org.jboss.shrinkwrap.api.spec.WebArchive; - -/** - * BaseArchiveProvider implementation for running TCK against TomEE - */ -public class TomeeDevArchiveProvider extends AbstractArchiveProvider { - - @Override - public WebArchive getBaseArchive() { - return ShrinkWrap.create(WebArchive.class) - .addAsLibraries(resolveMvcSpecJar()) - .addAsLibraries( - ShrinkWrap.create(ExplodedImporter.class, "krazo-core.jar") - .importDirectory("../core/target/classes") - .as(JavaArchive.class) - ) - .addAsLibraries( - ShrinkWrap.create(ExplodedImporter.class, "krazo-cxf.jar") - .importDirectory("../cxf/target/classes") - .as(JavaArchive.class) - ); - } - -} diff --git a/testsuite/pom.xml b/testsuite/pom.xml index 6305041f..d3c0a58c 100644 --- a/testsuite/pom.xml +++ b/testsuite/pom.xml @@ -335,79 +335,42 @@ - - testsuite-tomee - - - false - - - - - org.apache.tomee - arquillian-tomee-remote - 8.0.4 - test - - - org.eclipse.krazo - krazo-cxf - ${project.version} - runtime - - - - - - - maven-failsafe-plugin - - false - - tomee - testsuite-tomee - - - - - - - - testsuite-liberty - - - false - - - - - io.openliberty.arquillian - arquillian-liberty-managed - 1.0.6 - - - org.eclipse.krazo - krazo-cxf - ${project.version} - runtime - - - - - - - maven-failsafe-plugin - - false - - liberty - testsuite-liberty - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 57dc38094e5a8c076fa8c54d10667100b255a52d Mon Sep 17 00:00:00 2001 From: "Erdle, Tobias" Date: Mon, 12 Apr 2021 21:41:55 +0200 Subject: [PATCH 6/7] Adapt Travis pipeline to ignore TomEE and Liberty Signed-off-by: Erdle, Tobias --- .travis/docker-tomee.sh | 14 -------------- .travis/tests.sh | 43 ++++++++++++++--------------------------- 2 files changed, 14 insertions(+), 43 deletions(-) delete mode 100755 .travis/docker-tomee.sh diff --git a/.travis/docker-tomee.sh b/.travis/docker-tomee.sh deleted file mode 100755 index b802c233..00000000 --- a/.travis/docker-tomee.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env sh - -set -eu - -TOMEE_VERSION=11-jre-8.0.4-plus - -docker pull tomee:${TOMEE_VERSION} -docker run --name=tomee -d \ - -p 8080:8080 \ - -e CATALINA_OPTS="\ - -Dtomee.serialization.class.blacklist=- \ - -Dtomee.remote.support=true \ - -Dopenejb.system.apps=true" \ - tomee:${TOMEE_VERSION} diff --git a/.travis/tests.sh b/.travis/tests.sh index e96fdac4..f64bde70 100755 --- a/.travis/tests.sh +++ b/.travis/tests.sh @@ -91,20 +91,13 @@ elif [[ ${1} == tck-wildfly22* ]]; then mvn -B -V -Dtck-env=wildfly verify ${BUILD_PROFILE} popd -elif [ "${1}" == "tck-tomee" ]; then - - mvn -B -V -DskipTests clean install ${BUILD_PROFILE} - pushd tck - mvn -B -V -Dtck-env=tomee verify ${BUILD_PROFILE} - popd - -elif [ "${1}" == "tck-liberty" ]; then - - source .travis/install-liberty.sh - mvn -B -V -DskipTests clean install ${BUILD_PROFILE} - pushd tck - mvn -B -V -Dtck-env=liberty -Dliberty.home=${LIBERTY_HOME} verify ${BUILD_PROFILE} - popd +#elif [ "${1}" == "tck-liberty" ]; then +# +# source .travis/install-liberty.sh +# mvn -B -V -DskipTests clean install ${BUILD_PROFILE} +# pushd tck +# mvn -B -V -Dtck-env=liberty -Dliberty.home=${LIBERTY_HOME} verify ${BUILD_PROFILE} +# popd elif [[ ${1} == testsuite-wildfly ]]; then @@ -120,21 +113,13 @@ elif [[ ${1} == testsuite-payara ]]; then echo "Running test suite on Payara" mvn -P${TYPE} --projects testsuite clean verify ${BUILD_PROFILE} -elif [[ ${1} == testsuite-tomee ]]; then - - source .travis/docker-tomee.sh - echo "Building Krazo..." - mvn -B -V -DskipTests clean install ${BUILD_PROFILE} - echo "Running test suite on TomEE" - mvn -P${TYPE} --projects testsuite clean verify ${BUILD_PROFILE} - -elif [[ ${1} == testsuite-liberty ]]; then - - source .travis/install-liberty.sh && mvn -P${TYPE} -Dliberty.home=${LIBERTY_HOME} --projects testsuite clean verify ${BUILD_PROFILE} - echo "Building Krazo..." - mvn -B -V -DskipTests clean install ${BUILD_PROFILE} - echo "Running test suite on Liberty" - mvn -P${TYPE} -Dliberty.home=${LIBERTY_HOME} --projects testsuite clean verify ${BUILD_PROFILE} +# elif [[ ${1} == testsuite-liberty ]]; then +# +# source .travis/install-liberty.sh && mvn -P${TYPE} -Dliberty.home=${LIBERTY_HOME} --projects testsuite clean verify ${BUILD_PROFILE} +# echo "Building Krazo..." +# mvn -B -V -DskipTests clean install ${BUILD_PROFILE} +# echo "Running test suite on Liberty" +# mvn -P${TYPE} -Dliberty.home=${LIBERTY_HOME} --projects testsuite clean verify ${BUILD_PROFILE} elif [[ ${1} == testsuite-glassfish ]]; then From 4d976d4ebfd0041cba25c2a2dcacbc544f59ed26 Mon Sep 17 00:00:00 2001 From: "Erdle, Tobias" Date: Tue, 13 Apr 2021 12:03:06 +0200 Subject: [PATCH 7/7] Re-enable OpenLiberty Tests with RESTEasy Signed-off-by: Erdle, Tobias --- README.md | 8 +++++ tck/pom.xml | 92 ++++++++++++----------------------------------- testsuite/pom.xml | 66 +++++++++++++++++----------------- 3 files changed, 64 insertions(+), 102 deletions(-) diff --git a/README.md b/README.md index 81a96a29..540a63a5 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ The following sections describe how you test Eclipse Krazo against them. At the - Glassfish 8 - WildFly 22.x.x +- OpenLiberty 21.* ### Preconditions - JDK 11 @@ -31,6 +32,13 @@ To run the Krazo testsuite with WildFly, you need to follow these steps: 2. Start WildFly with `sh standalone.sh --debug`. This enables you to remote-debug the Arquillian tests. 3. Go into the `testsuite` package of Eclipse Krazo and execute `mvn clean integration-test -Ptestsuite-wildfly` +### OpenLiberty +To run the Krazo testsuite with OpenLiberty, you need to follow these steps. Please note that this process has been tested with 20.x only. + +Download OpenLiberty from the official download page and unzip it. +Replace the file `wlp/templates/servers/defaultServer/server.xml` with `.travis/wlp-server-template.xml` from the Eclipse Krazo repository. +Go into the testsuite package of Eclipse Krazo and execute `mvn clean integration-test -Ptestsuite-liberty -Dliberty.home=c:/somewhere/wlp/`. Please make sure to replace c:/somewhere/wlp/ with the absolute path to the unpacked OpenLiberty distribution. + ### Troubleshooting #### Tests are failing locally but not in Jenkins diff --git a/tck/pom.xml b/tck/pom.xml index 20f7a539..c501046e 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -213,19 +213,15 @@ - + - tck-tomee + tck-liberty tck-env - tomee + liberty - - 9.0.0-M2 - webprofile - @@ -233,10 +229,9 @@ jakarta.mvc.tck:mvc-tck-tests - ${tomee.version} - tomee + liberty - org.eclipse.krazo.tck.tomee.TomeeArchiveProvider + org.eclipse.krazo.tck.liberty.LibertyArchiveProvider @@ -245,68 +240,27 @@ - org.apache.tomee - arquillian-tomee-remote - ${tomee.version} - - - org.apache.tomee - apache-tomee - ${tomee.version} - ${tomee.classifier} - zip + io.openliberty.arquillian + arquillian-liberty-managed-jakarta + 2.0.0-M1 + test - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + sonatype-oss-snapshots + Sonatype OSS Nexus Snapshots + https://oss.sonatype.org/content/repositories/snapshots/ + + false + + + true + + + + diff --git a/testsuite/pom.xml b/testsuite/pom.xml index d3c0a58c..e67dfe49 100644 --- a/testsuite/pom.xml +++ b/testsuite/pom.xml @@ -336,41 +336,41 @@ - - + + testsuite-liberty - - - + + false + - - - - - - - - - - - - - + + + io.openliberty.arquillian + arquillian-liberty-managed + 1.0.6 + + + org.eclipse.krazo + krazo-resteasy + ${project.version} + runtime + + - - - - - - - - - - - - - - - + + + + maven-failsafe-plugin + + false + + liberty + testsuite-liberty + + + + + +