2016-01-05 97 views
0

我正在嘗試將restlet與servlet引擎集成,這樣我就不會產生新的服務器進程。與servlet引擎集成時,Apache camel restlet無法正常工作

我已經在web.xml

<servlet> 
     <servlet-name>spring-rs</servlet-name> 
     <servlet-class>org.restlet.ext.spring.SpringServerServlet</servlet-class> 
     <init-param> 
      <param-name>org.restlet.Component</param-name> 
      <param-value>RestletComponent</param-value> 
     </init-param> 



     <load-on-startup>1</load-on-startup> 
    </servlet> 
    <servlet-mapping> 
     <servlet-name>spring-rs</servlet-name> 
     <url-pattern>/restful/*</url-pattern> 
    </servlet-mapping> 

下面的配置,我的春天的applicationContext.xml我有下面的條目,

<bean name = "RestletComponent" id="RestletComponent" class="org.restlet.Component" /> 
    <bean name = "RestletComponentService" id="RestletComponentService" class="org.apache.camel.component.restlet.RestletComponent"> 
     <constructor-arg index="0"> 
      <ref bean="RestletComponent" /> 
     </constructor-arg> 
    </bean> 

<camelContext xmlns="http://camel.apache.org/schema/spring"> 

<route id = "RS_getdata"> 
      <from uri="restlet:/getData?restletMethod=POST" /> 
</camelContext> 

但當我嘗試調用REST式服務,我得到下面的錯誤。

java.lang.IllegalArgumentException: 'name' must not be null 
    at org.springframework.util.Assert.notNull(Assert.java:112) 
    at org.springframework.beans.factory.BeanFactoryUtils.transformedBeanName(BeanFactoryUtils.java:72) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.transformedBeanName(AbstractBeanFactory.java:1067) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:235) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) 
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:956) 
    at org.restlet.ext.spring.SpringServerServlet.createApplication(SpringServerServlet.java:77) 
    at org.restlet.ext.servlet.ServerServlet.getApplication(ServerServlet.java:802) 
    at org.restlet.ext.servlet.ServerServlet.createServer(ServerServlet.java:538) 
    at org.restlet.ext.servlet.ServerServlet.getServer(ServerServlet.java:945) 
    at org.restlet.ext.servlet.ServerServlet.service(ServerServlet.java:1114) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) 
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) 
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) 
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142) 
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) 
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617) 
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) 
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518) 
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091) 
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668) 
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1521) 
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1478) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 
    at java.lang.Thread.run(Thread.java:745) 

任何幫助,高度讚賞。

回答

0

您應該爲你的bean相同的名稱作爲組件名稱,駱駝使用它,例如:

<bean name = "RestletComponent" id="RestletComponent" 

應該

<bean name = "restlet" id="restlet"