1 2 Previous Next 15 Replies Latest reply on Nov 12, 2011 3:25 AM by njiang

    CXF Endpoint Creation

    gt6081a

      Since the other thread got a wee bit cluttered I figured I would start one anew regarding my current effort towards creating a cxf endpoint to be leveraged by camel in future routes.

       

      I have pretty much taken the example striaght out of my trusty Camel In Action book.  At any rate I am getting an error that I am unfamiliar with which I have attached.  I am not familiar with referencing the OSGI classpath xml files so I am sure it is an issue surrounding those.

       

      The beans.xml file is:

       

        • 1. Re: CXF Endpoint Creation
          njiang

          Which version of CXF are you using ?

          I'm just assuming that you are using CXF 2.3.x ?

          Do you try to add import package of "org.apache.cxf.binding.soap.spring" into your bundle ?

           

          Willem

          • 2. Re: CXF Endpoint Creation
            gt6081a

            I am not trying to use any specific version of cxf as I am just trying to leverage the packages in servicemix.  Looking at the installed features I see:

             

            camel-cxf is 2.7.1-fuse-00-43

            cxf is 2.4.1-fuse-00-43

            servicemix-cxf-bc is 2011.02.0-fuse-00-43

             

            I haven't tried importing anything into the POM other than

             

             

                 

             

            Edited by: gt6081a on Nov 7, 2011 3:06 PM

            • 3. Re: CXF Endpoint Creation
              gt6081a

              Ok so I went through the maven importing dance and now that I am through that I am seeing the following when trying to deploy.   Those included xml files that are referenced I just copied from the book so I am not sure what their role is or how I should treat issues around them like this.

               

               

              10:18:18,799 | INFO  | xtenderThread-60 | DefaultListableBeanFactory       | 68 - org.springframework.beans - 3.0.5.RELEASE | Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@46ccc076: defining beans ; root of factory hierarchy

              10:18:18,800 | WARN  | xtenderThread-60 | DisposableBeanAdapter            | 68 - org.springframework.beans - 3.0.5.RELEASE | Invocation of destroy method 'shutdown' failed on bean with name 'cxf': org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'org.apache.cxf.binding.soap.SoapBindingFactory': Singleton bean creation not allowed while the singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)

              10:18:18,800 | ERROR | xtenderThread-60 | ContextLoaderListener            | 85 - org.springframework.osgi.extender - 1.2.1 | Application context refresh failed (OsgiBundleXmlApplicationContext(bundle=SalesforceEndpoint, config=osgibundle:/META-INF/spring/*.xml))

              org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.cxf.binding.soap.SoapBindingFactory' defined in OSGi resource[classpath:META-INF/cxf/cxf-extension-soap.xml|bnd.id=271|bnd.sym=SalesforceEndpoint]: Could not resolve matching constructor (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)

                   at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:250)[68:org.springframework.beans:3.0.5.RELEASE]

                   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1003)[68:org.springframework.beans:3.0.5.RELEASE]

                   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:907)[68:org.springframework.beans:3.0.5.RELEASE]

                   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)[68:org.springframework.beans:3.0.5.RELEASE]

                   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)[68:org.springframework.beans:3.0.5.RELEASE]

                   at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)[68:org.springframework.beans:3.0.5.RELEASE]

                   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)[68:org.springframework.beans:3.0.5.RELEASE]

                   at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)[68:org.springframework.beans:3.0.5.RELEASE]

                   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)[68:org.springframework.beans:3.0.5.RELEASE]

                   at org.springframework.beans.factory.support.AbstractBeanFactory.isSingleton(AbstractBeanFactory.java:396)[68:org.springframework.beans:3.0.5.RELEASE]

                   at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:317)[68:org.springframework.beans:3.0.5.RELEASE]

                   at org.springframework.context.support.AbstractApplicationContext.getBeanNamesForType(AbstractApplicationContext.java:1136)[70:org.springframework.context:3.0.5.RELEASE]

                   at org.apache.cxf.bus.spring.SpringBeanLocator.getBeansOfType(SpringBeanLocator.java:89)[123:org.apache.cxf.bundle:2.4.1.fuse-00-43]

                   at org.apache.cxf.bus.CXFBusImpl.getExtension(CXFBusImpl.java:99)[123:org.apache.cxf.bundle:2.4.1.fuse-00-43]

                   at org.apache.cxf.bus.extension.ExtensionManagerBus.initialize(ExtensionManagerBus.java:151)[123:org.apache.cxf.bundle:2.4.1.fuse-00-43]

                   at org.apache.cxf.bus.spring.SpringBus.onApplicationEvent(SpringBus.java:92)[123:org.apache.cxf.bundle:2.4.1.fuse-00-43]

                   at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:97)[70:org.springframework.context:3.0.5.RELEASE]

                   at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:303)[70:org.springframework.context:3.0.5.RELEASE]

                   at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:911)[70:org.springframework.context:3.0.5.RELEASE]

                   at org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.finishRefresh(AbstractOsgiBundleApplicationContext.java:235)[82:org.springframework.osgi.core:1.2.1]

                   at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:358)[82:org.springframework.osgi.core:1.2.1]

                   at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)[82:org.springframework.osgi.core:1.2.1]

                   at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)[82:org.springframework.osgi.core:1.2.1]

                   at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)[85:org.springframework.osgi.extender:1.2.1]

                   at java.lang.Thread.run(Thread.java:662)[:1.6.0_23]

              • 4. Re: CXF Endpoint Creation
                ffang

                Hi,

                 

                Your bundle depend CXF 2.2.10 but in OSGi container the CXF version is 2.4.1-fuse-00-43, this mismatch could cause issues, also, after CXF 2.4.0, you don't need

                 

                anymore,

                so you need remove it from your beans.xml and change the CXF dependency to keep it same as the OSGi container and rebuild it.

                 

                Freeman

                • 5. Re: CXF Endpoint Creation
                  gt6081a

                  Thanks, making those changes everything appears to have been deployed to the container without issue.

                   

                  So now in a camel route I should be able to just call cxf:bean:salesforceLogin and that will in effect pass the message off to that webservice?

                  • 6. Re: CXF Endpoint Creation
                    gt6081a

                    So deploying my route which references the endpoint I just deployed, I am getting

                    org.apache.camel.RuntimeCamelException: org.apache.camel.FailedToCreateRouteException: Failed to create route SalesforceAuthentication at: >>> To[cxf:bean:salesforceLogin] <<< in route: Route[[From[timer://sforce?fixedRate=true&period=60000]] -> ... because of Failed to resolve endpoint: cxf://bean:salesforceLogin due to: registry entry called salesforceLogin of type org.apache.camel.component.cxf.spring.CxfEndpointBean must be specified
                    

                    I am not sure why the endpoint I deployed wouldn't be in the context. 

                     

                    The route is just

                     

                     

                       <to uri="cxf:bean:salesforceLogin"/>

                        

                     

                    Just as a reminder the beans.xml for the deployed endpoint is:

                    <?xml version="1.0" encoding="UTF-8"?>
                    <beans xmlns="http://www.springframework.org/schema/beans"
                        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                        xmlns:cxf="http://camel.apache.org/schema/cxf"
                         xmlns:sfdc="urn:enterprise.soap.sforce.com"
                        xsi:schemaLocation="
                            http://www.springframework.org/schema/beans 
                            http://www.springframework.org/schema/beans/spring-beans.xsd
                            http://camel.apache.org/schema/cxf
                            http://camel.apache.org/schema/cxf/camel-cxf.xsd">
                        <import resource="classpath:META-INF/cxf/cxf.xml"></import>
                        <import resource="classpath:META-INF/cxf/osgi/cxf-extension-osgi.xml"></import>
                         <cxf:cxfEndpoint
                              id="salesforceLogin"
                              address="https://test.salesforce.com/services/Soap/c/22.0"
                              wsdlURL="wsdl/sfdc.wsdl"
                              serviceClass="com.sforce.soap.enterprise.Login">
                         </cxf:cxfEndpoint>
                    </beans>
                    

                     

                    Edited to add endpoint

                    • 7. Re: CXF Endpoint Creation
                      davsclaus

                      Where do you have the Camel routes?

                       

                      If you have the Camel routes and the CXF bean in the same XML file, then Camel should be able to find the CXF bean.

                      • 8. Re: CXF Endpoint Creation
                        njiang

                        You need to make sure the  are in the same application context of the camel context.

                         

                        Willem

                        • 9. Re: CXF Endpoint Creation
                          gt6081a

                          Currently they are in separate projects as I wanted to have the endpoint used by other routes as well that will be deployed separately.  Is there a way to make the CXF endpoint available outside of the same xml?

                          • 10. Re: CXF Endpoint Creation
                            gt6081a

                            I've put the camel-context.xml and beans.xml into the same osgi bundle and deployed.  Now I get

                             

                            10:55:25,920 | ERROR | xtenderThread-75 | ContextLoaderListener            | 85 - org.springframework.osgi.extender - 1.2.1 | Application context refresh failed (OsgiBundleXmlApplicationContext(bundle=HCMSalesforceRoute, config=osgibundle:/META-INF/spring/*.xml))
                            org.apache.camel.FailedToCreateProducerException: Failed to create Producer for endpoint: Endpoint[cxf://bean:salesforceLogin]. Reason: org.apache.cxf.service.factory.ServiceConstructionException: Could not find definition for service {http://enterprise.soap.sforce.com/}SforceService.
                            

                             

                            I am looking over the namespaces and such and everything seems to match so I am not entirely sure where the disconnect is.

                             

                            camel-context.xml:

                            <?xml version="1.0" encoding="UTF-8" standalone="no"?>
                            <beans xmlns="http://www.springframework.org/schema/beans" 
                                    xmlns:ctx="http://www.springframework.org/schema/context" 
                                    xmlns:osgi="http://camel.apache.org/schema/osgi" 
                                    xmlns:osgix="http://www.springframework.org/schema/osgi-compendium" 
                                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                                    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        
                                              http://camel.apache.org/schema/osgi 
                                              http://camel.apache.org/schema/osgi/camel-osgi.xsd        
                                              http://www.springframework.org/schema/osgi-compendium 
                                              http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd        
                                              http://www.springframework.org/schema/context 
                                              http://www.springframework.org/schema/context/spring-context.xsd ">
                            
                                   <camelContext xmlns="http://camel.apache.org/schema/spring" trace="true">
                            
                                 <route id="SalesforceAuthentication">
                                         <from uri="timer://sforce?fixedRate=true&amp;period=60000"></from>
                                         <to uri="velocity://velocity/sforceLogin.vm"></to>
                                     <convertBodyTo type="java.lang.String"></convertBodyTo>
                                     <to uri="cxf:bean:salesforceLogin"></to> 
                                     <convertBodyTo type="java.lang.String"></convertBodyTo>
                                     <to uri="file:data/sforce?fileName=sforceLoginResponse.xml"></to>
                                </route>      
                                 
                            </camelContext>
                            </beans>
                            

                             

                            beans.xml:

                            
                            <?xml version="1.0" encoding="UTF-8"?>
                            <beans xmlns="http://www.springframework.org/schema/beans"
                                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                xmlns:cxf="http://camel.apache.org/schema/cxf"
                                 xmlns:sfdc="urn:enterprise.soap.sforce.com"
                                xsi:schemaLocation="
                                    http://www.springframework.org/schema/beans 
                                    http://www.springframework.org/schema/beans/spring-beans.xsd
                                    http://camel.apache.org/schema/cxf
                                    http://camel.apache.org/schema/cxf/camel-cxf.xsd">
                            
                                <import resource="classpath:META-INF/cxf/cxf.xml"></import>
                                <import resource="classpath:META-INF/cxf/osgi/cxf-extension-osgi.xml"></import>
                            
                                 <cxf:cxfEndpoint
                                      id="salesforceLogin"
                                      address="https://test.salesforce.com/services/Soap/c/22.0"
                                      wsdlURL="wsdl/sfdc.wsdl"
                                      serviceClass="com.sforce.soap.enterprise.SforceService">
                                 </cxf:cxfEndpoint>
                            
                            </beans>
                            

                             

                            I also attached the WSDL in case it is relevant.  I have the bundle setup to generate the sources from the WSDL with CXF, so all the stubs are a part of the bundle as well.

                            • 11. Re: CXF Endpoint Creation
                              davsclaus

                              They have to be in the same file.

                               

                              Alternatively you would need to use xml:include to include another XML file. But its just easier to put them all in the same XML file, to have it working.

                              • 12. Re: CXF Endpoint Creation
                                gt6081a

                                I tried putting them into the same file.  I actually got the exact same error.

                                 

                                14:47:09,007 | ERROR | xtenderThread-83 | ContextLoaderListener            | 85 - org.springframework.osgi.extender - 1.2.1 | Application context refresh failed (OsgiBundleXmlApplicationContext(bundle=HCMSalesforceRoute, config=osgibundle:/META-INF/spring/*.xml))
                                org.apache.camel.FailedToCreateProducerException: Failed to create Producer for endpoint: Endpoint[cxf://bean:salesforceLogin]. Reason: org.apache.cxf.service.factory.ServiceConstructionException: Could not find definition for service {http://enterprise.soap.sforce.com/}SforceService.
                                        at org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:362)[77:org.apache.camel.camel-core:2.7.1.fuse-00-43]
                                        at org.apache.camel.impl.ProducerCache.acquireProducer(ProducerCache.java:93)[77:org.apache.camel.camel-core:2.7.1.fuse-00-43]
                                        at org.apache.camel.impl.ProducerCache.startProducer(ProducerCache.java:124)[77:org.apache.camel.camel-core:2.7.1.fuse-00-43]
                                

                                 

                                When the stubs from the wsdl are generated, I see the com/sforce/soap/enterprise/SforceService.java, and the class exists in the bundle when I look inside.  Is there something misconfigured with the serviceClass or something else that would be causing this?

                                • 13. Re: CXF Endpoint Creation
                                  ffang

                                  Hi,

                                   

                                  This error generally means your wsdl has not wsdl:service like

                                  SforceService

                                  Could you check your wsdl/sfdc.wsdl?

                                   

                                  Freeman

                                  • 14. Re: CXF Endpoint Creation
                                    gt6081a

                                    In the WSDL is

                                     

                                     

                                     

                                    Which gives the error that SforceService is not an interface

                                    1 2 Previous Next