从javax迁移到jaktron后,API路径匹配失败

cczfrluj  于 2024-01-05  发布在  Java
关注(0)|答案(1)|浏览(175)

我正在将quarkus从1.x升级到3.6,这需要从javax迁移到jakarta
在将javax更改为jakarta后,部分API unittest开始出现给予404错误。对于这些故障,我发现请求甚至没有到达控制器函数,这表明API路径匹配失败。
API是这样定义的:

  1. @Path("/api/topology-graph")
  2. public class Resource {
  3. @POST
  4. @Path("/v1/maps/{map-id}/omap-stats")
  5. public Response addStats(@PathParam("map-id") Long mapId) {
  6. ...
  7. }
  8. @GET
  9. @Path("/v1/maps/{map-id}/omap-stats/edges/{edge-id}/age")
  10. public Response getAge(
  11. @PathParam("map-id") Long mapId,
  12. @PathParam("edge-id") Long edgeId) {
  13. ...
  14. }
  15. }

字符串
Quarkus日志:

  1. 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]
  2. 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]
  3. 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]
  4. 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]
  5. 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]
  6. 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
  7. at org.jboss.resteasy.reactive.server.handlers.RestInitialHandler.handle(RestInitialHandler.java:71)
  8. at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:121)
  9. at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:147)
  10. at org.jboss.resteasy.reactive.server.handlers.RestInitialHandler.beginProcessing(RestInitialHandler.java:48)
  11. at org.jboss.resteasy.reactive.server.vertx.ResteasyReactiveVertxHandler.handle(ResteasyReactiveVertxHandler.java:23)
  12. at org.jboss.resteasy.reactive.server.vertx.ResteasyReactiveVertxHandler.handle(ResteasyReactiveVertxHandler.java:10)
  13. at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1286)
  14. at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:177)
  15. at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:144)
  16. at io.quarkus.vertx.http.runtime.options.HttpServerCommonHandlers$1.handle(HttpServerCommonHandlers.java:59)
  17. at io.quarkus.vertx.http.runtime.options.HttpServerCommonHandlers$1.handle(HttpServerCommonHandlers.java:37)
  18. at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1286)
  19. at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:177)
  20. at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:144)
  21. at io.quarkus.resteasy.reactive.server.runtime.ResteasyReactiveRecorder$13.handle(ResteasyReactiveRecorder.java:339)
  22. at io.quarkus.resteasy.reactive.server.runtime.ResteasyReactiveRecorder$13.handle(ResteasyReactiveRecorder.java:332)
  23. at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1286)
  24. at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:177)
  25. at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:144)
  26. at io.quarkus.vertx.http.runtime.cors.CORSFilter.handle(CORSFilter.java:199)
  27. at io.quarkus.vertx.http.runtime.cors.CORSFilter.handle(CORSFilter.java:21)
  28. at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1286)
  29. at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:177)
  30. at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:144)
  31. at io.quarkus.vertx.http.runtime.devmode.VertxHttpHotReplacementSetup$4.handle(VertxHttpHotReplacementSetup.java:192)
  32. at io.quarkus.vertx.http.runtime.devmode.VertxHttpHotReplacementSetup$4.handle(VertxHttpHotReplacementSetup.java:181)
  33. at io.vertx.core.impl.future.FutureImpl$3.onSuccess(FutureImpl.java:141)
  34. at io.vertx.core.impl.future.FutureBase.lambda$emitSuccess$0(FutureBase.java:54)
  35. at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:173)
  36. at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:166)
  37. at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
  38. at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569)
  39. at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
  40. at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
  41. at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
  42. at java.base/java.lang.Thread.run(Thread.java:840)
  43. 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/,然后路径可以匹配......这种行为对我来说没有多大意义。
有人遇到过类似的问题吗?

o4hqfura

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的数据
找到导致问题的原因的一种方法是注解/禁用部分代码,直到找到破坏它的原因或将代码移动到新项目。

相关问题