You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 21 Next »

Application Server Specific Configuration Guide

This document provides app server-specific configuration information for running Apache CXF.

JBoss

If you package the war in the ear, you might need to add the jboss specific file (jboss-app.xml) in the $EAR/META-INF folder to config the classloader.

<?xml version="1.0" encoding="UTF-8"?>
<jboss-app>
	<loader-repository>
		apache.cxf:loader=spring_http.ear
		<loader-repository-config>
			java2ParentDelegation=false
		</loader-repository-config>
	</loader-repository>
</jboss-app>

If you are coming across LinkageErrors involving the QName class, try repackaging the stax-api jar without the javax.xml.namespace.QName class.  (In JBoss 4.0.5GA at least) a conflicting version of this class is included in JBoss's lib and lib/endorsed directories.  This was the only way I could get CXF working in my environment.

WebLogic

There are two ways to deploy a CXF WAR archive in WebLogic. (Note: This has been validated on WebLogic9.2.)

Put jars in endorsed folder

  • Put the geronimo-ws-metadata_2.0_spec-1.1.1.jar in the $Weblogic_Home/jdk_../jre/lib/endorsed folder.
  • Deploy the CXF war in weblogic.
    (This way is not recommended, since it might break the application server itself. )

Pack war in an ear, deploy the ear with weblogic-application.xml

  • Create a standard J2EE application.xml file in the META-INF folder. (Take $CXF_HOME/samples/java_first_spring_support for example)
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE application PUBLIC
    		"-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN"
    		"http://java.sun.com/dtd/application_1_3.dtd">
    <application>
    	<display-name>spring_http</display-name>
    	<module>
    		<web>
    			<web-uri>spring_http.war</web-uri>
    			<context-root>spring</context-root>
    		</web>
    	</module>
    </application>
    
  • Create a weblogic-application.xml (Weblogic specific) in the META-INF folder.
    <?xml version="1.0" encoding="UTF-8"?>
    <weblogic-application xmlns="http://www.bea.com/ns/weblogic/90">
    	<application-param>
    		<param-name>webapp.encoding.default</param-name>
    		<param-value>UTF-8</param-value>
    	</application-param>
    	<prefer-application-packages>
    		<package-name>javax.jws.*</package-name>
    	</prefer-application-packages>
    </weblogic-application>
    
  • Run "jar cvf ..." command to create the ear and then deploy it.

    This is the recommend way to deploy since it only impacts a single module.

Websphere

Currently, I've only found the endorsed way to make cxf work with websphere. (Note: this has been validated against Websphere6.1.0.0)

put jar in the endorsed folder

  • put the wsdl4j-1.6.1.jar in the $WebSphere_HOME/java/jre/lib/endorsed folder.
  • In the WebSphere console, find the specific enterprise application, click the "Class loading and update detection".
    • Mark the "Classes loaded with application class loader first" selected.
    • Mark the "Class loader for each war file in application" selected.

And then restart the Websphere server. (Because we changed the endorsed folder, we need to restart it to make it effect).

Please make sure your classpath doesn't have the servlet-2.5 library, since WebSphere6.1 is servlet-2.4 compliant!

OC4J

This guide requires heavy customization of OC4J configuration. Bear in mind that some of steps presented below are either undocumented or unsupported. We strongly advice to do those steps on separate container, dedicated exclusively for CXF.

Disclaimer

This guide covers only 10.1.3.X.X version of OC4J. Note that OC4J 10.1.2 is not JSE 1.5 certified server. OC4J 11_g_ is fully JEE 5.0 certified stack and comes with their own JAX-WS implementation.

Background

Oracle OC4J comes with highly customized XML stack by Oracle including SAX, StAX, JAXP, JAX-WS, SAAJ, WSDL and few others. All of those frameworks are Oralce proprietary implementations in OC4J distribution. This gives Oracle really good interoperability between their products (e.g. Database) and assures interoperability with all Oracle portfolio. However it makes rather hard to introduce something which needs different implementation of above APIs.


OC4J 10.1.3 comes with preliminary implementation of JAX-WS (JSR-181) but this implementation is somewhat limited only to top-down scenario, with very limited customization (lack of JAXB 2.0 etc.).

Configuration overview

Few components need to be customized in OC4J towards CFX integration:

Unfortunately all of those components have to be configured in different parts of OC4J.

Oracle OC4J class loading

Key part toward successful CXF integration with OC4J is to understand how does class loaders work in OC4J. Basically when starting OC4J there are generally three stages where customization could occur:

  1. When Virtual Machine boot
  2. When OC4J boot
  3. When CXF (aplication) boot

Last step is quite easy to achieve - basically OC4J has quite powerful class loader and easy customization console. Unfortunately there are some components that could not be configured this way. They are configured during OC4J boot. Unfortunately one of this is OC4J webservices stack (located in $ORACLE_HOME/webservices/lib).

Needed components

Before start please download Apache CXF 2.0.1 or better and Xerces 2.8.1

Preparing stax-api

Remove javax.xml.namespace.QName from stax-api shiped with CXF. Oracle apparently has it already in $ORACLE_HOME/j2ee/home/lib/jax-qname-namespace.jar.

Swapping Oracle XML parser with Xerces

Basic idea behind how to do this is described in details here

Create OC4J shared libary named cxf.foundation and put there:

  • xercesImpl.jar (from Xerces distribution)
  • xml-apis-1.2.02.jar (from CXF-distribution)
  • xalan-2.7.0.jar (ditto)
  • geronimo-ws-metadata_2.0_spec-1.1.1.jar (ditto)

When building Your application DO NOT INCLUDE THOSE COMPONENTS again.

Get rid of OC4J JAX-WS libraries

OC4J has preliminary support for JAX-WS, unfortunately this means that during OC4J boot there are loaded outdated JAX-WS APIs and implementation by Oracle. This occurs even before shared libraries comes into action, on very early stage of OC4J boot. Boot-time OC4J libraries are configured in boot.xml file in $ORACLE_HOME/j2ee/home/oc4j.jar bootstrap jar. To get rid of this:

  • unpack oc4j.jar file
  • locate META-INF/boot.xml file and edit it
  • find section
        <!-- WS jax-rpc -->
        <code-source path="${oracle.home}/webservices/lib/jaxr-api.jar"/>
        <code-source path="${oracle.home}/webservices/lib/jaxrpc-api.jar"/>
        <code-source path="${oracle.home}/webservices/lib/jaxb-api.jar"/>
        <code-source path="${oracle.home}/webservices/lib/saaj-api.jar"/>
        <code-source path="${oracle.home}/webservices/lib/jws-api.jar" if="java.specification.version == /1\.[5-6]/"/>

and comment out line which include jws-api.jar entry, like below

<!-- <code-source path="${oracle.home}/webservices/lib/jws-api.jar" if="java.specification.version == /1\.[5-6]/"/> -->
  • repackage oc4j.jar (don't forget about MANIFEST.MF - use jar -m META-INF/MANIFEST.MF)

swapping Oracle wsdl.jar with wsdl4j.jar

Additionally Oracle provides it's own implementation of WSDL functinality which conflicts with wsdl4j.jar. To get rid of this add -Xbootclasspath/p:"<path to wsdlj>/wsdl4j-1.6.1.jar" option to JVM parametrs (either in command line running OC4J standalone or in OPMN).

Deploying applications

When deploying please follow those steps:

  • Edit deployment plan
  • Edit Configure class loading in the deployment plan like described here
  • Uncheck oracle.xml library
  • Check cxf.foundation library
  • Uncheck Search Local Classes First
  • do not include xercesImpl, xml-apis, xalan and geronimo-ws-metadata_2.0_spec-1.1.1.jar in war - those will be automatically loaded by by OC4J Shared Libraries class loader.

You can automate above steps by packaging You war into ear archive (even though) if it's only war and providing orion-application.xml proprietary descriptor as described here. You could also provide proprietary orion-web.xml in Your war instrumenting Search Local Classes First attribute described above. This step is described here.

Oracle FAQ

I'm getting java.lang.ClassCastException: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl

This primarily happens when:

  • xerces is loaded twice - by shared library class loader and application class loader
  • or when there is mismatch between xerces and oracle implementation of SAX API

Please be sure You properly installed and enabled for Your application cxf.foundation shared library as described here. If Yes please be sure that You didn't include xercesImpl.jar in Your war. If You still have problems please see how You can debug JAXP problems - be sure that org.apache.xerces.jaxp.DocumentBuilderFactoryImpl are instantiated from within JAXP and not oracle.xml.parser.v2.DocumentBuilder.

I cannot get WSDL (getting HTTP 500 accesing my CXF service WSDL with http://myshot/myservice?wsdl)

Please be sure that wsdl4j.jar is loaded before wsdl.jar as described here

I'm getting java.lang.NoSuchMethodException: oracle.j2ee.ws.wsdl.extensions.soap.SOAPBodyImpl.getElementType()

See this

I cannot get it to work still

Try something simple. Download OC4J standalone and bootstrap it from command line directly: java [options] -jar oc4j.jar. Enable SAX debugging. Be sure You don't include douplicated jars in Your application like xercesImpl, xalan, xml-apis and geronimo-ws-metadata_2.0_spec-1.1.1.jar. Review steps above once more. It works .

Integration with Application Server FAQ

1.
Q: I have this error: javax.xml.ws.WebServiceException: Cannot create SAAJ factory instance.
A: Please make sure you have the saaj-impl-1.3.jar in the classpath and make sure your app picks up this one instead of weblogic one.

Resources

Utilizing the OC4J Class Loading Framework
Deploy XFire in WebLogic
Understanding WebLogic ClassLoader
JBoss Class Configuration
Troubleshooting JAXP

  • No labels