Search code examples
swaggerjax-rswebsphere

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


I have a JAX-RS application running into Websphere 9.0 using Swagger.

We catch the stacktrace below. Does anyone have any idea on how to resolve?

StackTrace

javax.ws.rs.ClientErrorException: HTTP 404 Not Found at org.apache.cxf.jaxrs.utils.SpecExceptions.toHttpException(SpecExceptions.java:117) 12 lines skipped for [org.apache.cxf] at com.ibm.ws.jaxrs20.endpoint.AbstractJaxRsWebEndpoint.invoke(AbstractJaxRsWebEndpoint.java:147) at com.ibm.websphere.jaxrs.server.IBMRestServlet.handleRequest(IBMRestServlet.java:192) at com.ibm.websphere.jaxrs.server.IBMRestServlet.doGet(IBMRestServlet.java:158) 1 line skipped for [javax.servlet] at com.ibm.websphere.jaxrs.server.IBMRestServlet.service(IBMRestServlet.java:138) at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1235) at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:779) at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478) at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:179) at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1134) at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:82) at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:966) at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1817) at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:382) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:465) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:532) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:318) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:289) at com.ibm.ws.ssl.channel.impl.SSLConnectionLink.determineNextChannel(SSLConnectionLink.java:1187) at com.ibm.ws.ssl.channel.impl.SSLConnectionLink$MyReadCompletedCallback.complete(SSLConnectionLink.java:694) at com.ibm.ws.ssl.channel.impl.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1833) at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175) at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217) at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161) at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138) at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204) at 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) Caused by: java.lang.NumberFormatException: For input string: "null" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:76) at java.lang.Integer.parseInt(Integer.java:592) at java.lang.Integer.(Integer.java:879) 3 lines skipped for [sun.] at java.lang.reflect.Constructor.newInstance(Constructor.java:437) 1 line skipped for [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>

Solution

  • Please add this dependency io.swagger:swagger-models:1.6.1. I guess you forgot to add this.

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

    See if this works.