2 Replies Latest reply on Mar 15, 2012 5:33 AM by luigi12

    jboss ws cxf client istantiated from a spring context without spring libraries in common/lib

    luigi12

      Hi all, I am a newbie in jboss ws

       

      I am developing a "headless" jboss/web application which is loaded and started by means of a spring application context;

      which in turn is loaded by a spring ContextLoaderListener configured in the web.xml;

       

      the application connects to external devices and communicates with remote applications using web services (client and service);

      the spring libraries are not deployed in the common/lib directory (Jboss-6.1.0-Final)

       

      when instantiating the client proxy to a remote web service,

      I receive a (well known) exception thrown during the execution of the the javax.xml.ws.Service constructor:

       

      java.lang.NoClassDefFoundError: org/springframework/beans/BeansException

      at org.jboss.wsf.stack.cxf.client.configuration.JBossWSBusFactory.getSpringBusFactory(JBossWSBusFactory.java:120)

       

      the exception in due to the missing spring jars in the common/lib directory, while the spring libraries are available in the current thread context classpath.

       

      After examination of the classes

       

      org.jboss.wsf.stack.cxf.client.ProviderImpl and

      org.jboss.wsf.stack.cxf.client.configuration.JbossWSBusFactory,

       

      I inserted the following code, before the invocation of the javax.xml.ws.Service constructor (through an extending class):

       

          BusFactory busFactory = BusFactory.newInstance();

          if (busFactory instanceof JBossWSBusFactory)

                  BusFactory.setThreadDefaultBus(((JBossWSBusFactory)busFactory).getNonSpringBusFactory().createBus());

         

           MyService service = new MyService(..

       

      where MyService extends javax.xml.ws.Service.

       

      and now the service client is istantiated ok.

       

      Required (provided scope) jars in the compilation classpath,

      from directory %JBOSS_HOME%/ client:

        cxf-api.jar, cxf-rt-core.jar, jbossws-cxf-client.jar

       

      My question:

      can the same result be achieved with modification of the jboss ws cxf ... configuration files ?

       

      thanks to all,

      Luigi

        • 1. Re: jboss ws cxf client istantiated from a spring context without spring libraries in common/lib
          rwoods

          Hi Luigi, i had the same problem.

           

          The CXF Bus implementation is defined in the file:

           

          ${jboss.server.home.url}/deployers/jbossws.deployer/jbossws-cxf-factories.jar!/META-INF/services/org.apache.cxf.bus.factory

           

          Change the first line from "org.jboss.wsf.stack.cxf.client.configuration.JBossWSBusFactory" to "org.jboss.wsf.stack.cxf.client.configuration.JBossWSNonSpringBusFactory" to skip the Spring auto-discovery feature and always use the non-spring bus. That should allow you to decouple your project's build from the ws implementation.

          • 2. Re: jboss ws cxf client istantiated from a spring context without spring libraries in common/lib
            luigi12

            Well Richard, the changed configuration is consistent wth the fact that the spring libraries are not deployed in jboss libs.

            As soon as possible I will try to put the modified jbossws-cxf-factories.jar in the classpath of the war application, in order to further decouple the application from the host jboss

            (I still don't know if it will work, due to the ClassLoader problems ..)

            Thank you very much.

             

            by Luigi