Using Spring CXF descriptors in WildFly

In some cases, users might still want to consume Spring cxf.xml descriptors. On client side, in order to do that, the Spring libraries need to be available in the current thread classloader. For the Web Services stack to have correct visibility over Spring classes, the Spring libraries need to be properly installed in a specific WildFly module, the org.springframework.spring module, which many Web Services stack modules on the server already have optional dependencies to.

Installing Spring libraries in that module is basically a matter of copying the Spring jars in the correct path (JBOSS_HOME/modules/org/springframework/spring/main) which needs to be at first created, and adding its module.xml descriptor. Below is an example of the Spring module.xml, containing the name of jars referenced in the resourceroot paths, which must match the actual name of the jars in the module:

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.springframework.spring">
      <resource-root path="spring-core.jar" />
      <resource-root path="spring-beans.jar" />
      <resource-root path="spring-jms.jar" />
      <resource-root path="spring-context.jar" />
      <resource-root path="spring-asm.jar" />
      <resource-root path="spring-expression.jar" />
      <resource-root path="spring-tx.jar" />
      <resource-root path="spring-aop.jar" />
      <module name="javax.api" />
      <module name="javax.jms.api" />
      <module name="javax.annotation.api" />
      <module name="org.apache.commons.logging" />
      <module name="org.jboss.vfs" />

When Spring is available, the creation of Apache CXF Bus instances will load cxf.xml descriptor resources that can be found using the current thread classloader.

On server side, when the org.springframework.spring module is properly configured, JBossWS processes a custom descriptor, which can be added to the Web Services deployments. The convention for such a descriptor is the following:

  • The descriptor file name must be jbossws-cxf.xml
  • This descriptor is located in WEB-INF directory for POJO deployments
  • This descriptor is located in META-INF for EJB3 deployments

Here is an example of jbossws-cxf.xml, which contains an endpoint definition:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="" xmlns:beans="" xmlns:jaxws="" xmlns:xsi="" xsi:schemaLocation="">
   <jaxws:endpoint id="SampleWS" address="http://localhost:8080/Samplews" implementor="com.sample.SampleWS">
         <bean class="org.jboss.wsf.stack.cxf.JBossWSInvoker" />

Once loaded the jbossws-cxf.xml, the WildFly HTTP engine will be serving the endpoints.

Do you want some more Spring stuff ? check Spring Boot Tutorials !

Found the article helpful? if so please follow us on Socials