web services - CXFRS webservice don't work -


fuse esb. component: cxfrs webservice

i have problem webservice.

this pom.xml:

    <dependencies>              <dependency>                 <groupid>org.apache.camel</groupid>                 <artifactid>camel-core</artifactid>                 <version>2.15.1.redhat-620133</version>              </dependency>                 <dependency>            <groupid>org.apache.camel</groupid>             <artifactid>camel-blueprint</artifactid>           <version>2.15.1.redhat-620133</version>           </dependency>            <!-- logging -->           <dependency>       <groupid>org.slf4j</groupid>       <artifactid>slf4j-api</artifactid>       <version>1.7.10</version>     </dependency>            <dependency>              <groupid>org.slf4j</groupid>            <artifactid>slf4j-log4j12</artifactid>       <version>1.7.10</version>     </dependency>     <dependency>       <groupid>log4j</groupid>       <artifactid>log4j</artifactid>       <version>1.2.17</version>     </dependency>      <!-- testing & camel plugin -->     <dependency>       <groupid>org.apache.camel</groupid>       <artifactid>camel-test-blueprint</artifactid>       <version>2.15.1.redhat-620133</version>     </dependency>      <!-- cxf -->      <dependency>       <groupid>org.ow2.asm</groupid>       <artifactid>asm-all</artifactid>       <version>4.1</version>     </dependency>     <dependency>       <groupid>org.apache.camel</groupid>       <artifactid>camel-cxf</artifactid>       <version>2.15.1.redhat-620133</version>     </dependency>     <dependency>       <groupid>javax.servlet</groupid>       <artifactid>javax.servlet-api</artifactid>       <version>3.0.1</version>       <scope>provided</scope>     </dependency>     <dependency>         <groupid>org.apache.cxf</groupid>         <artifactid>cxf-rt-transports-http-jetty</artifactid>         <version>2.7.0.redhat-610379</version>     </dependency>      <dependency>         <groupid>org.apache.camel</groupid>         <artifactid>camel-jackson</artifactid>         <version>2.12.0.redhat-610379</version>     </dependency>     <dependency>       <groupid>org.apache.camel</groupid>       <artifactid>camel-jaxb</artifactid>       <version>2.12.0.redhat-610379</version>     </dependency>     <dependency>         <groupid>org.apache.cxf</groupid>         <artifactid>cxf-rt-frontend-jaxrs</artifactid>         <version>2.7.0.redhat-610379</version>     </dependency>      <dependency>       <groupid>org.apache.camel</groupid>       <artifactid>camel-http4</artifactid>       <version>2.12.0.redhat-610379</version>       </dependency>     <dependency>     <groupid>javax.ws.rs</groupid>     <artifactid>javax.ws.rs-api</artifactid>     <version>2.0-m10</version> </dependency>      </dependencies> 

this route:

   <?xml version="1.0" encoding="utf-8"?>     <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"        xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"        xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf"        xsi:schemalocation="        http://www.osgi.org/xmlns/blueprint/v1.0.0                  http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd        http://camel.apache.org/schema/blueprint                   http://camel.apache.org/schema/           blueprint/camel-blueprint.xsd">    <bean id="hellobean" class="com.mycompany.camel.blueprint.hellobean">       <property name="say" value="hi camel"/>   </bean> <cxf:rsserver id="rsserver" address="http://localhost:9090/route"               serviceclass="com.mycompany.camel.blueprint.testws"/>   <camelcontext xmlns="http://camel.apache.org/schema/blueprint">   <route>     <from uri="cxfrs:beanid:rsserver"/>     <log message="test"/>     <marshal>       <json library="jackson"/>     </marshal>   </route> </camelcontext>  </blueprint> 

this function:

     package com.mycompany.camel.blueprint;       import javax.ws.rs.get;      import javax.ws.rs.path;       import javax.ws.rs.pathparam;      import javax.ws.rs.produces;      import javax.ws.rs.core.mediatype;      @path("/")     public class testws {      @get     @path("/test/{id}/{id2}")     @produces(mediatype.application_json)     public string getassets(@pathparam("id") string id,          @pathparam("id2")        string id2){         return null;     }      } 

and error message:

 caused by: javax.ws.rs.notfoundexception @                         org.apache.cxf.jaxrs.*  abstractjaxrsfactorybean.checkresources (abstractjaxrsfactor     ybean.java:322) @  2) ... 55 more 

how can fix problem?

javax.ws.rs.notfoundexception - reason error is, cxf cannot find matching resource given request.

to comply best practice, donot use qualified url in "address attribute". below working sample, please try same in code. work

camel dsl:

<cxf:rsserver id="rsserver" address="/"                       serviceclass="com.guru.service.controlservice"                       loggingfeatureenabled="true" loggingsizelimit="20">                       <cxf:providers>                 <bean id="jsonprovider" class="org.apache.cxf.jaxrs.provider.json.jsonprovider"/>                               </cxf:providers>    </cxf:rsserver>  <route id="esbroute">     <from uri="cxfrs:bean:rsserverr"/>     <to uri="mock:test" /> </route> 

java code

@path("/controlcservice") public class controlservice {      @post     @path("/save")     @consumes(mediatype.application_json)     @produces(mediatype.application_json)        public responsedetail save(controlentity entity) {                 system.out.println("hi im inside rest api");         return null ;      }   } 

and path access rest resource "http://localhost:xxxx/controlcservice/save"


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -