Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: More detailed oc4j guide

...

Tip

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

OC4J

Note

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. Not that OC4J 10.1.2 is not JSE 1.5 certified server. OC4J 11g 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, WSDL4J and few others. All of those frameworks are Oralce proprietary implementations in OC4J distribution. This giver Oracle really good interoperability between their products (e.g. Database) and insures interoperability with all Oracle portfolio. However it makes rather hard to introduce something

Tip

OC4J 10.1.3 comes with preliminary implementation of JAX-WS but this implementation is 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.

Anchor
xerces
xerces

Swapping Oracle XML parser with Xerces

Basic ide 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)
Note

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 boot there are loaded outdated JAX-WS APIs and implementation by Oracle. 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
Code Block
xml
xml

        <!-- 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

Code Block
xml
xml

<!-- <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)

Anchor
wsdl4j
wsdl4j

swapping Oracle wsdl.jar with wsdl4j.jar

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
  • 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.
Tip

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

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 debu JAXP problems - be sure that org.apache.xerces.jaxp.DocumentBuilderFactoryImpl are instantiated from within JAXP and not {{oracle.xml.parser.v2.DocumentBuilder
}}.

Anchor
f2
f2

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

Please be sure that wsdl4j.jar is loaded before wsdl.jar

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 ocj4.jar. Enable SAX debugging. Be sure You don't include douplicated jars in Your application like xercesImpl.jar. Review steps above once more. It works (wink).I got CXF working in OC4J by ignoring Oracle's XML parser and adding the Xerces parser libs as shared libraries, and by performing the QName hack above.

Integration with Application Server FAQ

...

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