camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Spring route config involving custom components
Date Tue, 22 Jun 2010 07:24:40 GMT
On Mon, Jun 21, 2010 at 6:08 PM, Bernd Schuller
<b.schuller@fz-juelich.de> wrote:
>
> Hi,
>
> I try to setup a Camel (version 2.3.0) route involving custom components
> using Spring. My Spring xml looks like this:
>
> <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring" >
>
>       <route>
>                <from uri="direct://x"/>
>                <to uri="foo://x"/>
>     </route>
>
> </camelContext>
>
> where "foo" is referring to a custom component which is auto-registered
> using the META-INF/services... approach. The custom component is rather
> simple and basically just extends DefaultComponent by creating the correct
> type of endpoint.
>

You custom endpoint may not return the CamelContext instance when the
getCamelContext method is invoked on it.
So check your custom endpoint code.

Usually the constructor of the endpoint invokes super with the uri and
the component

    public CustomEndpoint(final String endpointUri, final Component component) {
        super(endpointUri, component);
    }



> When starting the context I get an exception [1] saying that the
> "camelContext
> must be specified". With a default component (say, "mock") things are
> working.
>
> What could I be missing?
>
> Thanks in advance for your help, and best regards,
> Bernd.
>
>
>
> [1] stack trace:
>
> org.apache.camel.RuntimeCamelException:
> org.apache.camel.FailedToCreateRouteException: Failed to create route route1
> at: >>> To[foo://x] <<< in route: Route[[From[direct://x]] -> [To[foo://x
> because of camelContext must be specified
>        at
> org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1111)
>        at
> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:103)
>        at
> org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:665)
>        at
> org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:78)
>        at
> org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
>        at
> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:76)
>        at
> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:274)
>        at
> org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:736)
>        at
> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:383)
>        at
> org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140)
>        at
> org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:84)
>        at
> wisnetgrid.adapter.connectors.unicore.TestSpringConfig.test1(TestSpringConfig.java:28)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>        at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
>        at java.lang.reflect.Method.invoke(Method.java:599)
>        at junit.framework.TestCase.runTest(TestCase.java:154)
>        at junit.framework.TestCase.runBare(TestCase.java:127)
>        at junit.framework.TestResult$1.protect(TestResult.java:106)
>        at junit.framework.TestResult.runProtected(TestResult.java:124)
>        at junit.framework.TestResult.run(TestResult.java:109)
>        at junit.framework.TestCase.run(TestCase.java:118)
>        at junit.framework.TestSuite.runTest(TestSuite.java:208)
>        at junit.framework.TestSuite.run(TestSuite.java:203)
>        at
> org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
>        at
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>        at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
>        at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
>        at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
>        at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create
> route route1 at: >>> To[foo://x] <<< in route: Route[[From[direct://x]]
->
> [To[foo://x because of camelContext must be specified
>        at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:720)
>        at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:138)
>        at
> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:545)
>        at
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1209)
>        at
> org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1107)
>        at
> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1037)
>        at
> org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:164)
>        at
> org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:56)
>        at
> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:912)
>        at
> org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:203)
>        at
> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:101)
>        ... 28 more
> Caused by: java.lang.IllegalArgumentException: camelContext must be
> specified
>        at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:260)
>        at
> org.apache.camel.processor.SendProcessor.<init>(SendProcessor.java:51)
>        at
> org.apache.camel.processor.SendProcessor.<init>(SendProcessor.java:55)
>        at
> org.apache.camel.model.SendDefinition.createProcessor(SendDefinition.java:58)
>        at
> org.apache.camel.model.ToDefinition.createProcessor(ToDefinition.java:91)
>        at
> org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:365)
>        at
> org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:161)
>        at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:717)
>        ... 38 more
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Spring-route-config-involving-custom-components-tp510448p510448.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Mime
View raw message