我正在将 quarkus 从 1.x 升级到 3.6,这需要从
javax
迁移到 jakarta
。
部分 API 单元测试在将
javax
更改为 jakarta
后开始给出 404 错误。
对于这些失败,我发现请求甚至没有到达控制器功能,表明 API 路径无法匹配。
API 的定义如下:
@Path("/api/topology-graph")
public class Resource {
@POST
@Path("/v1/maps/{map-id}/omap-stats")
public Response addStats(@PathParam("map-id") Long mapId) {
...
}
@GET
@Path("/v1/maps/{map-id}/omap-stats/edges/{edge-id}/age")
public Response getAge(
@PathParam("map-id") Long mapId,
@PathParam("edge-id") Long edgeId) {
...
}
}
Quarkus 日志:
2023-12-25 21:17:20,161 DEBUG [io.qua.mic.run.bin.ver.VertxHttpServerMetrics] (vert.x-eventloop-thread-1) requestRouted null HttpRequestMetric [initialPath=/api/topology-graph/v1/maps/1/omap-stats, currentRoutePath=null, templatePath=null, request=io.vertx.core.http.impl.Http1xServerRequest@5d258289]
2023-12-25 21:17:20,165 DEBUG [io.qua.mic.run.bin.ver.VertxHttpServerMetrics] (vert.x-eventloop-thread-1) requestRouted null HttpRequestMetric [initialPath=/api/topology-graph/v1/maps/1/omap-stats, currentRoutePath=null, templatePath=null, request=io.vertx.core.http.impl.Http1xServerRequest@5d258289]
2023-12-25 21:17:20,166 DEBUG [io.qua.mic.run.bin.ver.VertxHttpServerMetrics] (vert.x-eventloop-thread-1) requestRouted null HttpRequestMetric [initialPath=/api/topology-graph/v1/maps/1/omap-stats, currentRoutePath=null, templatePath=null, request=io.vertx.core.http.impl.Http1xServerRequest@5d258289]
2023-12-25 21:17:20,166 DEBUG [io.qua.mic.run.bin.ver.VertxHttpServerMetrics] (vert.x-eventloop-thread-1) requestRouted null HttpRequestMetric [initialPath=/api/topology-graph/v1/maps/1/omap-stats, currentRoutePath=null, templatePath=null, request=io.vertx.core.http.impl.Http1xServerRequest@5d258289]
2023-12-25 21:17:20,166 DEBUG [io.qua.mic.run.bin.ver.VertxHttpServerMetrics] (vert.x-eventloop-thread-1) requestRouted / HttpRequestMetric [initialPath=/api/topology-graph/v1/maps/1/omap-stats, currentRoutePath=null, templatePath=null, request=io.vertx.core.http.impl.Http1xServerRequest@5d258289]
2023-12-25 21:17:20,166 DEBUG [WebApplicationException] (vert.x-eventloop-thread-1) Restarting handler chain for exception exception: jakarta.ws.rs.NotFoundException: HTTP 404 Not Found
at org.jboss.resteasy.reactive.server.handlers.RestInitialHandler.handle(RestInitialHandler.java:71)
at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:121)
at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:147)
at org.jboss.resteasy.reactive.server.handlers.RestInitialHandler.beginProcessing(RestInitialHandler.java:48)
at org.jboss.resteasy.reactive.server.vertx.ResteasyReactiveVertxHandler.handle(ResteasyReactiveVertxHandler.java:23)
at org.jboss.resteasy.reactive.server.vertx.ResteasyReactiveVertxHandler.handle(ResteasyReactiveVertxHandler.java:10)
at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1286)
at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:177)
at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:144)
at io.quarkus.vertx.http.runtime.options.HttpServerCommonHandlers$1.handle(HttpServerCommonHandlers.java:59)
at io.quarkus.vertx.http.runtime.options.HttpServerCommonHandlers$1.handle(HttpServerCommonHandlers.java:37)
at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1286)
at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:177)
at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:144)
at io.quarkus.resteasy.reactive.server.runtime.ResteasyReactiveRecorder$13.handle(ResteasyReactiveRecorder.java:339)
at io.quarkus.resteasy.reactive.server.runtime.ResteasyReactiveRecorder$13.handle(ResteasyReactiveRecorder.java:332)
at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1286)
at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:177)
at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:144)
at io.quarkus.vertx.http.runtime.cors.CORSFilter.handle(CORSFilter.java:199)
at io.quarkus.vertx.http.runtime.cors.CORSFilter.handle(CORSFilter.java:21)
at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1286)
at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:177)
at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:144)
at io.quarkus.vertx.http.runtime.devmode.VertxHttpHotReplacementSetup$4.handle(VertxHttpHotReplacementSetup.java:192)
at io.quarkus.vertx.http.runtime.devmode.VertxHttpHotReplacementSetup$4.handle(VertxHttpHotReplacementSetup.java:181)
at io.vertx.core.impl.future.FutureImpl$3.onSuccess(FutureImpl.java:141)
at io.vertx.core.impl.future.FutureBase.lambda$emitSuccess$0(FutureBase.java:54)
at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:173)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:166)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:840)
2023-12-25 21:17:20,167 DEBUG [io.qua.mic.run.bin.ver.VertxHttpServerMetrics] (vert.x-eventloop-thread-1) responseEnd io.vertx.core.http.impl.Http1xServerResponse@5e5431c7, HttpRequestMetric [initialPath=/api/topology-graph/v1/maps/1/omap-stats, currentRoutePath=/, templatePath=null, request=io.vertx.core.http.impl.Http1xServerRequest@5d258289]
我做了更多实验,将
/v1/maps/
更改为/v2/maps/
,然后路径就可以匹配了......这种行为对我来说没有多大意义。
有人遇到过类似问题吗