javaMan javaMan - 1 year ago 349
Java Question

How to deploy Swagger generated JAXRS server code in Websphere

I generated JAX-RS server code for Uber API example in swagger. It is the default Json which can be found by opening

Now I tried to deploy it in websphere but I see below message:

Error 404: javax.servlet.ServletException: SRVE0190E: File not found: /v1/swagger.json

when I access this url: http://localhost:9080/swagger-jaxrs-server/v1/swagger.json

I didn't make any changes to auto generated code.

I am using wlp-javaee7-

This is how my server.xml file looks like:

<server description="new server">

<!-- Enable features -->

<basicRegistry id="basic" realm="BasicRealm">
<!-- <user name="yourUserName" password="" /> -->

<!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" -->
<httpEndpoint httpPort="9080" httpsPort="9443" id="defaultHttpEndpoint"/>

<!-- Automatically expand WAR files and EAR files -->
<applicationManager autoExpand="true"/>

<applicationMonitor updateTrigger="mbean"/>

<webApplication id="swagger-jaxrs-server" location="swagger-jaxrs-server.war" name="swagger-jaxrs-server"/>

Can someone point what is missing here.


This URL is working fine: http://localhost:8080/swagger-jaxrs-server/swagger.json. This is the part of Json :

enter image description here

So, I tried the below two urls.. but both didn't work.


I don't see web.xml with autogenerated code.

Answer Source

This path would almost work: http://localhost:9080/swagger-jaxrs-server/swagger.json for serving the json file (where swagger-jaxrs-server is the implied context root), though it overlaps with the @ApplicationPath("/") in the generated war. BUT...

The issue is with the context root.

The swagger.json has "basePath" : "/v1", but doesn't include anything in the generated classes to change that base path to include the v1, and servlet containers are somewhat limited in how they allocate context roots.

I would suggest tweaking the generated RestApplication so it has @ApplicationPath("/v1"), in which case http://localhost:9080/swagger-jaxrs-server/swagger.json would work to retrieve the json, and http://localhost:9080/swagger-jaxrs-server/v1/products would match the expected REST endpoints.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download