OC4J Configuration for Web Services

From Skyway Wiki

Jump to: navigation, search

Contents

Overview

Skyway utilizes CXF 2.1 for its web service implementations on consumption and production. CXF is a project from Apache and has seen a great degree of adoption due to its flexibility, WS support and great performance.

When using OC4J, there are a few adjustments that need to be made to the container itself to enable it to use CXF. These changes are required in OC4J 10.x due to the fact that it shipped with preliminary web service libraries and JAX-WS implementation.

CXF has a recommended setup for OC4J that was described with CXF 2, but not updated with the newer release of CXF 2.1. This setup document is a good starting point, but to simplify the distribution, we have taken a slightly different approach when Skyway deploys to OC4J. If you will not be using web services in your Skyway projects, then there is no special setup that needs to be performed. But if you are using web services within the project, then you must follow the below setup. For reference, here is the CXF original setup document.

http://cwiki.apache.org/CXF20DOC/appserverguide.html


OC4J Setup

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 Oracle proprietary implementations in the OC4J distribution. This gives Oracle really good interoperability between their products but it makes it rather hard to introduce something which needs different implementation of above APIs (like CXF). 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.).

Replace the Oracle XML Parser with Xerces

The basic idea behind how to do this is described in detail here: http://www.oracle.com/technology/tech/java/oc4j/1013/how_to/how-to-swapxmlparser/doc/readme.html Create OC4J shared library named cxf.foundation. Skyway is dependent upon this name, so be sure to use it exactly. Add the following contents to the shared library:

  • xercesImpl-2.9.0.jar
  • xml-apis-2.9.0.jar
  • xalan-2.7.1.jar
  • serializer-2.7.1.jar

Replace the OC4J JAX-WS Libraries

OC4J has preliminary support for JAX-WS, unfortunately this means that during OC4J boot it loads outdated JAX-WS APIs and implementation by Oracle. This occurs even before shared libraries comes into action, at a 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:

  • Copy the jaxws-api-2.1-1.jar file to ${oracle.home}/webservices/lib/jaxws
  • Copy the geronimo-ws-metadata_2.0_spec-1.1.2.jar file to ${oracle.home}/webservices/lib/jaxws
  • Unpack the OC4J.jar file
  • Locate META-INF/boot.xml
    • Replace the line:
    • <code-source path="${oracle.home}/webservices/lib/jws-api.jar" if="java.specification.version == /1\.[5-6]/"/>
  • With the two lines:
    • <code-source path="${oracle.home}/webservices/lib/jaxws-api-2.1-1.jar" if="java.specification.version == /1\.[5-6]/"/>
    • <code-source path="${oracle.home}/webservices/lib/geronimo-ws-metadata_2.0_spec-1.1.2.jar" if="java.specification.version == /1\.[5-6]/"/>
  • repackage oc4j.jar (don't forget about MANIFEST.MF - use jar -m META-INF/MANIFEST.MF)


Skyway Setup

Fixing the Classpath

Since OC4J now has the correct WS libraries to run, you can now remove those libraries from the classpath of the application. To do this, follow the below steps:

  • R-Click the project and select “properties”
  • Click the “Java Build Path preference panel
  • Click the “libraries” tab
  • Select the below libraries and click the “remove” button
    • SKYWAY_WS_WEBSERVICE/xalan-2.7.1.jar
    • SKYWAY_WS_WEBSERVICE/xercesImpl-2.9.0.jar
    • SKYWAY_WS_WEBSERVICE/xml-apis-2.9.0.jar
    • SKYWAY_WS_WEBSERVICE/serializer-2.7.1.jar
    • SKYWAY_WS_CXF/Geronimo-ws-metadata_2.0_spec-1.1.2.jar
  • Click “OK”

Deploy a Skyway Application

For this setup to work, you must deploy the Skyway modeled application as an EAR and not as a WAR. To do this, simply open the project model and go to the “Enterprise Configuration” tab and ensure that the “Container Settings” section is flagged as an EJB3 deployment to an EAR.

Personal tools