title: Getting error while creating rest service using apache camel
body: <p>Since i am prety much new to Apache camel and especially Rest DSL, I thought of trying a sample of Rest DSL.</p>
  
  <p>So i created a camel-config.xml  as:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:camel="http://camel.apache.org/schema/spring"
         xsi:schemaLocation="
           http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
           http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"&gt;
  
    &lt;!-- use camel-metrics route policy to gather metrics for all routes --&gt;
    &lt;!-- bean id="metricsRoutePolicyFactory" class="org.apache.camel.component.metrics.routepolicy.MetricsRoutePolicyFactory"/--&gt;
  
    &lt;!-- a rest service which uses binding to/from pojos --&gt;
    &lt;bean id="userRoutes" class="org.apache.camel.example.rest.UserRouteBuilder"/&gt;
  
    &lt;!-- a bean for user services --&gt;
    &lt;bean id="userService" class="org.apache.camel.example.rest.UserService"/&gt;
  
    &lt;camelContext id="myCamel" xmlns="http://camel.apache.org/schema/spring"&gt;
      &lt;routeBuilder ref="userRoutes"/&gt;
    &lt;/camelContext&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>and my route class is :</p>
  
  <pre><code>package org.apache.camel.example.rest;
  
  import org.apache.camel.builder.RouteBuilder;
  
  /**
   * Define REST services using the Camel REST DSL
   */
  public class UserRouteBuilder extends RouteBuilder {
  
      public void configure() throws Exception {
          rest("/say").get("/hello").to("direct:hello").get("/bye")
                  .consumes("application/json").to("direct:bye").post("/bye")
                  .to("mock:update");
          from("direct:hello").transform().constant("Hello World");
          from("direct:bye").transform().constant("Bye World");
      }
  
  }
  </code></pre>
  
  <p>and my web.xml is :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"&gt;
    &lt;display-name&gt;My Camel Rest Application&lt;/display-name&gt;
  
    &lt;!-- location of Camel Spring xml files --&gt;
    &lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
  
      &lt;!-- to use Java DSL --&gt;
      &lt;param-value&gt;classpath:camel-config.xml&lt;/param-value&gt;
  
      &lt;!-- to use XML DSL, then enable me, and disable Java DSL above
      &lt;param-value&gt;classpath:camel-config-xml.xml&lt;/param-value&gt;
      --&gt;
    &lt;/context-param&gt;
  
    &lt;!-- the listener that kick-starts Spring --&gt;
    &lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
    &lt;/listener&gt;
  
    &lt;!-- to setup Camel Servlet --&gt;
    &lt;servlet&gt;
      &lt;display-name&gt;Camel Http Transport Servlet&lt;/display-name&gt;
      &lt;servlet-name&gt;CamelServlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.apache.camel.component.servlet.CamelHttpTransportServlet&lt;/servlet-class&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
    &lt;/servlet&gt;
  
    &lt;!-- START SNIPPET: e1 --&gt;
    &lt;!-- to setup Camel Swagger api servlet --&gt;
    &lt;servlet&gt;
      &lt;servlet-name&gt;ApiDeclarationServlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.apache.camel.component.swagger.DefaultCamelSwaggerServlet&lt;/servlet-class&gt;
      &lt;init-param&gt;
        &lt;!-- we specify the base.path using relative notation, that means the actual path will be calculated at runtime as
             http://server:port/contextpath/rest --&gt;
        &lt;param-name&gt;base.path&lt;/param-name&gt;
        &lt;param-value&gt;rest&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
        &lt;!-- we specify the api.path using relative notation, that means the actual path will be calculated at runtime as
             http://server:port/contextpath/api-docs --&gt;
        &lt;param-name&gt;api.path&lt;/param-name&gt;
        &lt;param-value&gt;api-docs&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
        &lt;param-name&gt;api.version&lt;/param-name&gt;
        &lt;param-value&gt;1.2.3&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
        &lt;param-name&gt;api.title&lt;/param-name&gt;
        &lt;param-value&gt;User Services&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
        &lt;param-name&gt;api.description&lt;/param-name&gt;
        &lt;param-value&gt;Camel Rest Example with Swagger that provides an User REST service&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;load-on-startup&gt;2&lt;/load-on-startup&gt;
    &lt;/servlet&gt;
  
    &lt;!-- swagger api declaration --&gt;
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;ApiDeclarationServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/api-docs/*&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
    &lt;!-- END SNIPPET: e1 --&gt;
  
    &lt;!-- define that url path for the Camel Servlet to use --&gt;
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;CamelServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  
    &lt;!-- START SNIPPET: e2 --&gt;
    &lt;!-- enable CORS filter so people can use swagger ui to browse and test the apis --&gt;
    &lt;filter&gt;
      &lt;filter-name&gt;RestSwaggerCorsFilter&lt;/filter-name&gt;
      &lt;filter-class&gt;org.apache.camel.component.swagger.RestSwaggerCorsFilter&lt;/filter-class&gt;
    &lt;/filter&gt;
  
    &lt;filter-mapping&gt;
      &lt;filter-name&gt;RestSwaggerCorsFilter&lt;/filter-name&gt;
      &lt;url-pattern&gt;/api-docs/*&lt;/url-pattern&gt;
      &lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt;
    &lt;/filter-mapping&gt;
    &lt;!-- END SNIPPET: e2 --&gt;
  
    &lt;welcome-file-list&gt;
        &lt;welcome-file&gt;home.html&lt;/welcome-file&gt;
    &lt;/welcome-file-list&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>Now i have created a war file of my restProject and i deployed it on tomcat. Provided all the neccessary jars in the lib folder of tomcat. I am using camel 2.14.</p>
  
  <p>Now when i start my tomcat, During startup i get error as :</p>
  
  <pre><code>SEVERE: Context initialization failed
  org.apache.camel.RuntimeCamelException: java.lang.IllegalStateException: Cannot find RestConsumerFactory in Registry or
  as a Component to use
          at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1364)
          at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:122)
          at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:327)
          at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMult
  icaster.java:96)
          at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:3
  34)
          at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:
  948)
          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
          at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389
  )
          at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
          at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
          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)
  Caused by: java.lang.IllegalStateException: Cannot find RestConsumerFactory in Registry or as a Component to use
          at org.apache.camel.component.rest.RestEndpoint.createConsumer(RestEndpoint.java:238)
          at org.apache.camel.impl.EventDrivenConsumerRoute.addServices(EventDrivenConsumerRoute.java:65)
          at org.apache.camel.impl.DefaultRoute.onStartingServices(DefaultRoute.java:80)
          at org.apache.camel.impl.RouteService.warmUp(RouteService.java:134)
          at org.apache.camel.impl.DefaultCamelContext.doWarmUpRoutes(DefaultCamelContext.java:2379)
          at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:2309)
          at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:2091)
          at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1951)
          at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1777)
          at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
          at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1745)
          at org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:254)
          at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:120)
          ... 22 more
  </code></pre>
  
  <p>I am trying to figure out for the past two days, Why i am getting this error. 
  Really looking forward to your solutions. Thanks in advance..</p>