4 Replies Latest reply on Apr 2, 2009 4:10 AM by hkapoor

    Configuring CXF address

    tysgodhi

      I've succeeded in bundling my own CFX service using OSGI and getting ESB to run it, but only at port 8080 in the /cxf URL.  When I try to publish it to a different URL by using a fully-qualified address in the endpoint element of beans.xml, as shown in the example in Developing and Deploying JAX-WS Applications with FUSE ESB, I get the following stack trace.  Where/how can the full URL for a service be configured, and is it possible to configure listeners at multiple ports?

       

      Exception in thread "SpringOsgiExtenderThread-64" org.springframework.beans.fact

      ory.BeanCreationException: Error creating bean with name 'helloWorld': Invocatio

      n of init method failed; nested exception is javax.xml.ws.WebServiceException: j

      ava.lang.IllegalStateException: Endpoint address should be a relative URI wrt to

      the servlet address (use '/xxx' for example)

              at org.springframework.beans.factory.support.AbstractAutowireCapableBean

      Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1337)

              at org.springframework.beans.factory.support.AbstractAutowireCapableBean

      Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)

              at org.springframework.beans.factory.support.AbstractAutowireCapableBean

      Factory$1.run(AbstractAutowireCapableBeanFactory.java:409)

              at java.security.AccessController.doPrivileged(Native Method)

              at org.springframework.beans.factory.support.AbstractAutowireCapableBean

      Factory.createBean(AbstractAutowireCapableBeanFactory.java:380)

              at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb

      ject(AbstractBeanFactory.java:264)

              at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr

      y.getSingleton(DefaultSingletonBeanRegistry.java:221)

              at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe

      an(AbstractBeanFactory.java:261)

              at org.springframework.beans.factory.support.AbstractBeanFactory.getBean

      (AbstractBeanFactory.java:185)

              at org.springframework.beans.factory.support.AbstractBeanFactory.getBean

      (AbstractBeanFactory.java:164)

              at org.springframework.beans.factory.support.DefaultListableBeanFactory.

      preInstantiateSingletons(DefaultListableBeanFactory.java:429)

              at org.springframework.context.support.AbstractApplicationContext.finish

      BeanFactoryInitialization(AbstractApplicationContext.java:729)

              at org.springframework.osgi.context.support.AbstractDelegatedExecutionAp

      plicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.ja

      va:276)

              at org.springframework.osgi.extender.internal.dependencies.startup.Depen

      dencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterAp

      plicationContextExecutor.java:145)

              at java.lang.Thread.run(Thread.java:619)

      Caused by: javax.xml.ws.WebServiceException: java.lang.IllegalStateException: En

      dpoint address should be a relative URI wrt to the servlet address (use '/xxx' f

      or example)

              at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:267)

              at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:201)

              at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:394)

              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.

      java:39)

              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces

      sorImpl.java:25)

              at java.lang.reflect.Method.invoke(Method.java:597)

              at org.springframework.beans.factory.support.AbstractAutowireCapableBean

      Factory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1413)

              at org.springframework.beans.factory.support.AbstractAutowireCapableBean

      Factory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1374)

              at org.springframework.beans.factory.support.AbstractAutowireCapableBean

      Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1334)

              ... 14 more

      Caused by: java.lang.IllegalStateException: Endpoint address should be a relativ

      e URI wrt to the servlet address (use '/xxx' for example)

              at org.apache.servicemix.cxf.transport.http_osgi.OsgiTransportFactory.ge

      tDestination(OsgiTransportFactory.java:59)

              at org.apache.cxf.endpoint.ServerImpl.initDestination(ServerImpl.java:90

      )

              at org.apache.cxf.endpoint.ServerImpl.(ServerImpl.java:69)

              at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.ja

      va:118)

              at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactory

      Bean.java:168)

              at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:336)

              at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:251)

              ... 23 more

        • 1. Re: Configuring CXF address
          wfreitas

          Hi,

           

          Does your test case look like the cxf-osgi example incluced with Servicemix 4? Are you exposing the web service through the OSGi HTTP Service?

           

          If the answer is YES I think you can't change the full URL because your service must be published using the same host:port pair configured in the OSGi HTTP Service. If you need to change this configuration on the OSGi HTTP bundle itself.

           

          Hope it helps

           

          --

          Wilson Freitas

          Software Architect

          Vetta Technologies

          • 2. Re: Configuring CXF address
            tysgodhi

            OK, thanks.  But, if the only way to configure addresses, and presumably stuff like SSL transport as well, is to hack a bundle released by servicemix as part of the container, instead of, say, a config file in the etc directory, then that's not too convenient for deployment.

            • 3. Re: Configuring CXF address
              wfreitas

              Hi,

               

              To specify the location URI you can use the cxf-bc component. The cxf-wsdl-first example included in SMX distribution shows how to do it. To specify a consumer using cxf-bc the configuration looks like this:

               

              =================================================

              <cxfbc:consumer wsdl="/wsdl/calculator.wsdl"

                                    service="calculator:CalculatorService"

                                    endpoint="CalculatorPort"

                                    targetEndpoint="CalculatorPortProxy"

                                    targetService="calculator:CalculatorService"

                                    targetInterface="calculator:CalculatorPortType"

                                    locationURI="http://localhost:8192/person">

                         

              </cxfbc:consumer>

              =================================================

               

              I hope it helps.

               

              --

              Wilson Freitas

              Software Architect

              Vetta Technologies

              • 4. Re: Configuring CXF address

                Hi,

                 

                I have created servicemix-cxf-bc-service-unit by the following command

                 

                mvn archetype:create -DarchetypeGroupId=org.apache.servicemix.tooling -DarchetypeArtifactId=servicemix-cxf-bc-service-unit  -DarchetypeVersion=3.3.0.5-fuse -DgroupId=GEIP -DartifactId=SOAPReceiver -DremoteRepositories=http://repo.open.iona.com/maven2

                 

                my xbean.xml has the following :

                ...

                (ServerImpl.java:58)

                        at org.apache.servicemix.cxfbc.CxfBcConsumer.validate(CxfBcConsumer.java:493)

                 

                What could I be doing wrong ??

                 

                -Harshit