cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Akitoshi Yoshida (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CXF-6904) Unable to read swagger annotations if the file is in another osgi bundle
Date Wed, 18 May 2016 12:57:13 GMT

    [ https://issues.apache.org/jira/browse/CXF-6904?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15288904#comment-15288904
] 

Akitoshi Yoshida commented on CXF-6904:
---------------------------------------

A temporary workaround that worked for me is to add a dummy resource in the api bundle (eg.,
an empty file named api in cxf-swagger2-osgi-api/src//main/resources/demo/jaxrs/swagger/server/)
and update the impl bundle's blueprint.xml to have this resource listed as well (i.e., this
is not a package but adding this will instruct ClasspathHelper.fromPackage to look up a resource
demo/jaxrs/swagger/server/api and will find the api bundle url)
        <property name="resourcePackage" value="demo.jaxrs.swagger.server,demo.jaxrs.swagger.server.api"/>
With this change, the both bundle urls are added to the reflection's config object and its
reflections.getTypesAnnotatedWith(Path.class) etc will find the annotated classes from the
api bundle.

When I use a similar set up in webapp+spring, where the annotated classes are placed in the
api.jar and the impl/beans/web.xml part in impl.war, without the above workaround, CasspathHelper.fromPackage
finds both classpath urls and the annotated classes are found.

In contrast, with the osgi setup, if we have only <property name="resourcePackage" value="demo.jaxrs.swagger.server"/>,
ClasspathHelper.fromPackage will only add the impl's bundle url to the reflection's config.
As a result, reflections.getTypesAnnotatedWith(Path.class) etc are not finding any annotated
classes.
Even with the honorInherited option of reflections.getTypesAnnotatedWith(Path.class, true)
to look up in the annotations from its super classes because it doesn't lookup for the non
Inherited annotations ( https://docs.oracle.com/javase/7/docs/api/java/lang/annotation/Inherited.html)

If someone has a suggestion in resolving this problem without adding a dummy resource, that
would be appreciated.



> Unable to read swagger annotations if the file is in another osgi bundle
> ------------------------------------------------------------------------
>
>                 Key: CXF-6904
>                 URL: https://issues.apache.org/jira/browse/CXF-6904
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS, OSGi
>            Reporter: Christian Lutz
>
> I created a simple example to reproduce the error.
> https://github.com/ChristianLutz/cxf-swagger-osgi-bug
> =================
> JAX-RS Swagger2Feature OSGI Issue
> =================
> This example is based on the code from 
> https://github.com/apache/cxf/tree/master/distribution/src/main/release/samples/jax_rs/description_swagger2_osgi
> 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:
>   http://cxf.547215.n5.nabble.com/Swagger2Feature-via-blueprint-config-does-not-produce-the-expected-results-td5761841.html



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message