今天用Camel做了个Servlet接收数据转发的功能,原本感受挺简单的.可是在作的过程当中仍是遇到了很多问题. java
1.Camel用的版本是2.6,如今看起来是比较老了,but这个是jdk1.5能支持的最后一个版本了.又不想本身编译. web
2.路由定义用的springDSL. spring
开始启动 apache
第一个错,XML解析失败.没有jaxb对应的包................................. api
第二个错,缺乏activation包.......................... app
总算很多了, svn
第三个错找不到对应的servlet.明明配的有嘛,猜想是Spring容器启动的顺序比Servlet建立先. ui
还好在官网找到如下内容 this
Sample when using Spring 2.xWhen using the Servlet component in a Camel/Spring application it's often required to load the Spring ApplicationContext after the Servlet component has started. This can be accomplished by using Spring'sContextLoaderServletinstead ofContextLoaderListener. In that case you'll need to startContextLoaderServletafter CamelHttpTransportServlet like this: spa
<web-app> <servlet> <servlet-name>CamelServlet</servlet-name> <servlet-class> org.apache.camel.component.servlet.CamelHttpTransportServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet> <servlet-name>SpringApplicationContext</servlet-name> <servlet-class> org.springframework.web.context.ContextLoaderServlet </servlet-class> <load-on-startup>2</load-on-startup> </servlet> <web-app>
总算搞定.
启动正常了.
再发数据,
第四个错,没有xstream,娘的就转发下数据要这么多包不.
就一个from(“servlet://xml”).to(“http://xxxx.xxxx/ssss”)的路由恁是搞了一下午.
activation-2.2.1.jar camel-core-2.6.0.jar camel-http-2.6.0.jar camel-servlet-2.6.0.jar camel-spring-2.6.0.jar commons-codec-1.6.jar commons-httpclient-3.0.jar commons-logging.jar commons-management-1.0.jar javax.xml.bind.jar jaxb-impl-2.1-EA1.jar log4j-1.2.15.jar spring.jar src stax-api-1.0-2.jar