From aa59a0f71f20d095692e6c883c722689394d2716 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20K=C3=BChne?= Date: Mon, 10 Jul 2023 08:09:46 +0200 Subject: [PATCH] Add review comments for migration of servlets for RESTEasy Reactive --- .../asciidoc/resteasy-reactive-migration.adoc | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/docs/src/main/asciidoc/resteasy-reactive-migration.adoc b/docs/src/main/asciidoc/resteasy-reactive-migration.adoc index ab70087384f8c..fca208c2f84d3 100644 --- a/docs/src/main/asciidoc/resteasy-reactive-migration.adoc +++ b/docs/src/main/asciidoc/resteasy-reactive-migration.adoc @@ -124,10 +124,30 @@ when the method returns a `String`. RESTEasy Reactive does **not** support servlets. If your project depends on servlets you have to migrate them. -A common situation is when your application is developed with JAX-RS for a servlet-based environment. A servlet-based JAX-RS implementation must support injections of these types with the `@Context` annotation: `ServletConfig`, `ServletContext`, `HttpServletRequest` and `HttpServletResponse`. -Since RESTEasy Reactive is not servlet-based these injections are not mandatory. +Since RESTEasy Reactive is not servlet-based these injections will not work. + It is not always obvious that this will fail especially if you depend on an extension like `quarkus-undertow` which supplies the interfaces. +For example, if you write this you could compile it but get an exception on calling it: + +[source, java] +---- +@Path("/reactive") +public class ReactiveResource { + + @Context + HttpServletRequest httpServletRequest; + + @GET + @Produces(MediaType.TEXT_PLAIN) + public String servletContextPath() { + + String contextPath = httpServletRequest.getContextPath(); + + return "My context path is: " + contextPath; + } +} +---- The same is true for your third-party libraries. If they happen to depend on servlets you need to find a migration path for them.