rest - Apache CXF JAX-RS service not exposed with Spring Java config -


for reason cannot java config counterpart work apache cxf.

in xml works fine following configuration:

<?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans"     xmlns:util="http://www.springframework.org/schema/util" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"     xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:aop="http://www.springframework.org/schema/aop"     xmlns:p="http://www.springframework.org/schema/p"     xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">      <import resource="classpath:meta-inf/cxf/cxf.xml" />     <import resource="classpath:meta-inf/cxf/cxf-servlet.xml" />      <bean id="jsonmapper"         class="org.springframework.http.converter.json.jackson2objectmapperfactorybean">         <property name="featurestoenable">             <array>                 <util:constant                     static-field="com.fasterxml.jackson.databind.serializationfeature.indent_output" />             </array>         </property>         <property name="featurestodisable">             <array>             </array>         </property>     </bean>      <bean id="jsonprovider" class="com.fasterxml.jackson.jaxrs.json.jacksonjsonprovider">         <constructor-arg ref="jsonmapper" />         <constructor-arg>             <value></value>         </constructor-arg>     </bean>      <!-- configuration expose web service beans. -->     <jaxrs:server id="apiserver" address="/">         <jaxrs:servicebeans>             <ref bean="someresource" />         </jaxrs:servicebeans>         <jaxrs:providers>             <ref bean="throwablemapper" />             <ref bean="jsonprovider" />         </jaxrs:providers>     </jaxrs:server>  </beans> 

with java config counter part application starts doesn't expose rest services:

@configuration @importresource({ "classpath:meta-inf/cxf/cxf.xml", "classpath:meta-inf/cxf/cxf-servlet.xml" }) @componentscan(basepackages = { "some.package.api.provider", "some.package.api.resource" }) public class apiresourceconfiguration {      @bean     public objectmapper jsonmapper() {          final jackson2objectmapperfactorybean factorybean = new jackson2objectmapperfactorybean();         factorybean.setfeaturestoenable(serializationfeature.indent_output);         factorybean.afterpropertiesset();         return factorybean.getobject();     }      @bean     public providerbase<jacksonjsonprovider, objectmapper, jsonendpointconfig, jsonmapperconfigurator> jsonprovider() {         return new jacksonjsonprovider();     }      @bean     public server apiserver(final someresource someresource,             final throwablemapper throwablemapper,             final providerbase<jacksonjsonprovider, objectmapper, jsonendpointconfig, jsonmapperconfigurator> jsonprovider) {         final springjaxrsserverfactorybean factorybean = new springjaxrsserverfactorybean();  factorybean.setservicebeans(arrays.aslist(someresource));                 factorybean.setproviders(arrays.aslist(throwablemapper, jsonprovider));         factorybean.setaddress("/");         return factorybean.create();         }  } 

i tried several combinations:

  • instead of serservicebeans() used setresourceclasses() , setresourceprovider() didn't make difference
  • added setresourceclasses() , setresourceprovider() configuration. same result.
  • used setserviceclass still not working
  • tried use jaxrsserverfactorybean instead of springjaxrsserverfactorybean didn't help

the apache cxf servlet running says "no services have been found." when go http://localhost:someport/some/context/services. works fine xml configuration , displays exposed services.

i have no clue doing wrong. found several examples on stackoverflow didn't work me. can me out please?


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -