This sounds like a new angle. Do you have any pointers as to how I do this?
Does it limit what I can do with CXF or is it "fully featured"?

/Bengt

2011/5/26 Christian Schneider <[email protected]>

> You might want to try the camel transport for cxf instead.
> I think in this case you do not need spring.
>
> Christian
>
>
> -----Ursprüngliche Nachricht-----
> Von: [email protected] [mailto:[email protected]] Im Auftrag
> von Bengt Rodehav
> Gesendet: Donnerstag, 26. Mai 2011 12:17
> An: [email protected]
> Betreff: camel-cxf in OSGi, java DSL and iPOJO (no Spring)
>
> I have great problems getting camel-cxf to work. I use Camel 2.7.1 running
> in Karaf 2.2.0.
>
> First, lets see what I can get to work...
>
> If I create my camel context and my cxf endpoint from within Spring I do
> get things to work, like this:
>
> *META-INF/spring/beans.xml*
> ...
>
> *    <cxf:cxfEndpoint id="trsWsEndpoint"
> **                     address="http://localhost:9000/trsws/";
> **
>  serviceClass="se.digia.trs.route.webservice.ITrsWebService">
> **    </cxf:cxfEndpoint>**
> **    <bean id="routes" class="se.digia.trs.route.webservice.Routes" />**
> **    <camel:camelContext id="camel">
> **    <camel:routeBuilder ref="routes"/>
> **    </camel:camelContext>*
>
> ...
>
> *Routes.java*
> ...
>
> *  ITrsWebService serverBean = new TrsWebServiceImpl();**
> **  from("cxf:bean:trsWsEndpoint")..bean(serverBean);*
>
> ...
>
> Using soapUI I can verify that my implementation class gets called and that
> the web service works.
>
> However I have built a framework using iPOJO that basically creates the
> camel context and the route when the iPOJO component is started. I thus do
> not have access to any beans/endponts/contexts instantiated by Spring. How
> can I get this to work?
>
> I first tried to use cxf:bean like above. However there is no way (at least
> I cant find any) to create the cxfEndpoint. I cant refer to the cxf endpoint
> instantiated in Spring and I don't seem to be able to create one of my own
> from Java.
>
> I then tried using "cxf:" instead of "cxf:bean" like this:
>
> *  ITrsWebService serverBean = new TrsWebServiceImpl();
> >   from("cxf:
> > http://localhost:9001/trsws/?serviceClass=se.digia.trs.route.webservic
> > e.ITrsWebService
> > ").bean(serverBean);*
>
>
> But for some reason camel-cxf can't seem to find the ITrsWebService class
> (an interface). I get the following exception:
>
>
> *2011-05-26 11:33:31,655 | ERROR | 01-fdce4f9f0365) | webservice
> >           | ?                                   ? | [ERROR] null :
> > [trs.route.webservice.8f8bae86-9561-4c21-be01-fdce4f9f0365] The
> > callback method start has thrown an exception : Camel context failed
> > to start (WS)
> > **java.lang.RuntimeException: Camel context failed to start (WS)
> > ** at
> > se.digia.connect.core.service.RouteServiceBase.doStart(RouteServiceBas
> > e.java:70)
> > ** at
> > se.digia.connect.core.service.ServiceBase.start(ServiceBase.java:46)
> > ** at
> > se.digia.trs.route.webservice.WebserviceService.__start(WebserviceServ
> > ice.java:54)
> > ** at
> > se.digia.trs.route.webservice.WebserviceService.start(WebserviceServic
> > e.java)
> > ** at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> > Method)[:1.6.0_25]
> > ** at
> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
> > ava:39)[:1.6.0_25]
> > ** at
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
> > orImpl.java:25)[:1.6.0_25]
> > ** at java.lang.reflect.Method.invoke(Method.java:597)[:1.6.0_25]
> > ** at
> > org.apache.felix.ipojo.util.Callback.call(Callback.java:237)[68:org.ap
> > ache.felix.ipojo:1.6.8]
> > ** at
> > org.apache.felix.ipojo.util.Callback.call(Callback.java:193)[68:org.ap
> > ache.felix.ipojo:1.6.8]
> > ** at
> > org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallback.c
> > all(LifecycleCallback.java:86)[68:org.apache.felix.ipojo:1.6.8]
> > ** at
> > org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHa
> > ndler.__stateChanged(LifecycleCallbackHandler.java:162)[68:org.apache.
> > felix.ipojo:1.6.8]
> > ** at
> > org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHa
> > ndler.stateChanged(LifecycleCallbackHandler.java)[68:org.apache.felix.
> > ipojo:1.6.8]
> > ** at
> > org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:4
> > 55)[68:org.apache.felix.ipojo:1.6.8]
> > ** at
> > org.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:336)
> > [68:org.apache.felix.ipojo:1.6.8]
> > ** at
> > org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactor
> > y.java:165)[68:org.apache.felix.ipojo:1.6.8]
> > ** at
> > org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFacto
> > ry.java:301)[68:org.apache.felix.ipojo:1.6.8]
> > ** at
> > org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFacto
> > ry.java:238)[68:org.apache.felix.ipojo:1.6.8]
> > ** at
> > org.apache.felix.ipojo.IPojoFactory.updated(IPojoFactory.java:634)[68:
> > org.apache.felix.ipojo:1.6.8]
> > ** at
> > org.apache.felix.cm.impl.ConfigurationManager$UpdateConfiguration.run(
> > ConfigurationManager.java:1567)[5:org.apache.felix.configadmin:1.2.8]
> > ** at
> > org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:104)[5:org
> > .apache.felix.configadmin:1.2.8]
> > ** at java.lang.Thread.run(Thread.java:662)[:1.6.0_25]
> > **Caused by: java.lang.ClassNotFoundException:
> > se.digia.trs.route.webservice.ITrsWebService not found by
> > org.apache.camel.camel-cxf [165]
> > ** at
> > org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(
> > ModuleImpl.java:787)
> > ** at
> > org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)
> > ** at
> > org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(Modu
> > leImpl.java:1768)
> > ** at java.lang.ClassLoader.loadClass(ClassLoader.java:247)[:1.6.0_25]
> > ** at
> > org.apache.cxf.common.classloader.ClassLoaderUtils.loadClass2(ClassLoa
> > derUtils.java:236)
> > ** at
> > org.apache.cxf.common.classloader.ClassLoaderUtils.loadClass(ClassLoad
> > erUtils.java:222)
> > ** at
> > org.apache.camel.component.cxf.CxfEndpoint.createServerFactoryBean(Cxf
> > Endpoint.java:378)
> > ** at
> > org.apache.camel.component.cxf.CxfConsumer.<init>(CxfConsumer.java:59)
> > ** at
> > org.apache.camel.component.cxf.CxfEndpoint.createConsumer(CxfEndpoint.
> > java:127)
> > ** at
> > org.apache.camel.impl.EventDrivenConsumerRoute.addServices(EventDriven
> > ConsumerRoute.java:61)
> > ** at
> > org.apache.camel.impl.DefaultRoute.onStartingServices(DefaultRoute.jav
> > a:75)
> > ** at org.apache.camel.impl.RouteService.warmUp(RouteService.java:128)
> > ** at
> > org.apache.camel.impl.DefaultCamelContext.doWarmUpRoutes(DefaultCamelC
> > ontext.java:1832)
> > ** at
> > org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(Def
> > aultCamelContext.java:1758)
> > ** at
> > org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(Defaul
> > tCamelContext.java:1548)
> > ** at
> > org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelCon
> > text.java:1440)
> > ** 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.ja
> > va:1314)
> > ** at
> > se.digia.connect.core.service.RouteServiceBase.doStart(RouteServiceBas
> > e.java:54)
> > ** ... 21 more*
>
>
> How can I expose a web service with camel-cxf completely without using
> Spring? Is it even possible? If not, how do I access the cxf endpoint
> instantiated by Spring from my java code?
>
> I should add that I'm using code-first and thus do not use a WSDL file.
>
> /Bengt
>

Reply via email to