Thank you for your response, Andriy.

This is an existing application and I am bound by certain limitations
which include not being able to upgrade to any newer version.
This is a POC that I am trying to develop on my own and not a requirement
from the higher ups. Yet, giving my best shot.

How about generating WADL? Postman tool can still import WADL files and
this solves at least half the purpose.
And there are WADL to Swagger conversion tools as well. This would be my
next step in the process provided a WADL file can be generated with Apache
CXF 2.4.6

There are @Descriptions and @Description annotations available and I have
annotated one of the existing REST classes and methods appropriately. But,
how is the WADL file generated? Do I have to follow any steps to create
one? If yes, pls mention those.

I am referring to the following links.

https://cxf.apache.org/docs/jaxrs-services-description.html#JAXRSServicesDescription-WADL

https://cxf.apache.org/docs/jaxrs-services-description.html#JAXRSServicesDescription-DocumentingresourceclassesandmethodsingeneratedWADL

On Mon, Oct 24, 2022 at 6:25 AM Andriy Redko <drr...@gmail.com> wrote:

> Hello Tanuja,
>
> The SwaggerFeature was introduced in Apache CXF 3.0 [1], but as far as I
> understand, you are trying to use Apache CXF 2.4.6 and pulling the
> cxf-rt-rs-service-description-3.0.0.jar with it. If that is the case,
> it is not going to work out. The recommendation would be to update to
> one of the supported Apache CXF releases [2].
>
> Thank you.
>
> [1] https://issues.apache.org/jira/browse/CXF-5379
> [2] https://cxf.apache.org/download.html
>
> Best Regards,
>     Andriy Redko
>
> TS> Hello everyone,
>
> TS> My project uses cxf-2.4.6 version. There is no REST API documentation
> as of
> TS> date.
> TS> I plan to create one and have been exploring various options for this
> TS> version.
>
> TS> Official documentation mentions that SwaggerFeature needs to be used
> for
> TS> this version.
> TS> https://cwiki.apache.org/confluence/display/CXF20DOC/Swagger2Feature
>
> TS> As per the above link,
>
> TS> *For generating Swagger 1.2
> TS> <
> https://github.com/swagger-api/swagger-spec/blob/master/versions/1.2.md>
> TS> documents,
> TS> you can use SwaggerFeature instead of Swagger2Feature (for CXF
> versions <=
> TS> 3.1.x).*
>
> TS> But, I am lost here.
>
> TS> Added all the needed jars. Ant is used as a build tool; hence,
> individual
> TS> jars are added manually.
>
> TS> scala-library-2.7.7.jar
> TS> swagger-jaxrs_2.10-1.3.13.jar
> TS> swagger-ui-2.1.2.jar
> TS> swagger-annotations-1.5.2.jar
> TS> swagger-jaxrs-1.5.2.jar
> TS> cxf-rt-rs-service-description-3.0.0.jar
>
> TS> I've added this bean in the cxfbeans.xml.
>
> TS>      <!-- CXF SwaggerFeature -->
> TS>     <bean id="swaggerFeature"
> TS> class="org.apache.cxf.jaxrs.swagger.SwaggerFeature">
> TS>         <!-- customize some of the properties -->
> TS>         <property name="basePath" value=""/>
> TS>     </bean>
>
> TS>  <bean class="com.test" id="testClass"/>
>
> TS> <jaxrs:server address="/testService" id="testServiceId">
> TS>       <jaxrs:serviceBeans>
> TS>             <ref bean="testClass"/>
> TS>       </jaxrs:serviceBeans>
> TS>      <jaxrs:extensionMappings>
> TS>             <entry key="xml" value="application/xml"/>
> TS>             <entry key="json" value="application/json"/>
> TS>       </jaxrs:extensionMappings>
> TS>        <jaxrs:features>
> TS>             <ref bean="swaggerFeature" />
> TS>         </jaxrs:features>
> TS> </jaxrs:server>
>
> TS> Now, server doesn't start and I get this exception.
>
> TS> org.springframework.beans.factory.BeanCreationException: Error creating
> TS> bean with name ' testServiceId': Invocation of init method failed;
> nested
> TS> exception is
> org.apache.cxf.service.factory.ServiceConstructionException
> TS>  at
> TS>
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
> TS> at
> TS>
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
> TS> at
> TS>
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
> TS> at java.security.AccessController.doPrivileged(Native Method)
> TS> at
> TS>
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
> TS> at
> TS>
> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
> TS> at
> TS>
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
> TS> at
> TS>
> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
> TS> at
> TS>
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
> TS> at
> TS>
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
> TS> at
> TS>
> org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
> TS> at
> TS>
> org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
> TS> at
> TS>
> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
> TS> at
> TS>
> org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
> TS> at
> TS>
> org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
> TS> at
> TS>
> org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
> TS> at
> TS>
> org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4727)
> TS> at
> TS>
> org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5189)
> TS> at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
> TS> at
> TS>
> org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1403)
> TS> at
> TS>
> org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393)
> TS> at java.util.concurrent.FutureTask.run(FutureTask.java:266)
> TS> at
> TS>
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
> TS> at
> TS>
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
> TS> at java.lang.Thread.run(Thread.java:745)
> TS> Caused by: org.apache.cxf.service.factory.ServiceConstructionException
> TS> at
> TS>
> org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:192)
> TS> at sun.reflect.GeneratedMethodAccessor61.invoke(Unknown Source)
> TS> at
> TS>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> TS> at java.lang.reflect.Method.invoke(Method.java:498)
> TS> at
> TS>
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1414)
> TS> at
> TS>
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1375)
> TS> at
> TS>
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
> TS> ... 24 more
> TS> Caused by: java.lang.NullPointerException
> TS> at
> TS>
> org.apache.cxf.jaxrs.swagger.SwaggerFeature.calulateDefaultResourcePackage(SwaggerFeature.java:69)
> TS> at
> TS>
> org.apache.cxf.jaxrs.swagger.SwaggerFeature.initialize(SwaggerFeature.java:46)
> TS> at
> TS>
> org.apache.cxf.jaxrs.JAXRSServerFactoryBean.applyFeatures(JAXRSServerFactoryBean.java:203)
> TS> at
> TS>
> org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:180)
> TS> ... 30 more
>
> TS> Regards,
> TS> Sandy
>
>

Reply via email to