Hi Sergey,
thanks for the reply.
I have also another problem using swagger with my endPoint: when I use the 
swagger ui to obtain the api list an exception occurs.
I created a simple java project that should public the endPoint via java code 
and without configuration xml files.
I
 attach the zip folder to this forum...the entry point is 
"SwaggerTest.java" main method (it can be launched as a simple java 
application), the RestPublicDocs.java class is the implementor: this 
class contains both the static method to publish the endPoint 
("publishEndpoint()" method called from the main), with address and port
 info (you can change them in this class), both the endPoints annotations
 and other info required by swagger.
It seems to publish the ws succesful but testing via swagger ui this problems 
occurs:
- a "No message body writer has been found for response class ResourceListing" 
is printed and no response is shown 
(this calling the http://localhost:8162/PubDocs/api-docs from swagger ui)
I've attached the project and the list of the jar required. 
The example I've followed (with some differences to publish cxf endPoint via 
java source code without xml configuration file) is this:
https://github.com/wordnik/swagger-core/tree/develop-1.3/samples/java-jaxrs-cxf

Any suggestion is welcome :-)
Thanks a lot,


Andrea

Date: Tue, 4 Jun 2013 13:10:32 -0700
From: [email protected]
To: [email protected]
Subject: Re: CXF and swagger



        On 04/06/13 19:03, eanbiso wrote:

> I'm sorry, I have not explained clearly,

> I was referring to the call of the other endPoint.

> I try to explain:

> whit the annotation

>      @Path("/PubDocs.json")

>

> in the RestPublicDocsJSON class, when I call the endPoint

>       http://localhost:8162/PubDocs/isReady
> the call fails with the exception described;

> without the @Path annotation in the RestPublicDocsJSON class,

> the call at the  http://localhost:8162/PubDocs/isReady begins to function 
> properly and return true.
Well, I can only assume then that a superclass has @Path("/PubDocs"), 

which becomes visible once @Path("/PubDocs.json") is dropped, otherwise 

@Path("/PubDocs.json") simply overrides the super class @Path is  any, 

nothing unusual there


Sergey


>

> Andrea

>

> Date: Tue, 4 Jun 2013 09:57:19 -0700

> From: [hidden email]

> To: [hidden email]

> Subject: Re: CXF and swagger

>

>

>

>       Hi

>

> On 04/06/13 17:35, eanbiso wrote:

>

>> Hi Sergey,

>

>> I've tried but the same problem occurs.

>

>> the only ways to call the ws without exceptions seem to be:

>

>> 1) remove the annotation @Path

>

>> 2) or replace it with general @Path("/")

>

>>

>

> Hmm, so which URI works ?

>

> When you have

>

>

> @Path("/PubDocs.json")

>

>

> then you obviously expect "/PubDocs.json" be in the request URI, but you

>

> say it starts working if we remove the above @Path. So which request URI

>

> works for you ?

>

>

> Sergey

>

>> Cheers,

>

>> Andrea

>

>>

>

>> Date: Tue, 4 Jun 2013 07:19:00 -0700

>

>> From: [hidden email]

>

>> To: [hidden email]

>

>> Subject: Re: CXF and swagger

>

>>

>

>>

>

>>

>

>>      Hi

>

>>

>

>> On 04/06/13 14:31, eanbiso wrote:

>

>>

>

>>>

>

>>

>

>>> Hi Sergey,

>

>>

>

>>> the annotation that is responsible for the failure is the

>

>>

>

>>>        @Path("/PubDocs.json")

>

>>

>

>>>

>

>>

>

>>> Removing it the endPoint works fine.

>

>>

>

>>> All the annotations used in the class are the following :

>

>>

>

>>>        @Path("/PubDocs.json")

>

>>

>

>>>

>

>>

>

>>>        @Api(value = "/PubDocs", description = "Operations about pubDocs")

>

>>

>

>>>

>

>>

>

>>>        @Produces({"application/json"})

>

>>

>

>>>

>

>>

>

>>>        public class RestPublicDocsJSON extends RestPublicDocs{}

>

>>

>

>>>

>

>> I think I know what it is. CXF supports these type extensions

>

>>

>

>> (originally from JAX-RS 0.8 I think), so you do for example,

>

>>

>

>>

>

>> "GET <a href="<a href="<a 
>> href="http://host:port/PubDocs.json";>http://host:port/PubDocs.json";><a 
>> href="http://host:port/PubDocs.json";>http://host:port/PubDocs.json";><a 
>> href="<a 
>> href="http://host:port/PubDocs.json";>http://host:port/PubDocs.json";><a 
>> href="http://host:port/PubDocs.json";>http://host:port/PubDocs.json"; and the 
>> runtime will replace it with

>

>>

>

>>

>

>> "<a href="<a href="<a 
>> href="http://host:port/PubDocs";>http://host:port/PubDocs";><a 
>> href="http://host:port/PubDocs";>http://host:port/PubDocs";><a href="<a 
>> href="http://host:port/PubDocs";>http://host:port/PubDocs";><a 
>> href="http://host:port/PubDocs";>http://host:port/PubDocs";

>

>>

>

>> and set

>

>>

>

>> "Accept: application/json"

>

>>

>

>>

>

>> I think @Path("/PubDocs")

>

>>

>

>>

>

>> will work with

>

>>

>

>>

>

>> "GET <a href="<a href="<a 
>> href="http://host:port/PubDocs.json";>http://host:port/PubDocs.json";><a 
>> href="http://host:port/PubDocs.json";>http://host:port/PubDocs.json";><a 
>> href="<a 
>> href="http://host:port/PubDocs.json";>http://host:port/PubDocs.json";><a 
>> href="http://host:port/PubDocs.json";>http://host:port/PubDocs.json";

>

>>

>

>>

>

>> Can you try it ?

>

>>

>

>>

>

>> I think we also need to get RequestPreprocessor configurable (which is

>

>>

>

>> where extensions like .json are checked), we have a JIRA for that

>

>>

>

>>

>

>> Cheers, Sergey

>

>>

>

>>

>

>>>

>

>>

>

>>> Thanks,

>

>>

>

>>>

>

>>

>

>>> Andrea

>

>>

>

>>>

>

>>

>

>>> Date: Tue, 4 Jun 2013 02:13:05 -0700

>

>>

>

>>> From: [hidden email]

>

>>

>

>>> To: [hidden email]

>

>>

>

>>> Subject: Re: CXF and swagger

>

>>

>

>>>

>

>>

>

>>>

>

>>

>

>>>

>

>>

>

>>>     Hi

>

>>

>

>>>

>

>>

>

>>> On 03/06/13 16:32, eanbiso wrote:

>

>>

>

>>>

>

>>

>

>>>> Hi all,

>

>>

>

>>>

>

>>

>

>>>> I'm trying to publish and use cxf rest endPoint adding annotations required

>

>>

>

>>>

>

>>

>

>>>> to use the framework com.wordnik.swagger

>

>>

>

>>>

>

>>

>

>>>> I tried to follow the example at

>

>>

>

>>>

>

>>

>

>>>> https://github.com/wordnik/swagger-core/tree/master/samples/java-jaxrs-cxf/src/main/java/com/wordnik/swagger/sample
>>>> with some differences: I must publish the endPoint directly from java code.

>

>>

>

>>>

>

>>

>

>>>> My situatios is the following...

>

>>

>

>>>

>

>>

>

>>>>

>

>>

>

>>>

>

>>

>

>>>> I have an endPoint with a simple interface like this:

>

>>

>

>>>

>

>>

>

>>>>

>

>>

>

>>>

>

>>

>

>>>>         @WebService(targetNamespace = http://com.prova.pubdocs/)

>

>>

>

>>>

>

>>

>

>>>>         public interface IPublic extends IPublishable{

>

>>

>

>>>

>

>>

>

>>>>            

>

>>

>

>>>

>

>>

>

>>>>             @GET

>

>>

>

>>>

>

>>

>

>>>>    @Path("/isReady")

>

>>

>

>>>

>

>>

>

>>>>    @ApiOperation(value = "Check the instance is ready or not", notes =

>

>>

>

>>>

>

>>

>

>>>> "Returns a boolean corresponding to the instance state.", responseClass =

>

>>

>

>>>

>

>>

>

>>>> "boolean")

>

>>

>

>>>

>

>>

>

>>>>    boolean isReady();

>

>>

>

>>>

>

>>

>

>>>>

>

>>

>

>>>

>

>>

>

>>>>         }

>

>>

>

>>>

>

>>

>

>>>> (the interface IPublishable specifies only the methods to publish and

>

>>

>

>>>

>

>>

>

>>>> unpublish the endPoints),  

>

>>

>

>>>

>

>>

>

>>>>

>

>>

>

>>>

>

>>

>

>>>> and an implementor like this:

>

>>

>

>>>

>

>>

>

>>>>         @WebService("RestServicePubDocs", "PubDocs")

>

>>

>

>>>

>

>>

>

>>>>         public class RestPublicDocs implements IPublic, IPlat1Service {

>

>>

>

>>>

>

>>

>

>>>>

>

>>

>

>>>

>

>>

>

>>>>            @Override

>

>>

>

>>>

>

>>

>

>>>>    public boolean isReady() {

>

>>

>

>>>

>

>>

>

>>>>            return true;

>

>>

>

>>>

>

>>

>

>>>>    }

>

>>

>

>>>

>

>>

>

>>>>         ....

>

>>

>

>>>

>

>>

>

>>>>         }

>

>>

>

>>>

>

>>

>

>>>>

>

>>

>

>>>

>

>>

>

>>>> Following the example I've also  daclared the class:

>

>>

>

>>>

>

>>

>

>>>>

>

>>

>

>>>

>

>>

>

>>>>         @Path("/PubDocs.json")

>

>>

>

>>>

>

>>

>

>>>>         @Api(value = "/PubDocs", description = "Operations about pubDocs")

>

>>

>

>>>

>

>>

>

>>>>         @Produces({"application/json"})

>

>>

>

>>>

>

>>

>

>>>>         public class RestPublicDocsJSON extends RestPublicDocs{}

>

>>

>

>>>

>

>>

>

>>>>

>

>>

>

>>>

>

>>

>

>>>> and then I've published the end point in a similar way:

>

>>

>

>>>

>

>>

>

>>>>

>

>>

>

>>>

>

>>

>

>>>>    private Server publishRestServerSwagger(String addr,

>

>>

>

>>>

>

>>

>

>>>>                    List<Interceptor&lt;? extends Message>> inInterceptors,

>

>>

>

>>>

>

>>

>

>>>>                    List<Interceptor&lt;? extends Message>> 
>>>> outInterceptors){

>

>>

>

>>>

>

>>

>

>>>>            Server simpl=null;

>

>>

>

>>>

>

>>

>

>>>>            try {   

>

>>

>

>>>

>

>>

>

>>>>                    JAXRSServerFactoryBean sf = new 
>>>> JAXRSServerFactoryBean();

>

>>

>

>>>

>

>>

>

>>>>                    sf.setServiceBean(new RestPublicDocsJSON()); //the 
>>>> implementor

>

>>

>

>>>

>

>>

>

>>>>                    sf.setServiceBean(new ApiListingResourceJSON()); 
>>>> //required from swagger

>

>>

>

>>>

>

>>

>

>>>>                    sf.setAddress(addr);

>

>>

>

>>>

>

>>

>

>>>>                    sf.setProvider(new JacksonJsonProvider()); //required 
>>>> from swagger

>

>>

>

>>>

>

>>

>

>>>>                    sf.setProvider(new RestExceptionHandler()); //my 
>>>> exception mapper

>

>>

>

>>>

>

>>

>

>>>>                    

>

>>

>

>>>

>

>>

>

>>>>                    if (inInterceptors != null) {

>

>>

>

>>>

>

>>

>

>>>>                            for (Interceptor<? extends Message> interceptor 
>>>> : inInterceptors) {

>

>>

>

>>>

>

>>

>

>>>>                                    sf.getInInterceptors().add(interceptor);

>

>>

>

>>>

>

>>

>

>>>>                            }

>

>>

>

>>>

>

>>

>

>>>>                    }

>

>>

>

>>>

>

>>

>

>>>>                    if (outInterceptors != null) {

>

>>

>

>>>

>

>>

>

>>>>                            for (Interceptor<? extends Message> interceptor 
>>>> : outInterceptors) {

>

>>

>

>>>

>

>>

>

>>>>                                    
>>>> sf.getOutInterceptors().add(interceptor);

>

>>

>

>>>

>

>>

>

>>>>                            }

>

>>

>

>>>

>

>>

>

>>>>                    }

>

>>

>

>>>

>

>>

>

>>>>                    

>

>>

>

>>>

>

>>

>

>>>>                    //add new rest fault interceptor

>

>>

>

>>>

>

>>

>

>>>>                    sf.getOutFaultInterceptors().add(new 
>>>> RestFaultInterceptor());

>

>>

>

>>>

>

>>

>

>>>>                    //new management end

>

>>

>

>>>

>

>>

>

>>>>                    simpl = sf.create();

>

>>

>

>>>

>

>>

>

>>>>                    //disable honorKeepAlive value depending on VMArg 
>>>> (honorKeepAlive default

>

>>

>

>>>

>

>>

>

>>>> value is true)

>

>>

>

>>>

>

>>

>

>>>>                    log.info("Endpoint has been published on " + addr);

>

>>

>

>>>

>

>>

>

>>>>            } catch (Exception e) {

>

>>

>

>>>

>

>>

>

>>>>                    log.warn("Error publishing endpoint: " + e.toString(), 
>>>> e);

>

>>

>

>>>

>

>>

>

>>>>            }

>

>>

>

>>>

>

>>

>

>>>>            

>

>>

>

>>>

>

>>

>

>>>>            return simpl;

>

>>

>

>>>

>

>>

>

>>>>    }

>

>>

>

>>>

>

>>

>

>>>>

>

>>

>

>>>

>

>>

>

>>>>

>

>>

>

>>>

>

>>

>

>>>> The publication seems to be successful and no exception occurs but when I

>

>>

>

>>>

>

>>

>

>>>> call the ws, a javax.ws.rs.WebApplicationException with status 404 and all

>

>>

>

>>>

>

>>

>

>>>> values null occurs.

>

>>

>

>>>

>

>>

>

>>>> If I remove the annotations from the RestPublicDocsJSON class the api works

>

>>

>

>>>

>

>>

>

>>>> properly and no exception occurs.

>

>>

>

>>>

>

>>

>

>>>> Someone can help me?

>

>>

>

>>> I can't see what may be going wrong from the code above.

>

>>

>

>>>

>

>>

>

>>> In this fragment,

>

>>

>

>>>

>

>>

>

>>>

>

>>

>

>>>     >      @Path("/PubDocs.json")

>

>>

>

>>>

>

>>

>

>>>     >      @Api(value = "/PubDocs", description = "Operations about 
>>> pubDocs")

>

>>

>

>>>

>

>>

>

>>>     >      @Produces({"application/json"})

>

>>

>

>>>

>

>>

>

>>>     >      public class RestPublicDocsJSON extends RestPublicDocs{}

>

>>

>

>>>

>

>>

>

>>>

>

>>

>

>>> which annotations affect the api working properly ? Are these

>

>>

>

>>>

>

>>

>

>>> annotations the only ones on RestPublicDocsJSON ?

>

>>

>

>>>

>

>>

>

>>>

>

>>

>

>>> Sergey

>

>>

>

>>>

>

>>

>

>>>

>

>>

>

>>>

>

>>

>

>>>> Thanks a lot,

>

>>

>

>>>

>

>>

>

>>>>

>

>>

>

>>>

>

>>

>

>>>> Andrea

>

>>

>

>>>

>

>>

>

>>>>

>

>>

>

>>>

>

>>

>

>>>>

>

>>

>

>>>

>

>>

>

>>>>

>

>>

>

>>>

>

>>

>

>>>> --

>

>>

>

>>>

>

>>

>

>>>> View this message in context: 
>>>> http://cxf.547215.n5.nabble.com/CXF-and-swagger-tp5728644.html
>>>> Sent from the cxf-user mailing list archive at Nabble.com.

>

>>

>

>>>

>

>>

>

>>>>

>

>>

>

>>>

>

>>

>

>>>

>

>>

>

>>>

>

>>

>

>>>     

>

>>

>

>>>     

>

>>

>

>>>     

>

>>

>

>>>     

>

>>

>

>>>

>

>>

>

>>>     

>

>>

>

>>>

>

>>

>

>>>     

>

>>

>

>>>     

>

>>

>

>>>             If you reply to this email, your message will be added to the 
>>> discussion below:

>

>>

>

>>>             
>>> http://cxf.547215.n5.nabble.com/CXF-and-swagger-tp5728644p5728690.html
>>>     

>

>>

>

>>>     

>

>>

>

>>>             

>

>>

>

>>>             To unsubscribe from CXF and swagger, click here.

>

>>

>

>>>

>

>>

>

>>>             NAML

>

>>

>

>>>                                             

>

>>

>

>>>

>

>>

>

>>>

>

>>

>

>>>

>

>>

>

>>> --

>

>>

>

>>> View this message in context: 
>>> http://cxf.547215.n5.nabble.com/CXF-and-swagger-tp5728644p5728720.html
>>> Sent from the cxf-user mailing list archive at Nabble.com.

>

>>

>

>>>

>

>>

>

>>

>

>>

>

>>      

>

>>      

>

>>      

>

>>      

>

>>

>

>>      

>

>>

>

>>      

>

>>      

>

>>              If you reply to this email, your message will be added to the 
>> discussion below:

>

>>              
>> http://cxf.547215.n5.nabble.com/CXF-and-swagger-tp5728644p5728727.html
>>      

>

>>      

>

>>              

>

>>              To unsubscribe from CXF and swagger, click here.

>

>>

>

>>              NAML

>

>>                                              

>

>>

>

>>

>

>>

>

>> --

>

>> View this message in context: 
>> http://cxf.547215.n5.nabble.com/CXF-and-swagger-tp5728644p5728742.html
>> Sent from the cxf-user mailing list archive at Nabble.com.

>

>>

>

>


-- 

Sergey Beryozkin


Talend Community Coders

http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com


        
        
        
        

        

        
        
                If you reply to this email, your message will be added to the 
discussion below:
                
http://cxf.547215.n5.nabble.com/CXF-and-swagger-tp5728644p5728750.html
        
        
                
                To unsubscribe from CXF and swagger, click here.

                NAML
                                                  

jarListSwaggerTEST.txt (4K) 
<http://cxf.547215.n5.nabble.com/attachment/5728845/0/jarListSwaggerTEST.txt>
SwaggerTEST.rar (56K) 
<http://cxf.547215.n5.nabble.com/attachment/5728845/1/SwaggerTEST.rar>




--
View this message in context: 
http://cxf.547215.n5.nabble.com/CXF-and-swagger-tp5728644p5728845.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to