0

I'm experimenting the apiDiscovery-1.0 feature with a swagger generated server (exported from editor.swagger.io). The pom.xml file includes

<swagger-core-version>1.5.9</swagger-core-version>

If I push the generated war without specifying a server.xml file, just the war of my app, I am able to get to http://.eu-gb.mybluemix.net/v1/swagger.json

The same does not happen if I push the war with a server.xml including the

<feature>apiDiscovery-1.0</feature>

In that case I get the following exception when pointing at http://.eu-gb.mybluemix.net/v1/swagger.json

2016-09-21T00:34:15.05+0200 [App/0]      ERR [ERROR   ] SRVE0777E: Exception thrown by application class 'org.glassfish.jersey.servlet.WebComponent.serviceImpl:489'
2016-09-21T00:34:15.05+0200 [App/0]      ERR javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException: java.lang.NoSuchMethodError: io/swagger/annotations/ApiParam.examples()Lio/swagger/annotations/Example; (loaded from file:/home/vcap/app/.liberty/dev/api/third-party/com.ibm.websphere.appserver.thirdparty.swagger.annotations_1.0.14.jar by org.eclipse.osgi.internal.loader.EquinoxClassLoader@1a477115[com.ibm.websphere.appserver.thirdparty.swagger.annotations:1.0.14.cl160320160831-1555(id=113)]) called from class io.swagger.util.ParameterProcessor$ApiParamWrapper (loaded from file:/home/vcap/app/wlp/usr/servers/defaultServer/apps/servicemanager-jaxrs-server-1.0.0.war/WEB-INF/lib/swagger-core-1.5.9.jar by com.ibm.ws.classloading.internal.AppClassLoader@efe5e076).
2016-09-21T00:34:15.05+0200 [App/0]      ERR    at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:489)
2016-09-21T00:34:15.05+0200 [App/0]      ERR    at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427)
2016-09-21T00:34:15.05+0200 [App/0]      ERR    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388)
2016-09-21T00:34:15.05+0200 [App/0]      ERR    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341)
2016-09-21T00:34:15.05+0200 [App/0]      ERR    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228)
2016-09-21T00:34:15.05+0200 [App/0]      ERR    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1290)
2016-09-21T00:34:15.05+0200 [App/0]      ERR    at [internal classes]
2016-09-21T00:34:15.05+0200 [App/0]      ERR    at io.swagger.api.ApiOriginFilter.doFilter(ApiOriginFilter.java:16)
2016-09-21T00:34:15.05+0200 [App/0]      ERR    at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:207)
2016-09-21T00:34:15.05+0200 [App/0]      ERR    at [internal classes]
2016-09-21T00:34:15.05+0200 [App/0]      ERR Caused by: org.glassfish.jersey.server.ContainerException: java.lang.NoSuchMethodError: io/swagger/annotations/ApiParam.examples()Lio/swagger/annotations/Example; (loaded from file:/home/vcap/app/.liberty/dev/api/third-party/com.ibm.websphere.appserver.thirdparty.swagger.annotations_1.0.14.jar by org.eclipse.osgi.internal.loader.EquinoxClassLoader@1a477115[com.ibm.websphere.appserver.thirdparty.swagger.annotations:1.0.14.cl160320160831-1555(id=113)]) called from class io.swagger.util.ParameterProcessor$ApiParamWrapper (loaded from file:/home/vcap/app/wlp/usr/servers/defaultServer/apps/servicemanager-jaxrs-server-1.0.0.war/WEB-INF/lib/swagger-core-1.5.9.jar by com.ibm.ws.classloading.internal.AppClassLoader@efe5e076).
2016-09-21T00:34:15.05+0200 [App/0]      ERR    at org.glassfish.jersey.servlet.internal.ResponseWriter.rethrow(ResponseWriter.java:278)
2016-09-21T00:34:15.05+0200 [App/0]      ERR    at org.glassfish.jersey.servlet.internal.ResponseWriter.failure(ResponseWriter.java:260)
2016-09-21T00:34:15.05+0200 [App/0]      ERR    at org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:509)
2016-09-21T00:34:15.05+0200 [App/0]      ERR    at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:334)
2016-09-21T00:34:15.05+0200 [App/0]      ERR    at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
2016-09-21T00:34:15.05+0200 [App/0]      ERR    at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
2016-09-21T00:34:15.05+0200 [App/0]      ERR    at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
2016-09-21T00:34:15.05+0200 [App/0]      ERR    at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
2016-09-21T00:34:15.05+0200 [App/0]      ERR    at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
2016-09-21T00:34:15.05+0200 [App/0]      ERR    at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
2016-09-21T00:34:15.05+0200 [App/0]      ERR    at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305)
2016-09-21T00:34:15.05+0200 [App/0]      ERR    at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154)
2016-09-21T00:34:15.05+0200 [App/0]      ERR    at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:473)
2016-09-21T00:34:15.05+0200 [App/0]      ERR    ... 9 more
2016-09-21T00:34:15.05+0200 [App/0]      ERR Caused by: java.lang.NoSuchMethodError: io/swagger/annotations/ApiParam.examples()Lio/swagger/annotations/Example; (loaded from file:/home/vcap/app/.liberty/dev/api/third-party/com.ibm.websphere.appserver.thirdparty.swagger.annotations_1.0.14.jar by org.eclipse.osgi.internal.loader.EquinoxClassLoader@1a477115[com.ibm.websphere.appserver.thirdparty.swagger.annotations:1.0.14.cl160320160831-1555(id=113)]) called from class io.swagger.util.ParameterProcessor$ApiParamWrapper (loaded from file:/home/vcap/app/wlp/usr/servers/defaultServer/apps/servicemanager-jaxrs-server-1.0.0.war/WEB-INF/lib/swagger-core-1.5.9.jar by com.ibm.ws.classloading.internal.AppClassLoader@efe5e076).

If I comment the server.xml line

<feature>apiDiscovery-1.0</feature>

and push again the app, it works, I get back the swagger.json file.

Note that the /ibm/api/explorer does not show the API I defined in my swagger.json. I guess the exception is the root cause. What I noticed is the version of swagger reported in the exception:

javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException: java.lang.NoSuchMethodError: io/swagger/annotations/ApiParam.examples()Lio/swagger/annotations/Example; (loaded from file:/home/vcap/app/.liberty/dev/api/third-party/com.ibm.websphere.appserver.thirdparty.swagger.annotations_1.0.14.jar by 

which is different from the build version: 1.5.9.

Any idea? Thanks.

1 Answers1

0

Yes, as of today (09/20/2016), the Swagger annotation version that Liberty's API discovery is using 1.5.3, which is why the exception is being thrown for the newer attributes of ApiParam.

If you compile your application against the Liberty Swagger annotations found at wlp/dev/api/third-party/com.ibm.websphere.appserver.thirdparty.swagger.annotations_1.0.14.jar (you can get this free from wasdev.net by downloading the base WLP zip, and then running "wlp/bin installUtility install apiDiscovery-1.0" on it), OR point your maven dependency to the 1.5.3 repo: https://mvnrepository.com/artifact/io.swagger/swagger-annotations/1.5.3, then you'll see the deltas. After fixing them up you should be able to happily deploy and see them in /ibm/api/explorer.

I will take this feedback to the team to update the jar, so stay tuned for the next few Betas.

ArthurDM
  • 403
  • 3
  • 6
  • I changed the pom.xml to point to 1.5.3 and back ported the generated Bootstrap class. I do not get the exception anymore, so I can get the json. However, I still not see my API in the /ibm/api/explorer. The only api I see is the apiDiscovery. What else did I miss? – michele crudele Sep 21 '16 at 14:15
  • Can you try using the "Jaxrs Spec" flavour of the editor generation (instead of the jersey one)? We contributed that about a month ago, and it gets rid of 3rd party dependencies that often interfere with our API processor. – ArthurDM Sep 21 '16 at 15:36