The problem is that there are two instances of com.person.rest.RestServiceImpl. One is creatd by blueprint and correctly injected. The other is created by camel-cxf and is not injected with the jsonResponseService.

The problem is this:
<cxf:rsServer id="rsServer" address="/person" serviceClass="com.person.rest.RestServiceImpl" loggingFeatureEnabled="true" />

The property serviceClass means that camel-cxf should create the instance of the class. Honestly I have no idea why camel-cxf has this option as it is rarely useful. In general I am not a fan of camel-cxf. It is often highly confusing and I had lots of problems with it.

Instead I would use a plain cxf service like described here http://cxf.apache.org/docs/jaxrs-services-configuration.html. You refer to the impl as a blueprint bean id that can be injected nicely.

If you need camel then I would rather call into the camel route from the cxf service impl for example by injecting a camel ProducerTemplate.

Christian

Am 19.08.2015 um 19:16 schrieb slim:
Hi Christian,
Many thanks for your answer and your blog. here is a sample for what I'm
trying to do:

https://github.com/leadertun/karaf-cxf-postgresql-example

yes, I'm using blueprint. the problem is visible when executing the Rest web
service.  null pointer exception is fired due to a null reference

Error 500 Server Error. Problem accessing /cxf/person/rest/message. Reason:
Server Error Caused by:
Caused by: java.lang.NullPointerException
        at
com.person.service.impl.JsonResponseServiceImpl.getJsonResponse(JsonResponseServiceImpl.java:31)
at
com.person.rest.RestServiceImpl.getJsonResponseResult(RestServiceImpl.java:27)

Do I miss something?

Many thanks for your help
Reagrds,
Slim



--
View this message in context: 
http://karaf.922171.n3.nabble.com/inject-service-using-cxf-tp4041915p4041946.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Reply via email to