camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem Jiang <willem.ji...@gmail.com>
Subject Re: Camel CXF-JAXRS error !!
Date Tue, 24 Nov 2009 07:07:00 GMT
Hi Charles,

You need to include the cxf-rs extendsion in your spring configuration
file like this
<import
resource="classpath:META-INF/cxf/osgi/cxf-extension-jaxrs-binding.xml" />
Or you will not get the cxf rs binding factory loaded.

Willem

Charles Moulliard wrote:
> I try to create a small tutorial on camel cxf-jaxrs. Here is my camel
> route config :
> 
> <beans xmlns="http://www.springframework.org/schema/beans"
> 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> 	xmlns:context="http://www.springframework.org/schema/context"
> 	xmlns:camel="http://camel.apache.org/schema/spring"
> 	xmlns:osgi="http://www.springframework.org/schema/osgi"
> 	xmlns:jaxrs="http://cxf.apache.org/jaxrs"
> 	xmlns:cxf="http://camel.apache.org/schema/cxf"
> 	xsi:schemaLocation="
> 	    http://www.springframework.org/schema/beans
> 		http://www.springframework.org/schema/beans/spring-beans.xsd
> 		http://www.springframework.org/schema/context
>         http://www.springframework.org/schema/context/spring-context.xsd
> 		http://www.springframework.org/schema/osgi
> 		http://www.springframework.org/schema/osgi/spring-osgi.xsd
> 		http://camel.apache.org/schema/osgi
> 		http://camel.apache.org/schema/osgi/camel-osgi.xsd
> 		http://camel.apache.org/schema/spring
> 		http://camel.apache.org/schema/spring/camel-spring.xsd
> 		http://cxf.apache.org/jaxrs
> 		http://cxf.apache.org/schemas/jaxrs.xsd
> 		http://camel.apache.org/schema/cxf
> 		http://camel.apache.org/schema/cxf/camel-cxf.xsd">
> 
> 	<import resource="classpath:META-INF/cxf/cxf.xml" />
> 	<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
> 	<import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
> 	<import resource="classpath:META-INF/cxf/osgi/cxf-extension-osgi.xml" />
> 	
> 	<jaxrs:server id="restService"
> 		        address="/report"
> 		        staticSubresourceResolution="true">
>     	<jaxrs:serviceBeans>
>       		<ref bean="reportIncidentService"/>
>     	</jaxrs:serviceBeans>
>   	</jaxrs:server>
>   	
>   	<bean id="reportIncidentService"
> class="org.apache.camel.example.reportincident.restful.ReportIncidentService"
> />
> 
> 	<cxf:rsClient id="rsClient" address="http://localhost:8080"
> 		serviceClass="org.apache.camel.example.reportincident.restful.ReportIncidentService"
> />
> 
> 	<camel:camelContext trace="true"
> 		xmlns="http://camel.apache.org/schema/osgi">
> 
> 		<camel:route>
> 			<camel:from uri="cxfrs://bean://rsClient" />
> 			<camel:setHeader headerName="CamelCxfRsUsingHttpAPI">
> 				<camel:constant>True</camel:constant>
> 			</camel:setHeader>
> 			<camel:to uri="log:org.apache.camel.example.reportIncident?level=INFO" />
> 		</camel:route>
> 	</camel:camelContext>
> 
> </beans>
> 
> and the error returned :
> 
> 17:17:14,838 | ERROR | xtenderThread-31 | ContextLoaderListener
>     | BundleApplicationContextListener   50 | Application context
> refresh failed (OsgiBundleXmlApplicationContext(bundle=org.apache.camel.example.reportincident.restful.routing,
> config=osgibundle:/META-INF/spring/*.xml))
> org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'restService': Invocation of init method
> failed; nested exception is
> org.apache.cxf.service.factory.ServiceConstructionException
> 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
> 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
> 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
> 	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
> 	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
> 	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
> 	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
> 	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
> 	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
> 	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
> 	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)
> 	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)
> 	at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
> 	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
> 	at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:136)
> 	at java.lang.Thread.run(Thread.java:619)
> Caused by: org.apache.cxf.service.factory.ServiceConstructionException
> 	at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:122)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:597)
> 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1414)
> 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1375)
> 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
> 	... 17 more
> Caused by: java.lang.NullPointerException
> 	at org.apache.cxf.endpoint.ServerImpl.start(ServerImpl.java:122)
> 	at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:113)
> 	... 24 more
> 
> 
> NPE is raised here in the code
> 
>     public void start() {
>         if (messageObserver != null) {
>             destination.setMessageObserver(messageObserver);
>         } else {
>             bindingFactory.addListener(destination, endpoint); ///// NPE HERE
>         }
> 
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
> 
> *****************************
> blog : http://cmoulliard.blogspot.com
> twitter : http://twitter.com/cmoulliard
> Linkedlin : http://www.linkedin.com/in/charlesmoulliard
> 
> Apache Camel Group :
> http://www.linkedin.com/groups?home=&gid=2447439&trk=anet_ug_hm
> 



Mime
View raw message