我正在将quarkus从1.x升级到3.6,这需要从javax
迁移到jakarta
。
在将javax
更改为jakarta
后,部分API unittest开始出现给予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/
,然后路径可以匹配......这种行为对我来说没有多大意义。
有人遇到过类似的问题吗?
1条答案
按热度按时间o4hqfura1#
该资源看起来正常,并在新的Quarkus 3.2项目中工作。您可能有一些配置或依赖关系中断了路径。
检查application.properties中是否没有定义HTTP基本URL。
打开http://localhost:8080/q/dev-ui/和http://localhost:8080/q/dev-ui/io. quarkus. quarkus-resteasy-reactive/endpoint-scores,您可以在其中查看应用程序的已注册端点。
x1c 0d1x的数据
找到导致问题的原因的一种方法是注解/禁用部分代码,直到找到破坏它的原因或将代码移动到新项目。