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

Quick Steps:

  1. Find the shared-lib directory which is located in: <OC4J_HOME>/j2ee/home
  2. Create a directory named: cxf.foundation. Skyway is dependent upon this name, so be sure to use it exactly.
  3. Inside there create a directory named, 1.0
  4. Drop the following 4 files in it:
    1. xercesImpl-2.9.0.jar
    2. xml-apis-2.9.0.jar
    3. xalan-2.7.1.jar
    4. serializer-2.7.1.jar
  5. Add the following code to the server.xml file which is located in: <OC4J_HOME>/j2ee/home/config
<shared-library name="cxf.foundation" version="1.0">
		<code-source path="xml-apis-2.9.0.jar"/>
		<code-source path="xalan-2.7.1.jar"/>
		<code-source path="serializer-2.7.1.jar"/>
		<code-source path="xercesImpl-2.9.0.jar"/>
</shared-library>


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

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:

  1. Copy the jaxws-api-2.1-1.jar file to ${oracle.home}/webservices/lib/jaxws
  2. Copy the geronimo-ws-metadata_2.0_spec-1.1.2.jar file to ${oracle.home}/webservices/lib/jaxws
  3. Unpack the OC4J.jar file
  4. Locate META-INF/boot.xml
  5. 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

Configuring Your Skyway Project

In addition to the two projects that are created when you create a new Skyway Project, you will also need to create an Ear Project and associate it with your -Web Project. To do this,

  1. Create a new Java EE - Enterprise Application Project, (File > New > Other > Java EE > Enterprise Application Project). You will probably want to name this with a -Ear at the end. So for instance if your Skyway Project is named mySkywayProject, you should already have a modeling project named mySkywayProject and another project named mySkywayProject-Web, therefore you would want to name your new Ear Project, mySkywayProject-Ear. During the creation of the Ear project, in the Java EE Module Dependencies of the wizard, you will want to check the -Web Project.
  2. Once you've got the Ear project, you need to create a file inside the Ear Project, in the META-INF directory, named, orion-application.xml with the following content:
<orion-application>
	<imported-shared-libraries>
		<import-shared-library name="cxf.foundation"/>
		<remove-inherited name="org.jgroups"/>
		<remove-inherited name="apache.commons.logging"/>
		<remove-inherited name="oracle.jwsdl"/>
		<remove-inherited name="oracle.ws.core"/>
		<remove-inherited name="oracle.ws.client"/>
		<remove-inherited name="oracle.ws.reliability"/>
		<remove-inherited name="oracle.ws.security"/>
		<remove-inherited name="oracle.xml"/>
		<remove-inherited name="oracle.xml.security"/>
	</imported-shared-libraries> 
</orion-application>

Make sure your Project is using the correct Container Settings. This is configured in the Enterprise Configuration tab of the Modeling Project.
The settings should be:
Container Type: Oracle
Persistence Manager: Container
Transaction Manager: Container

All you should have to do now is deploy and run your project as your normally would.

Personal tools