cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Łukasz Dywicki (JIRA) <>
Subject [jira] [Commented] (CXF-6904) Unable to read swagger annotations if the file is in another osgi bundle
Date Wed, 17 Aug 2016 18:24:20 GMT


Łukasz Dywicki commented on CXF-6904:

Hey Sergey,
Thanks for your efforts, sadly it doesn't help. To get Application in use we need JaxrsScanner,
and JaxrsScanner is not registered in servlet context.. which is yet another problem.

During debugging I've found that Swagger internally pass some informations over servlet context
and register beanconfig there. It doesn't happen with JaxrsScanner. More over swagger instances
are cached in servlet context. This is minor issue (updates in code are ignored unless some
bundles get refreshed) compared to second thing I've found. There is one "global" scanner
instance registered under default key which is used everywhere. I'm pretty sure current swagger
integration will return swagger descriptor for first loaded endpoint and ommit scanning for
others - this is affecting regular deployments as well unless there are separate servlets
for each "swaggerized" endpoint.

In case of servlet transport embedded inside Karaf this is out of control of developer who
deploys service. Only one way I got it partially working was replacing bean config with:
        ScannerFactory.setScanner(new DefaultJaxrsScanner());

ScannerFactory is last resort used by swagger when it can not find any scanner in servlet
context. This is static instance used everywhere, sadly there is no description generated,
no base path, nothing at all, so descriptor is not valid.

> Unable to read swagger annotations if the file is in another osgi bundle
> ------------------------------------------------------------------------
>                 Key: CXF-6904
>                 URL:
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS, OSGi
>            Reporter: Christian Lutz
> I created a simple example to reproduce the error.
> =================
> JAX-RS Swagger2Feature OSGI Issue
> =================
> This example is based on the code from 
> How to reproduce the issue:
>   mvn install (on the example)
>   bin/karaf (I used the current karaf 4.0.5)
>   on karaf@root()>
>   feature:repo-add cxf 3.1.6
>   feature:install cxf-rs-description-swagger2
>   install mvn:com.fasterxml.jackson.jaxrs/jackson-jaxrs-base/2.6.5
>   install mvn:com.fasterxml.jackson.jaxrs/jackson-jaxrs-json-provider/2.6.5
>   install -s mvn:de.kreeloo/cxf-swagger2-osgi-api/1.0.0
>   install -s mvn:de.kreeloo/cxf-swagger2-osgi-impl/1.0.0
> It may happen that one component is complaining about a missing guava class even if you
provided it before. All you have todo is copy guava-18.jar into your deploy folder. I think
this is a karaf bug. I have to create a ticket for. After you place the guava file into your
deploy folder and type list, all bundles should be active.  
>   Now open your web browser and type: 
>   http://localhost:8181/cxf/swaggerSample/swagger.json
>   And all you see is the swagger header.
>   I guess the problem is the ClasspathHelper.class from org.reflections it looks like
that this one is not able to access the osgi component. 
>   The behavior is similar to this error description:

This message was sent by Atlassian JIRA

View raw message