-
Notifications
You must be signed in to change notification settings - Fork 369
Description
JAX-RS section 3.5 says:
In the absence of either of these annotations, support for any media type (“*/*”) is assumed.
We have applications that run on Java 11, do not declare @Consumes, and have endpoints like this, which rely on a custom media type:
@POST
@Path("/test")
public void test(@Context HttpServletRequest req, @Context HttpServletResponse resp) throws Exception {
This approach was working in Jersey 3.0.0, but as of Jersey 3.0.1, the client now receives HTTP 415:
Exception
2021-02-15 21:31:51,283 DEBUG [http-8082-27] o.g.j.s.ServerRuntime$Responder [ServerRuntime.java:566] [] WebApplicationException (WAE) with no entity thrown and no ExceptionMappers have been found for this WAE. Response with status 415 is directly generated from the WAE.
jakarta.ws.rs.NotSupportedException: HTTP 415 Unsupported Media Type
at org.glassfish.jersey.server.internal.routing.MethodSelectingRouter.getMethodRouter(MethodSelectingRouter.java:412)
at org.glassfish.jersey.server.internal.routing.MethodSelectingRouter.access$000(MethodSelectingRouter.java:73)
at org.glassfish.jersey.server.internal.routing.MethodSelectingRouter$4.apply(MethodSelectingRouter.java:665)
at org.glassfish.jersey.server.internal.routing.MethodSelectingRouter.apply(MethodSelectingRouter.java:305)
at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:86)
at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:89)
at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:89)
at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:89)
at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:69)
at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:38)
at org.glassfish.jersey.process.internal.Stages.process(Stages.java:173)
at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:247)
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:265)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:234)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:680)
at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:394)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:346)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:366)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:319)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:205)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:761)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:517)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:226)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1355)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:181)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:472)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:179)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1279)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:134)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
at org.eclipse.jetty.server.Server.handle(Server.java:567)
at org.eclipse.jetty.server.HttpChannel.lambda$handle$0(HttpChannel.java:404)
at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:661)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:396)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:289)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:324)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
at org.eclipse.jetty.io.SocketChannelEndPoint$1.run(SocketChannelEndPoint.java:106)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:790)
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:912)
at java.base/java.lang.Thread.run(Thread.java:829)
From a brief investigation, it appears that in 3.0.0, the @Consumes("*/*") on XmlRootObjectJaxbProvider was being detected by MethodSelectingRouter, but this is presumably longer happening as of #4634. Our application does not use JAXB at all, but adding explicit jakarta.xml.bind-api and jersey-media-jaxb dependencies works around the issue (this workaround is not really satisfactory, but was done to illustrate the point).