Deploying Apache CXF services on WebSphere Process Server
In this blog, we will look at how to deploy CXF application on WebSphere Process Server (WPS). One of the readers had asked me on how to deploy the sample application from the Chapter 2 in WPS, since my book covers deployment on tomcat server only. It was a good exercise for me to validate if the sample CXF application run on other servers as I haven’t tried this before.
I was able to run the application successfully with a modification to the module class loading policy . Given below are the steps required to deploy the sample CXF application in WPS. The version of WPS used was 7.0.
- Build the war file (orderapp.war) as mentioned in Chapter 2.
- Logon to WPS Administration Console
- Go to Applications -> Application Types – > WebSphere Enterprise applications. Click Install
- In next screen , provide the location of orderapp.war file.Click Next
- On the next screen, click Fast Path and click on Next
- On the Install New Application screen, Click on Step 3 Map virtual hosts for Web modules and select the orderapp.war file to map it to default_host virtual host
- On the Install New Application screen, Click on Step 4 Map context root for Web modules and enter the context root as /orderapp as shown below. Click Next
- On the Summary screen, click Finish.
- The orderapp.war would be deployed. On the confirmation screen, click Save to save the configuration to master configuration.
Next, you need to change the class loading policy for orderapp web module, to ensure that the CXF libraries, CXF JAX-WS and JAX-RS runtime and dependent files present in web module (all jar files in WEB-INF\lib) are loaded first , instead of WPS library to avoid any conflict. If you don’t change the class loading policy , the application deployment would be successful but would receive the following exception when you run the application -
com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0068E: Uncaught exception created in one of the service methods of the servlet CXFServlet in application orderapp_war. Exception created : java.lang.NoSuchMethodError: org/apache/ws/commons/schema/XmlSchema.getSchemaDocument()Lorg/w3c/dom/Document;
To change the class loading policy , follow these steps
- Go to Applications -> Application Types – > WebSphere enterprise applications and select orderapp_war
- Click on Manage modules
- Click on orderapp.war
Change the class loader order to “Classes loaded with local class loader first (parent last)” as shown belo and click Apply. Save the configuration.
- Start the orderapp_war enterprise application
- Run the web service client as mentioned in Chapter 2
Note if you plan to use CXF JAX-WS implementation with WAS/WPS , you would not be able to leverage the WS-Specifications (like WS-Security) offered by WAS/WPS container for that application and instead need to rely on CXF WS-Specification implementation.
To know, more about how to develop SOAP and RESTful web services, get a copy of my Apache CXF Web Service Book -