Over a million developers have joined DZone.

Ask DZ: Swagger API on Multiple OSGI Bundles Using Apache Karaf

This author is having an issue with a possible caching issue dealing with Swagger's api-docs. Think you may know a solution to his conundrum? Leave a comment!

· Integration Zone

Build APIs from SQL and NoSQL or Salesforce data sources in seconds. Read the Creating REST APIs white paper, brought to you in partnership with CA Technologies.

I have created Java RESTful web services using Apache Karaf, using Swagger for API documentation. All annotations are applied, and it's running successfully on a single OSGI bundle with the general Swagger configuration (Swagger core and the annotations JAR) with Apache Karaf on standalone mode.


While running Swagger on multiple OSGI bundles, it is catching the result generated while hitting "/api-docs" on the very first WSDL, and it returns the same for other WSDL's as well.


Let's say I have two web services exposed as below:

  1. "http:/localhost:8181/cxf/abc?_wadl"

  2. "http:/localhost:8181/cxf/xyz?_wadl"

The web services are exposed on two different OSGI bundles and all the configurations are written in their respective "bluprint.xml" files. The Swagger Core and Swagger annotations dependencies are located in each project's pom.xml.

When I run Swagger API on the first WSDL:


it returns the result successfully, but on hitting Swagger on the second WSDL:


it returned the same result, which was initially produced by the first WSDL. It cached the first WSDL JSON somewhere and always returns the initial result.

My Questions

  1. Is there any other way to run the Swagger API on Multiple OSGI bundles using Apache Karaf?

  2. Is there any way we can permanently disable the caching using this Karaf/Swagger configuration?

  3. Is there any method to clear the Swagger cache (which got created when I made a hit to http:/localhost:8181/cxf/abc/api-docs) when hitting Swagger for the next OSGI bundles (http:/localhost:8181/cxf/xyz/api-docs), so it rescans the API annotations and doesn't return the cached result?

Note: I have implemented the Swagger API on OSGI bundles using: https://github.com/ddragosd/jax-rs-on-karaf

The Integration Zone is brought to you in partnership with CA Technologies.  Use CA Live API Creator to quickly create complete application backends, with secure APIs and robust application logic, in an easy to use interface.

cxf ,java 1.7 ,swagger ,osgi ,restful web service

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}