2 Replies Latest reply on Nov 23, 2011 2:09 AM by Jochen Lauer

    Java DSL and CXF REST

    Jochen Lauer Apprentice

      Hello,

       

      I want to write a simple Route using Java DSL and I want to deploy the route

      as war file in a jetty/tomcat container.

       

      I defined the following in my applicationContext.xml

       

      <import resource="classpath:META-INF/cxf/cxf.xml" />
      
        <cxf:rsServer address="http://localhost:8888/rest" id="rsServer" serviceClass="test.camel.CrudConfigService"></cxf:rsServer>
      
        <camelContext trace="false" xmlns="http://camel.apache.org/schema/spring">
               <package>test.camel</package>
        </camelContext>
      

       

      and my route looks like

       

           public class TestRoute extends RouteBuilder {
           
          public static void main(String[] args) throws Exception{
              new Main().run(args);
          }
      
          public void configure() {
              from("cxfrs://bean://rsServer")
              .to("log:REST###############REST");
          }
      

       

       

      When I try to start the route using mvn jetty:run

      I got an exception

       

      el 2.8.2 (CamelContext: camel-1) is shutdown in 0.007 seconds
      [                          main] ContextLoader                  ERROR Context in
      itialization failed
      org.apache.camel.RuntimeCamelException: org.apache.cxf.service.factory.ServiceCo
      nstructionException
              at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHe
      lper.java:1164)[camel-core-2.8.2.jar:2.8.2]
              at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringC
      amelContext.java:117)[camel-spring-2.8.2.jar:2.8.2]
              at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(Ca
      melContextFactoryBean.java:240)[camel-spring-2.8.2.jar:2.8.2]
              at org.springframework.context.event.SimpleApplicationEventMulticaster.m
      ulticastEvent(SimpleApplicationEventMulticaster.java:97)[spring-context-3.0.6.RE
      LEASE.jar:3.0.6.RELEASE]
              at org.springframework.context.support.AbstractApplicationContext.publis
      hEvent(AbstractApplicationContext.java:303)[spring-context-3.0.6.RELEASE.jar:3.0
      .6.RELEASE]
              at org.springframework.context.support.AbstractApplicationContext.finish
      Refresh(AbstractApplicationContext.java:911)[spring-context-3.0.6.RELEASE.jar:3.
      0.6.RELEASE]
              at org.springframework.context.support.AbstractApplicationContext.refres
      h(AbstractApplicationContext.java:428)[spring-context-3.0.6.RELEASE.jar:3.0.6.RE
      LEASE]
              at org.springframework.web.context.ContextLoader.createWebApplicationCon
      text(ContextLoader.java:282)[spring-web-3.0.6.RELEASE.jar:3.0.6.RELEASE]
              at org.springframework.web.context.ContextLoader.initWebApplicationConte
      xt(ContextLoader.java:204)[spring-web-3.0.6.RELEASE.jar:3.0.6.RELEASE]
              at org.springframework.web.context.ContextLoaderListener.contextInitiali
      zed(ContextLoaderListener.java:47)[spring-web-3.0.6.RELEASE.jar:3.0.6.RELEASE]
              at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextH
      andler.java:640)
              at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletC
      ontextHandler.java:229)
              at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.jav
      a:1208)
              at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandle
      r.java:586)
              at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:449
      )
              at org.mortbay.jetty.plugin.JettyWebAppContext.doStart(JettyWebAppContex
      t.java:179)[jetty-maven-plugin-7.4.5.v20110725.jar:7.4.5.v20110725]
              at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLife
      Cycle.java:58)
              at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCol
      

       

      What's wrong with my code ?

       

      A route with an osgi package using spring DSL deployed in servicemix works fine

      but I want to deploy in to a servlet engine like jetty or tomcat.....

       

      Thanks

      labo