Very often the component creates the endpoint using an uri, and therefore you have the uri already.
But if you create the endpoint manually without a component, and just configure the endpoint using getter/setter, then there is no uri per see. And then you can implement that method to construct the uri to use. On Thu, Nov 21, 2013 at 6:48 AM, P Manchanda <manchan...@yahoo.com> wrote: > Hi Camel Experts, > > I am newbie to Apache Camel and was doing a hands-on tutorial to create a > custom component. That's when I stumbled on this as to why > DefaultEndpoint.createEndpointUri() is not an abstract method, even when it > has to be overwritten. > > The implementation of this method in the parent class - DefaultEndpoint- > returns null: > > /** > * A factory method to lazily create the endpointUri if none is specified > */ > protected String createEndpointUri() { > return null; > } > > > My custom endpoint was extending the DefaultEndpoint and as a first step I > only over-rode the abstract method. This led me to the following exception on > context start up. My camel context is embedded in tomcat: > > java.lang.IllegalArgumentException: endpointUri is not specified and > com.kronos.prince.camel.endpoint.MyJDBCEndpoint does not implement > createEndpointUri() to create a default value > at > org.apache.camel.impl.DefaultEndpoint.getEndpointUri(DefaultEndpoint.java:154) > at > org.apache.camel.impl.DefaultEndpoint.toString(DefaultEndpoint.java:139) > at java.lang.String.valueOf(String.java:2854) > at java.lang.StringBuilder.append(StringBuilder.java:128) > at > org.apache.camel.impl.EventDrivenConsumerRoute.toString(EventDrivenConsumerRoute.java:50) > at > org.apache.camel.management.mbean.ManagedRoute.<init>(ManagedRoute.java:62) > at > org.apache.camel.management.mbean.ManagedSuspendableRoute.<init>(ManagedSuspendableRoute.java:30) > at > org.apache.camel.management.DefaultManagementObjectStrategy.getManagedObjectForRoute(DefaultManagementObjectStrategy.java:119) > at > org.apache.camel.management.DefaultManagementLifecycleStrategy.onRoutesAdd(DefaultManagementLifecycleStrategy.java:523) > at org.apache.camel.impl.RouteService.warmUp(RouteService.java:156) > at > org.apache.camel.impl.DefaultCamelContext.doWarmUpRoutes(DefaultCamelContext.java:2109) > at > org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:2039) > at > org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:1827) > at > org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1699) > at > org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1544) > at > org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) > > at > org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1512) > at > org.apache.camel.component.servletlistener.CamelServletContextListener.contextInitialized(CamelServletContextListener.java:162) > at > org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791) > at > org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285) > at > org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) > at > org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) > at > org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) > at > org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618) > > at > org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1100) > at > org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1618) > at > java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) > at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) > at java.util.concurrent.FutureTask.run(FutureTask.java:166) > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) > at java.lang.Thread.run(Thread.java:722) > > A search on the net didn't help much to resolve this problem. So, i dived int > the camel's source code and found out that most of the endpoints like > JDBCEndpoint, JMSEndpoint override this method. > > Doing the same in my custom endpoint fixed the problem. Am I missing > something here and there is some other way to over come the above mentioned > exception. > > ___________________ > Thks & brgds > P Manchanda > Mobile: +91-9811210374 -- Claus Ibsen ----------------- Red Hat, Inc. Email: cib...@redhat.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen