javax.ws.rs.ClientErrorException:在使用 Swagger 的 Websphere 9 上找不到 HTTP 404

javax.ws.rs.ClientErrorException: HTTP 404 Not Found on Websphere 9 using Swagger

提问人:Luciana Oliveira 提问时间:10/19/2023 最后编辑:BalusCLuciana Oliveira 更新时间:10/20/2023 访问量:86

问:

我有一个使用 SwaggerWebsphere 9.0 中运行的 JAX-RS 应用程序。

我们捕获下面的堆栈跟踪。有谁知道如何解决?

堆栈跟踪

javax.ws.rs.ClientErrorException:在 org.apache.cxf.jaxrs.utils.SpecExceptions.toHttpException(SpecExceptions.java:117) 跳过 [org.apache.cxf] 的 12 行 com.ibm.ws.jaxrs20.endpoint.AbstractJaxRsWebEndpoint.invoke(AbstractJaxRsWebEndpoint.java:147) 在 com.ibm.websphere.jaxrs.server.IBMRestServlet.handleRequest(IBMRestServlet.java:192) 在 com.ibm.websphere.jaxrs.server.IBMRestServlet.doGet(IBMRestServlet.java:158) 跳过 [javax.servlet] 的 1 行 com.ibm.websphere.jaxrs.server.IBMRestServlet.service(IBMRestServlet.java:138) 在 com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1235) 在 com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:779) 在 com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478) 在 com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:179) 在 com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1134) 在 com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:82) 在 com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:966) 在 com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1817) 在 com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:382) 在 com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:465) 在 com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:532) 在 com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:318) 在 com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:289) 在 com.ibm.ws.ssl.channel.impl.SSLConnectionLink.determineNextChannel(SSLConnectionLink.java:1187) 在 com.ibm.ws.ssl.channel.impl.SSLConnectionLink$MyReadCompletedCallback.complete(SSLConnectionLink.java:694) 在 com.ibm.ws.ssl.channel.impl.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1833) 在 com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175) 在 com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217) 在 com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161) 在 com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138) 在 com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204) 位于 com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775) at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905) at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1909) 引起: java.lang.NumberFormatException:对于输入字符串:“null” java.lang.NumberFormatException.forInputString(NumberFormatException.java:76) 在 java.lang.Integer.parseInt(Integer.java:592) 在 java.lang.Integer。(整数.java:879) 跳过 3 行 [周日]在 java.lang.reflect.Constructor.newInstance(构造函数.java:437) 1 跳过 [org.apache.cxf] 的行

pom.xml:

<dependencies>
    <dependency>
         <groupId>io.swagger</groupId>
         <artifactId>swagger-annotations</artifactId>
         <version>1.6.1</version>
         <scope>provided</scope>
    </dependency>
</dependencies>

<profiles>
    <profile>
        <id>gerar-swagger</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>com.github.kongchen</groupId>
                    <artifactId>swagger-maven-plugin</artifactId>
                    <version>3.1.8</version>
                    <configuration>
                        <apiSources>
                            <apiSource>
                                <springmvc>false</springmvc>
                                <locations>
                                    <location>br.com.api</location>
                                </locations>
                                <schemes>
                                    <schemes>http</schemes>
                                    <schemes>https</schemes>
                                </schemes>
                                <host>hostName</host>
                                <basePath>/dir/v1</basePath>
                                <outputFormats>yaml</outputFormats>
                                <swaggerDirectory>${basedir}</swaggerDirectory>
                                <info>
                                    <title>API</title>
                                    <version>1.2.3.23</version>
                                    <description> API </description>
                                </info>
                            </apiSource>
                        </apiSources>
                    </configuration>
                    <executions>
                        <execution>
                            <phase>compile</phase>
                            <goals>
                                <goal>generate</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>
摇大摆 JAX-RS WebSphere

评论

0赞 Luciana Oliveira 10/19/2023
我们使用的是 1.6.2 (swagger-annotations) 和 3.1.8 (sugger-maven-plugin)。你能建议版本吗?
0赞 Luciana Oliveira 10/19/2023
我只能分享pom的这一部分。不可能分享大摇大摆。
0赞 Anish B. 10/19/2023
你没有在你的pom.xml中添加swagger模型吗?<dependency> <groupId>io.swagger</groupId> <artifactId>swagger-models</artifactId> <version>1.5.21</version> </dependency>
0赞 Luciana Oliveira 10/20/2023
是的,这是工作。

答:

1赞 Anish B. 10/19/2023 #1

请添加此依赖项。我猜你忘了添加这个。io.swagger:swagger-models:1.6.1

<dependency>
    <groupId>io.swagger</groupId>
    <artifactId>swagger-models</artifactId>
    <version>1.6.1</version>
</dependency>

看看这是否有效。