eclipse-ee4j / eclipse-ee4j/krazo

Missing Weld HTTP communication unwrapper on krazo-jersey

Open
#396 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
55
Forks
25
Avg merge
3h 25m
Merged PRs (30d)
3

Description

Trying to use Krazo 4.0.1 atop Jersey 4.0.2 with Weld 6.0.4.Final and Jetty 12.1.6, my controller methods fail with logs like:

> java.lang.IllegalStateException: could not find ServletContextRequest for oeje11s.ServletApiRequest@6a74cbe1{oeje11s.ServletContextRequest@65c45b6b{GET@26245e97 http://localhost:9000/context/servlet/resource/method HTTP/1.1}}
at org.eclipse.jetty.ee11.servlet.ServletContextRequest.getServletContextRequest(ServletContextRequest.java:100)
at org.eclipse.jetty.ee11.servlet.Dispatcher.forward(Dispatcher.java:134)
at org.eclipse.krazo.engine.ServletViewEngine.forwardRequest(ServletViewEngine.java:121)
at org.eclipse.krazo.engine.JspViewEngine.processView(JspViewEngine.java:58)
at org.eclipse.krazo.core.ViewableWriter.writeTo(ViewableWriter.java:159)
at org.eclipse.krazo.core.ViewableWriter.writeTo(ViewableWriter.java:71)
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.invokeWriteTo(WriterInterceptorExecutor.java:242)
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:227)
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:139)
at org.glassfish.jersey.server.internal.JsonWithPaddingInterceptor.aroundWriteTo(JsonWithPaddingInterceptor.java:85)
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:139)
at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundWriteTo(MappableExceptionWrapperInterceptor.java:61)
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:139)
at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1118)
at org.glassfish.jersey.server.ServerRuntime$Responder.writeResponse(ServerRuntime.java:691)
at org.glassfish.jersey.server.ServerRuntime$Responder.processResponse(ServerRuntime.java:398)
at org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:388)
at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:277)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:244)
at org.glassfish.jersey.internal.Errors.process(Errors.java:292)
at org.glassfish.jersey.internal.Errors.process(Errors.java:274)
at org.glassfish.jersey.internal.Errors.process(Errors.java:244)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:266)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:253)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:703)
at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:422)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:374)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:355)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:309)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:202)
at org.eclipse.jetty.ee11.servlet.ServletHolder.handle(ServletHolder.java:750)
at org.eclipse.jetty.ee11.servlet.ServletHandler$ChainEnd.doFilter(ServletHandler.java:1668)
at org.eclipse.jetty.ee11.servlet.ServletHandler$MappedServlet.handle(ServletHandler.java:1602)
at org.eclipse.jetty.ee11.servlet.ServletChannel.dispatch(ServletChannel.java:868)
at org.eclipse.jetty.ee11.servlet.ServletChannel.handle(ServletChannel.java:449)
at org.eclipse.jetty.ee11.servlet.ServletHandler.handle(ServletHandler.java:470)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:546)
at org.eclipse.jetty.ee11.servlet.SessionHandler.handle(SessionHandler.java:763)
at org.eclipse.jetty.server.handler.ContextHandler.handle(ContextHandler.java:1224)
at org.eclipse.jetty.server.Server.handle(Server.java:197)
at org.eclipse.jetty.server.internal.HttpChannelState$HandlerInvoker.run(HttpChannelState.java:787)
at org.eclipse.jetty.server.internal.HttpConnection.onFillable(HttpConnection.java:410)
at org.eclipse.jetty.server.internal.HttpConnection$FillableCallback.succeeded(HttpConnection.java:1805)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
at org.eclipse.jetty.io.SelectableChannelEndPoint$1.run(SelectableChannelEndPoint.java:54)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:1009)
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.doRunJob(QueuedThreadPool.java:1239)
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1194)
at java.base/java.lang.Thread.run(Thread.java:1583)

Looking into this, the problem seems to be that krazo-jersey does not know how to unwrap Weld request proxies for processing. This problem was fixed in #365 for RESTEasy, but that pull request did not add similar functionality on the Jersey side. I tried simply copying that class & service file over to the Jersey side and my methods started working, but there might be architecturally prettier solutions...

Attached is a minimal Maven project that compiles into an uber-jar reproducing this problem. Running it with `java -jar target/jersey-krazo-weld-integration-0.0.0.jar` will serve a page at http://localhost:9000/context/servlet/resource/method that will trigger the above exception; if you remove the comment from the `src/main/resources/META-INF/services/org.eclipse.krazo.core.HttpCommunicationUnwrapper` file to enable the `WeldHttpCommunicationUnwrapper` class, the page will start working.

[jersey-krazo-weld-integration.zip](https://github.com/user-attachments/files/25642344/jersey-krazo-weld-integration.zip)

Contributor guide

Open the contributing guide

Research direction

Start by running the attached Maven reproducer with `java -jar target/jersey-krazo-weld-integration-0.0.0.jar` and inspect `src/main/resources/META-INF/services/org.eclipse.krazo.core.HttpCommunicationUnwrapper`. Compare the Jersey integration with the Weld unwrapper added for RESTEasy in #365. Done means the endpoint at `/context/servlet/resource/method` works without the exception when the Jersey integration is enabled.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.