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: why camel-context.xml can't find in my j2ee project?
Date Thu, 14 Jul 2011 00:49:51 GMT
You may need to use spring context listener to load the camel-context.xml.

On 7/13/11 11:24 PM, xiangqiuzhao wrote:
> i import camel-mina components into myeclipse as a maven project. and write a
> test Class like this:
>
> public class SocketTest {
>      public static void main(String args[]) throws Exception {
>          CamelContext context = new DefaultCamelContext();
>          context.addRoutes(new RouteBuilder() {
>              public void configure() throws Exception {
>                  from("mina:tcp://localhost:9999?textline=true&sync=true")
>                  .choice()
>                  .when(body().isNotNull())
>                  .convertBodyTo(String.class)
>                  .process(new SampleTextProcessor());
>              }
>          });
>          context.start();
>          Thread.sleep(1000000);
>          context.stop();
>      }
> }
>
>
> the project directory tree like this:
>
> http://camel.465427.n5.nabble.com/file/n4583039/2011-07-13_231800.jpg
>
> the camel-context.xml:
> <bean id="sampleTextProcessor"
> class="com.sunyard.bpsp.channel.test.SampleTextProcessor">
> </bean>
>
>
> it's running very fine,but when i create new j2ee project in myeclipse, and
> copy some dependencies jars into project, and create the same test class and
> camel-context.xml in the similar place. but exception like this:
>
> Exception in thread "main" org.apache.camel.FailedToCreateRouteException:
> Failed to create route route1 at:>>>  Choice[[When[{body is not null} ->
> [convertBodyTo[java.lang.String], process[ref:sampleTextProcessor]]]]]<<<
> in route: Route[[From[mina:tcp://localhost:9999?textline=true&sync=tru...
> because of registry entry called sampleTextProcessor must be specified on:
> process[ref:sampleTextProcessor]
> 	at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:815)
> 	at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:165)
> 	at
> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:706)
> 	at
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1643)
> 	at
> org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1432)
> 	at
> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1336)
> 	at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:67)
> 	at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:54)
> 	at
> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1314)
> 	at
> com.sunyard.bpsp.channel.test.FileCopierWithCamel.main(FileCopierWithCamel.java:25)
> Caused by: java.lang.IllegalArgumentException: registry entry called
> sampleTextProcessor must be specified on: process[ref:sampleTextProcessor]
> 	at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:293)
> 	at
> org.apache.camel.model.ProcessDefinition.createProcessor(ProcessDefinition.java:89)
> 	at
> org.apache.camel.model.ProcessorDefinition.createOutputsProcessor(ProcessorDefinition.java:368)
> 	at
> org.apache.camel.model.ProcessorDefinition.createOutputsProcessor(ProcessorDefinition.java:136)
> 	at
> org.apache.camel.impl.DefaultRouteContext.createProcessor(DefaultRouteContext.java:106)
> 	at
> org.apache.camel.model.ProcessorDefinition.createChildProcessor(ProcessorDefinition.java:155)
> 	at
> org.apache.camel.model.ExpressionNode.createFilterProcessor(ExpressionNode.java:100)
> 	at
> org.apache.camel.model.WhenDefinition.createProcessor(WhenDefinition.java:69)
> 	at
> org.apache.camel.model.ChoiceDefinition.createProcessor(ChoiceDefinition.java:71)
> 	at
> org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:410)
> 	at
> org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:181)
> 	at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:812)
>
> how the camel-context.xml be found?
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/why-camel-context-xml-can-t-find-in-my-j2ee-project-tp4583039p4583039.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>


-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang

Mime
View raw message