cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache CXF Documentation > Application Server Specific Configuration Guide
Date Fri, 26 Aug 2011 20:55:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/9/1/_/styles/combined.css?spaceKey=CXF20DOC&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/CXF20DOC/Application+Server+Specific+Configuration+Guide">Application
Server Specific Configuration Guide</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~mazzag">Glen
Mazza</a>
    </h4>
        <div id="versionComment">
        <b>Comment:</b>
        Added weblogic blog entry.<br />
    </div>
        <br/>
                         <h4>Changes (1)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >Also note you can, and may need to,
specify other options in the weblogic-application.xml file such as XML processing factories
as shown [here|http://cxf.547215.n5.nabble.com/Getting-error-while-deploying-on-weblogic-9-2-but-able-to-do-in-tomcat-td554060.html#a554061].
See the WebLogic [guide|http://download.oracle.com/docs/cd/E12840_01/wls/docs103/programming/app_xml.html#wp1064995]
for more information.  <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >* Run &quot;jar cvf ...&quot;
command to create the ear and then deploy it. <span class="diff-added-words"style="background-color:
#dfd;"> Alternatively, this [blog entry|http://www.jroller.com/gmazza/entry/deploying_webservices_on_weblogic]
provides a Mavenized method of building the EAR.</span> <br></td></tr>
            <tr><td class="diff-unchanged" > <br>h2. Websphere <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <p>This document provides app server-specific configuration information for
running Apache CXF.</p>
<style type='text/css'>/*<![CDATA[*/
div.rbtoc1314392074233 {margin-left: 1.5em;padding: 0px;}
div.rbtoc1314392074233 ul {list-style: disc;margin-left: 0px;padding-left: 20px;}
div.rbtoc1314392074233 li {margin-left: 0px;padding-left: 0px;}

/*]]>*/</style><div class='rbtoc1314392074233'>
<ul>
    <li><a href='#ApplicationServerSpecificConfigurationGuide-JBoss'>JBoss</a></li>
    <li><a href='#ApplicationServerSpecificConfigurationGuide-WebLogic'>WebLogic</a></li>
<ul>
<ul>
    <li><a href='#ApplicationServerSpecificConfigurationGuide-Putjarsinendorsedfolder'>Put
jars in endorsed folder</a></li>
    <li><a href='#ApplicationServerSpecificConfigurationGuide-Packwarinanear%2Cdeploytheearwithweblogicapplication.xml'>Pack
war in an ear, deploy the ear with weblogic-application.xml</a></li>
</ul>
</ul>
    <li><a href='#ApplicationServerSpecificConfigurationGuide-Websphere'>Websphere</a></li>
<ul>
    <li><a href='#ApplicationServerSpecificConfigurationGuide-NoWebServicesFeaturePackforWebSphereinstalled'>No
Web Services Feature Pack for WebSphere installed</a></li>
<ul>
    <li><a href='#ApplicationServerSpecificConfigurationGuide-putjarintheendorsedfolder'>put
jar in the endorsed folder</a></li>
    <li><a href='#ApplicationServerSpecificConfigurationGuide-Addyourownclassloader'>Add
your own class loader</a></li>
</ul>
    <li><a href='#ApplicationServerSpecificConfigurationGuide-WebServicesFeaturePackforWebSphereInstalled'>Web
Services Feature Pack for WebSphere Installed</a></li>
</ul>
    <li><a href='#ApplicationServerSpecificConfigurationGuide-Glassfish'>Glassfish</a></li>
    <li><a href='#ApplicationServerSpecificConfigurationGuide-OC4J'>OC4J</a></li>
<ul>
    <li><a href='#ApplicationServerSpecificConfigurationGuide-Disclaimer'>Disclaimer</a></li>
    <li><a href='#ApplicationServerSpecificConfigurationGuide-Background'>Background</a></li>
<ul>
    <li><a href='#ApplicationServerSpecificConfigurationGuide-Configurationoverview'>Configuration
overview</a></li>
    <li><a href='#ApplicationServerSpecificConfigurationGuide-OracleOC4Jclassloading'>Oracle
OC4J class loading</a></li>
    <li><a href='#ApplicationServerSpecificConfigurationGuide-Neededcomponents'>Needed
components</a></li>
    <li><a href='#ApplicationServerSpecificConfigurationGuide-Preparingstaxapi'>Preparing
stax-api</a></li>
    <li><a href='#ApplicationServerSpecificConfigurationGuide-ReplacetheOracleXMLparserwithXerces'>Replace
the Oracle XML parser with Xerces</a></li>
    <li><a href='#ApplicationServerSpecificConfigurationGuide-GetridofOC4JJAXWSlibraries'>Get
rid of OC4J JAX-WS libraries</a></li>
    <li><a href='#ApplicationServerSpecificConfigurationGuide-swappingOracle%7B%7Bwsdl.jar%7D%7Dwith%7B%7Bwsdl4j.jar%7D%7Dand%7B%7Bjaxb.jar%7D%7DAPIwith%7B%7Bjaxbapi2.0.jar%7D%7D'>swapping
Oracle <tt>wsdl.jar</tt> with <tt>wsdl4j.jar</tt> and <tt>jaxb.jar</tt>
API with <tt>jaxb-api-2.0.jar</tt></a></li>
    <li><a href='#ApplicationServerSpecificConfigurationGuide-Deployingapplications'>Deploying
applications</a></li>
    <li><a href='#ApplicationServerSpecificConfigurationGuide-OracleFAQ'>Oracle
FAQ</a></li>
<ul>
    <li><a href='#ApplicationServerSpecificConfigurationGuide-I%27mgetting%7B%7Bjava.lang.ClassCastException%3Aorg.apache.xerces.jaxp.DocumentBuilderFactoryImpl%7D%7D'>I'm
getting <tt>java.lang.ClassCastException: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl</tt></a></li>
    <li><a href='#ApplicationServerSpecificConfigurationGuide-IcannotgetWSDL%28gettingHTTP500accesingmyCXFserviceWSDLwith'>I
cannot get WSDL (getting HTTP 500 accesing my CXF service WSDL with http://myshot/myservice?wsdl)</a></li>
    <li><a href='#ApplicationServerSpecificConfigurationGuide-I%27mgetting%7B%7Bjava.lang.NoSuchMethodException%3Aoracle.j2ee.ws.wsdl.extensions.soap.SOAPBodyImpl.getElementType%28%29%7D%7D'>I'm
getting <tt>java.lang.NoSuchMethodException: oracle.j2ee.ws.wsdl.extensions.soap.SOAPBodyImpl.getElementType()</tt></a></li>
    <li><a href='#ApplicationServerSpecificConfigurationGuide-Icannotgetittoworkstill'>I
cannot get it to work still</a></li>
</ul>
</ul>
</ul>
    <li><a href='#ApplicationServerSpecificConfigurationGuide-IntegrationwithApplicationServerFAQ'>Integration
with Application Server FAQ</a></li>
    <li><a href='#ApplicationServerSpecificConfigurationGuide-Resources'>Resources</a></li>
</ul></div>

<h2><a name="ApplicationServerSpecificConfigurationGuide-JBoss"></a>JBoss</h2>

<p>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.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;?xml version=<span class="code-quote">"1.0"</span>
encoding=<span class="code-quote">"UTF-8"</span>?&gt;</span>
<span class="code-tag">&lt;jboss-app&gt;</span>
	<span class="code-tag">&lt;loader-repository&gt;</span>
		apache.cxf:loader=spring_http.ear
		<span class="code-tag">&lt;loader-repository-config&gt;</span>
			java2ParentDelegation=false
		<span class="code-tag">&lt;/loader-repository-config&gt;</span>
	<span class="code-tag">&lt;/loader-repository&gt;</span>
<span class="code-tag">&lt;/jboss-app&gt;</span>
</pre>
</div></div>
<p>If you are coming across LinkageErrors involving the QName class, try repackaging
the stax-api jar without the javax.xml.namespace.QName class.&nbsp; (In JBoss 4.0.5GA
at least) a conflicting version of this class is included in JBoss's lib and lib/endorsed
directories.&nbsp; This was the only way I could get CXF working in my environment.</p>

<h2><a name="ApplicationServerSpecificConfigurationGuide-WebLogic"></a>WebLogic</h2>

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

<h4><a name="ApplicationServerSpecificConfigurationGuide-Putjarsinendorsedfolder"></a>Put
jars in endorsed folder </h4>

<ul>
	<li>Put the geronimo-ws-metadata_2.0_spec-1.1.1.jar in the $Weblogic_Home/jdk_../jre/lib/endorsed
folder.</li>
	<li>Deploy the CXF war in weblogic.<br/>
 (This way is not recommended, since it might break the application server itself.  The method
below is preferred, as it impacts a single module only.)</li>
</ul>


<h4><a name="ApplicationServerSpecificConfigurationGuide-Packwarinanear%2Cdeploytheearwithweblogicapplication.xml"></a>Pack
war in an ear, deploy the ear with weblogic-application.xml</h4>

<ul>
	<li>Create a standard J2EE application.xml file in the META-INF folder. (Take $CXF_HOME/samples/java_first_spring_support
for example)
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;?xml version=<span class="code-quote">"1.0"</span>
encoding=<span class="code-quote">"UTF-8"</span>?&gt;</span>
&lt;!DOCTYPE application PUBLIC
		<span class="code-quote">"-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN"</span>
		<span class="code-quote">"http://java.sun.com/dtd/application_1_3.dtd"</span>&gt;
<span class="code-tag">&lt;application&gt;</span>
	<span class="code-tag">&lt;display-name&gt;</span>spring_http<span
class="code-tag">&lt;/display-name&gt;</span>
	<span class="code-tag">&lt;module&gt;</span>
		<span class="code-tag">&lt;web&gt;</span>
			<span class="code-tag">&lt;web-uri&gt;</span>spring_http.war<span
class="code-tag">&lt;/web-uri&gt;</span>
			<span class="code-tag">&lt;context-root&gt;</span>spring<span class="code-tag">&lt;/context-root&gt;</span>
		<span class="code-tag">&lt;/web&gt;</span>
	<span class="code-tag">&lt;/module&gt;</span>
<span class="code-tag">&lt;/application&gt;</span>
</pre>
</div></div></li>
</ul>


<ul>
	<li>Create a weblogic-application.xml (Weblogic specific) in the META-INF folder.
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;?xml version=<span class="code-quote">"1.0"</span>
encoding=<span class="code-quote">"UTF-8"</span>?&gt;</span>
<span class="code-tag">&lt;weblogic-application xmlns=<span class="code-quote">"http://www.bea.com/ns/weblogic/90"</span>&gt;</span>
	<span class="code-tag">&lt;application-param&gt;</span>
		<span class="code-tag">&lt;param-name&gt;</span>webapp.encoding.default<span
class="code-tag">&lt;/param-name&gt;</span>
		<span class="code-tag">&lt;param-value&gt;</span>UTF-8<span class="code-tag">&lt;/param-value&gt;</span>
	<span class="code-tag">&lt;/application-param&gt;</span>
	<span class="code-tag">&lt;prefer-application-packages&gt;</span>
		<span class="code-tag">&lt;package-name&gt;</span>javax.jws.*<span
class="code-tag">&lt;/package-name&gt;</span>
	<span class="code-tag">&lt;/prefer-application-packages&gt;</span>
<span class="code-tag">&lt;/weblogic-application&gt;</span>
</pre>
</div></div></li>
</ul>


<p>The prefer-application-packages element you see above sets up WebLogic's <a href="http://e-docs.bea.com/wls/docs100/programming/classloading.html#wp1097187"
class="external-link" rel="nofollow">Filtering Classloader</a>.  Each class whose
package matches one of the package-name elements listed will be searched for first within
the EAR before relying on the WebLogic system classloader's version.  If a package for a particular
class is not listed here, WebLogic will try to load its own (possibly older) version first,
so if you are getting deployment errors due to any particular class you might wish to add
its package here.</p>

<p>Also note you can, and may need to, specify other options in the weblogic-application.xml
file such as XML processing factories as shown <a href="http://cxf.547215.n5.nabble.com/Getting-error-while-deploying-on-weblogic-9-2-but-able-to-do-in-tomcat-td554060.html#a554061"
class="external-link" rel="nofollow">here</a>. See the WebLogic <a href="http://download.oracle.com/docs/cd/E12840_01/wls/docs103/programming/app_xml.html#wp1064995"
class="external-link" rel="nofollow">guide</a> for more information. </p>

<ul>
	<li>Run "jar cvf ..." command to create the ear and then deploy it.  Alternatively,
this <a href="http://www.jroller.com/gmazza/entry/deploying_webservices_on_weblogic" class="external-link"
rel="nofollow">blog entry</a> provides a Mavenized method of building the EAR.</li>
</ul>


<h2><a name="ApplicationServerSpecificConfigurationGuide-Websphere"></a>Websphere</h2>

<p>Currently, I've only found one way to make cxf work with websphere: adding jars to
the 'endorsed' folder. (*Note: this has been validated against Websphere6.1.0.0, 6.1.0.19,
and 6.1.0.27 *)</p>

<h3><a name="ApplicationServerSpecificConfigurationGuide-NoWebServicesFeaturePackforWebSphereinstalled"></a>No
Web Services Feature Pack for WebSphere installed</h3>
<h4><a name="ApplicationServerSpecificConfigurationGuide-putjarintheendorsedfolder"></a>put
jar in the endorsed folder</h4>

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


<p>And then restart the Websphere server. (Because we changed the endorsed folder, we
need to restart it to make it take effect).</p>
<div class='panelMacro'><table class='tipMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/check.gif" width="16" height="16"
align="absmiddle" alt="" border="0"></td><td>Please make sure your classpath
doesn't have the servlet-2.5 library, since WebSphere6.1 is servlet-2.4 compliant&#33;</td></tr></table></div>

<h4><a name="ApplicationServerSpecificConfigurationGuide-Addyourownclassloader"></a>Add
your own class loader</h4>

<p>If you put your wsdl4j-1.6.1 jar in $WAS_HOME/java/jre/lib/endorsed, all your applications
will depend on your version of wsdl4j. Another solution is to create a new class loader in
your server which loads before parent class loader, create a shared library with your version
of wsdl4j, and add this shared library to your new class loader. This version of wsdl4j will
only be available for your specific server and not affect applications running in other servers.</p>


<p><b>Step by step</b></p>
<ol>
	<li>In the WAS console navigate to <b>Environment &gt; Shared Libraries</b></li>
	<li>Select the scope you wish your library should be visible in</li>
	<li>Click <b>New</b> and set values ex: <tt>name=MYAPP_SHARED_LIB,
classpath=PATH_TO/wsdl4j-1.6.2.jar</tt> and <b>Save</b></li>
	<li>Navigate to <b>Application servers &gt; [your server name]</b>
<b>&gt; Java and Process Management &gt; Class loader &gt; New</b></li>
	<li>Select <b>Classes loaded with application class loader first</b> and
<b>Save</b></li>
	<li>Select your new class loader and  click <b>Shared library references</b></li>
	<li>Add your shared library (MYAPP_SHARED_LIB) <b>Save</b> and restart
your server.<br class="atl-forced-newline" /></li>
</ol>


<p>Tested in WAS 6.1 only but should work in earlier versions as well.</p>

<p>Another user running WS6.1 FP 23 without the web services feature pack came up with
this solution that seemed to work for them:</p>
<blockquote>
<p>Create a shared library with the following jars: <br/>
jsr173_api-1.0.jar <br/>
jaxp-ri-1.4.2.jar <br/>
saaj-impl-1.3.2.jar <br/>
wsdl4j-1.6.2.jar </p>

<p>Create a new parent-first classloader and have it reference the shared library you
just created. Restart everything and it should work.</p></blockquote>

<h3><a name="ApplicationServerSpecificConfigurationGuide-WebServicesFeaturePackforWebSphereInstalled"></a>Web
Services Feature Pack for WebSphere Installed</h3>
<p>Things are way more complicated if the Web Services Feature Pack for WebSphere is
installed. With this feature pack installed, it is impossible to deploy an application using
CXF, because the WebSphere Web Services engine starts parsing the JAX-WS annotations of the
services and tries to deploy the services.</p>

<p>Up to fixpack 27 (6.1.0.27) there was no possibility to disable the WebSphere Web
Services engine.</p>

<p>In October 2009, IBM reacted to the problem and released the following fix:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
  PK96989: ENABLE USE OF THIRD PARTY JAX-WS WEB SERVICES ENGINE IN WEBSPHERE

This fix requires at least fixpack 27 (6.1.0.27). It allows to disable the WebSphere Web Services
engine <span class="code-keyword">for</span> the whole JVM by setting the JVM
property

  com.ibm.websphere.webservices.DisableIBMJAXWSEngine=<span class="code-keyword">true</span>

or to disable the engine just <span class="code-keyword">for</span> a specific
module by adding

  DisableIBMJAXWSEngine: <span class="code-keyword">true</span>

to WAR/META-INF/MANIFEST.MF.
</pre>
</div></div>

<p>According to IBM, this fix shall be included into fixpack 29.</p>

<p>For details, please see <a href="http://www-01.ibm.com/support/docview.wss?rs=180&amp;uid=swg1PK96989"
class="external-link" rel="nofollow">http://www-01.ibm.com/support/docview.wss?rs=180&amp;amp;uid=swg1PK96989</a></p>

<p>The WebSphere team has also added instructions for using third party JAX-WS applications
to their tech articles:
<a href="http://www.ibm.com/developerworks/websphere/library/techarticles/1001_thaker/1001_thaker.html"
class="external-link" rel="nofollow">http://www.ibm.com/developerworks/websphere/library/techarticles/1001_thaker/1001_thaker.html</a></p>

<h2><a name="ApplicationServerSpecificConfigurationGuide-Glassfish"></a>Glassfish</h2>

<p>CXF Interceptors will not work in Glassfish without this sun-web.xml file to configure
the classloader.  By default, Glassfish will use Metro for JAX-WS services so the classloader
needs to be configured to allow CXF libraries to provide JAX-WS services.   The following
sun-web.xml xml source was added to /WEB-INF to resolve this issue:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;?xml version=<span class="code-quote">"1.0"</span>
encoding=<span class="code-quote">"UTF-8"</span>?&gt;</span> 
&lt;!DOCTYPE sun-web-app PUBLIC '-//Sun Microsystems, Inc.//DTD 
Application Server 9.0 Servlet 2.5//EN' 
'http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd'&gt; 
<span class="code-tag">&lt;sun-web-app&gt;</span> 
<span class="code-tag">&lt;class-loader delegate=<span class="code-quote">"false"</span>/&gt;</span>

<span class="code-tag">&lt;/sun-web-app&gt;</span>
</pre>
</div></div>

<h2><a name="ApplicationServerSpecificConfigurationGuide-OC4J"></a>OC4J</h2>

<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/warning.gif" width="16" height="16"
align="absmiddle" alt="" border="0"></td><td>This guide requires heavy customization
of the OC4J configuration. Bear in mind that some of steps presented below are either undocumented
or unsupported. We strongly advice you to perform those steps in a separate container, dedicated
exclusively for CXF.</td></tr></table></div>

<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/warning.gif" width="16" height="16"
align="absmiddle" alt="" border="0"></td><td>Also see: <a href="http://chadthedeveloper.blogspot.com/2008/06/cxf-vs-oc4j-round-1.html"
class="external-link" rel="nofollow">http://chadthedeveloper.blogspot.com/2008/06/cxf-vs-oc4j-round-1.html</a>
for other suggestions on how to configure OC4J.</td></tr></table></div>

<h3><a name="ApplicationServerSpecificConfigurationGuide-Disclaimer"></a>Disclaimer</h3>

<p>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&#95; is <a href="http://java.sun.com/javaee/overview/compatibility.jsp"
class="external-link" rel="nofollow">fully JEE 5.0 certified stack</a> and comes
with their own JAX-WS implementation.</p>

<h3><a name="ApplicationServerSpecificConfigurationGuide-Background"></a>Background</h3>

<p>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).</p>
<div class='panelMacro'><table class='tipMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/check.gif" width="16" height="16"
align="absmiddle" alt="" border="0"></td><td><a name="ApplicationServerSpecificConfigurationGuide-orajaxws"></a><br/>
OC4J 10.1.3 comes with <a href="http://www.oracle.com/technology/tech/java/oc4j/10131/OracleAS-NF-10131.pdf"
class="external-link" rel="nofollow">preliminary implementation of JAX-WS (JSR-181)</a>
but this implementation is somewhat limited only to top-down scenario, with very limited customization
(lack of JAXB 2.0 etc.).</td></tr></table></div>

<h4><a name="ApplicationServerSpecificConfigurationGuide-Configurationoverview"></a>Configuration
overview</h4>

<p>A few components need to be customized in OC4J to allow CFX integration:</p>
<ul>
	<li><a href="http://xerces.apache.org/xerces2-j/" class="external-link" rel="nofollow">Xerces</a></li>
	<li>JAX-WS 2.0 APIs</li>
	<li><a href="http://sourceforge.net/projects/wsdl4j" class="external-link" rel="nofollow">WSDL4J</a></li>
</ul>


<p>Unfortunately, these components have to be configured in different parts of OC4J.</p>

<h4><a name="ApplicationServerSpecificConfigurationGuide-OracleOC4Jclassloading"></a>Oracle
OC4J class loading</h4>

<p>A key part of successfully integrating CXF into OC4J is to understand how class loaders
work in OC4J. When starting OC4J there are generally three stages where customization could
occur:</p>
<ol>
	<li>Virtual Machine boot</li>
	<li>OC4J boot</li>
	<li>CXF (application) boot</li>
</ol>


<p>Customizing in the last step is <a href="http://download-uk.oracle.com/docs/cd/B25221_03/web.1013/b14433/classload.htm"
class="external-link" rel="nofollow">quite easy to achieve</a> &#45; basically
OC4J has quite powerful class loader and an 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 <tt>$ORACLE_HOME/webservices/lib</tt>).</p>

<h4><a name="ApplicationServerSpecificConfigurationGuide-Neededcomponents"></a>Needed
components</h4>

<p>Before start please download <a href="http://cxf.apache.org/download.html" class="external-link"
rel="nofollow">Apache CXF 2.0.6 or better</a> and <a href="http://archive.apache.org/dist/xml/xerces-j/"
class="external-link" rel="nofollow">Xerces 2.8.1</a></p>

<h4><a name="ApplicationServerSpecificConfigurationGuide-Preparingstaxapi"></a>Preparing
stax-api</h4>

<p>If you use a version of CXF that includes stax-api.jar that in turn include the QName
class, remove <tt>javax.xml.namespace.QName</tt> from the stax-api shipped with
CXF. Oracle apparently has it already in <tt>$ORACLE_HOME/j2ee/home/lib/jax-qname-namespace.jar</tt>.</p>

<p><a name="ApplicationServerSpecificConfigurationGuide-xerces"></a></p>

<h4><a name="ApplicationServerSpecificConfigurationGuide-ReplacetheOracleXMLparserwithXerces"></a>Replace
the Oracle XML parser with Xerces</h4>

<p>The basic idea behind how to do this is described in detail <a href="http://www.oracle.com/technology/tech/java/oc4j/1013/how_to/how-to-swapxmlparser/doc/readme.html"
class="external-link" rel="nofollow">here</a></p>

<p>Create OC4J shared library named <tt>cxf.foundation</tt> and fill it
with:</p>
<ul>
	<li>xercesImpl.jar (from Xerces distribution)</li>
	<li>xml-apis-1.2.02.jar (from CXF-distribution)</li>
	<li>xalan-2.7.0.jar (ditto)</li>
	<li>geronimo-ws-metadata_2.0_spec-1.1.1.jar (ditto)
<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/warning.gif" width="16" height="16"
align="absmiddle" alt="" border="0"></td><td>When building Your application
<b>DO NOT INCLUDE THOSE COMPONENTS</b> again.</td></tr></table></div></li>
</ul>


<h4><a name="ApplicationServerSpecificConfigurationGuide-GetridofOC4JJAXWSlibraries"></a>Get
rid of OC4J JAX-WS libraries</h4>

<p>OC4J has <a href="#ApplicationServerSpecificConfigurationGuide-orajaxws">preliminary
support for JAX-WS</a>, unfortunately this means that during OC4J boot it loads <em>outdated</em>
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 <tt>boot.xml</tt>
file in <tt>$ORACLE_HOME/j2ee/home/oc4j.jar</tt> bootstrap jar. To get rid of
this:</p>
<ul>
	<li>unpack <tt>oc4j.jar</tt> file</li>
	<li>locate <tt>META-INF/boot.xml</tt> file and edit it</li>
	<li>find section</li>
</ul>


<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag"><span class="code-comment">&lt;!-- WS jax-rpc --&gt;</span></span>
        <span class="code-tag">&lt;code-source path=<span class="code-quote">"${oracle.home}/webservices/lib/jaxr-api.jar"</span>/&gt;</span>
        <span class="code-tag">&lt;code-source path=<span class="code-quote">"${oracle.home}/webservices/lib/jaxrpc-api.jar"</span>/&gt;</span>
        <span class="code-tag">&lt;code-source path=<span class="code-quote">"${oracle.home}/webservices/lib/jaxb-api.jar"</span>/&gt;</span>
        <span class="code-tag">&lt;code-source path=<span class="code-quote">"${oracle.home}/webservices/lib/saaj-api.jar"</span>/&gt;</span>
        <span class="code-tag">&lt;code-source path=<span class="code-quote">"${oracle.home}/webservices/lib/jws-api.jar"</span>
if=<span class="code-quote">"java.specification.version == /1\.[5-6]/"</span>/&gt;</span>
</pre>
</div></div>
<p>and comment out line which include <tt>jws-api.jar</tt> entry, like below</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag"><span class="code-comment">&lt;!-- &lt;code-source
path=<span class="code-quote">"${oracle.home}/webservices/lib/jws-api.jar"</span>
if=<span class="code-quote">"java.specification.version == /1\.[5-6]/"</span>/&gt;</span>
--&gt;</span>
</pre>
</div></div>
<ul>
	<li>repackage <tt>oc4j.jar</tt> (don't forget about <tt>MANIFEST.MF</tt>
&#45; use <tt>jar &#45;m META-INF/MANIFEST.MF</tt>)</li>
</ul>


<p><a name="ApplicationServerSpecificConfigurationGuide-wsdl4j"></a></p>

<h4><a name="ApplicationServerSpecificConfigurationGuide-swappingOracle%7B%7Bwsdl.jar%7D%7Dwith%7B%7Bwsdl4j.jar%7D%7Dand%7B%7Bjaxb.jar%7D%7DAPIwith%7B%7Bjaxbapi2.0.jar%7D%7D"></a>swapping
Oracle <tt>wsdl.jar</tt> with <tt>wsdl4j.jar</tt> and <tt>jaxb.jar</tt>
API with <tt>jaxb-api-2.0.jar</tt></h4>

<p>Additionally Oracle provides it's own implementation of WSDL functionality which
conflicts with <tt>wsdl4j.jar</tt>. To get rid of this add <tt>&#45;Xbootclasspath/p:"&lt;path
to wsdlj&gt;/wsdl4j-1.6.1.jar;&lt;path to jaxb2&gt;/jaxb-api-2.0.jar"</tt>
option to JVM parametrs (either in command line running OC4J standalone or in OPMN).</p>

<h4><a name="ApplicationServerSpecificConfigurationGuide-Deployingapplications"></a>Deploying
applications</h4>

<p>When deploying please follow those steps:</p>
<ul>
	<li>Edit deployment plan</li>
	<li>Edit <tt>Configure class loading</tt> in the deployment plan like described
<a href="http://www.oracle.com/technology/tech/java/oc4j/1013/how_to/how-to-swapxmlparser/doc/readme.html"
class="external-link" rel="nofollow">here</a></li>
	<li><b>Uncheck</b> <tt><b>oracle.xml</b></tt> library</li>
	<li><b>Check</b> <tt><b>cxf.foundation</b></tt>
library</li>
	<li><b>Uncheck</b> <tt><b>Search Local Classes First</b></tt></li>
	<li>do not include <tt>xercesImpl</tt>, <tt>xml-apis</tt>,
<tt>xalan</tt> and <tt>geronimo-ws-metadata_2.0_spec-1.1.1.jar</tt>
in <tt>war</tt> &#45; those will be automatically loaded by by OC4J Shared
Libraries class loader.
<div class='panelMacro'><table class='tipMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/check.gif" width="16" height="16"
align="absmiddle" alt="" border="0"></td><td>You can automate above steps by
packaging You <tt>war</tt> into <tt>ear</tt> archive (even though)
if it's only <tt>war</tt> and providing <tt>orion-application.xml</tt>
proprietary descriptor as described <a href="http://download-west.oracle.com/docs/cd/B32110_01/web.1013/b28952/classload.htm#CIHIHDEG"
class="external-link" rel="nofollow">here</a>. You could also provide proprietary
<tt>orion-web.xml</tt> in Your <tt>war</tt> instrumenting <tt>Search
Local Classes First</tt> attribute described above. This step is described <a href="http://www.oracle.com/technology/tech/java/oc4j/htdocs/how-to-servlet-sysclassloader.html"
class="external-link" rel="nofollow">here</a>.</td></tr></table></div></li>
</ul>


<h4><a name="ApplicationServerSpecificConfigurationGuide-OracleFAQ"></a>Oracle
FAQ</h4>


<h5><a name="ApplicationServerSpecificConfigurationGuide-I%27mgetting%7B%7Bjava.lang.ClassCastException%3Aorg.apache.xerces.jaxp.DocumentBuilderFactoryImpl%7D%7D"></a>I'm
getting <tt>java.lang.ClassCastException: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl</tt></h5>

<p>This primarily happens when:</p>
<ul>
	<li>xerces is loaded twice - by shared library class loader and application class loader</li>
	<li>or when there is mismatch between <tt>xerces</tt> and <tt>oracle</tt>
implementation of SAX API</li>
</ul>


<p>Please be sure You properly installed and enabled for Your application <tt>cxf.foundation</tt>
shared library as described <a href="#ApplicationServerSpecificConfigurationGuide-xerces">here</a>.
If Yes please be sure that You didn't include xercesImpl.jar in Your <tt>war</tt>.
If You still have problems please <a href="http://java.sun.com/javase/6/docs/api/javax/xml/parsers/SAXParserFactory.html#newInstance()"
class="external-link" rel="nofollow">see how You can debug JAXP problems</a> &#45;
be sure that <tt>org.apache.xerces.jaxp.DocumentBuilderFactoryImpl</tt> are instantiated
from within <tt>JAXP</tt> and not <tt>oracle.xml.parser.v2.DocumentBuilder</tt>.</p>

<p><a name="ApplicationServerSpecificConfigurationGuide-f2"></a></p>

<h5><a name="ApplicationServerSpecificConfigurationGuide-IcannotgetWSDL%28gettingHTTP500accesingmyCXFserviceWSDLwith"></a>I
cannot get WSDL (getting HTTP 500 accesing my CXF service WSDL with <a href="http://myshot/myservice?wsdl"
class="external-link" rel="nofollow">http://myshot/myservice?wsdl</a>)</h5>

<p>Please be sure that <tt>wsdl4j.jar</tt> is loaded before <tt>wsdl.jar</tt>
as described <a href="#ApplicationServerSpecificConfigurationGuide-wsdl4j">here</a></p>

<h5><a name="ApplicationServerSpecificConfigurationGuide-I%27mgetting%7B%7Bjava.lang.NoSuchMethodException%3Aoracle.j2ee.ws.wsdl.extensions.soap.SOAPBodyImpl.getElementType%28%29%7D%7D"></a>I'm
getting <tt>java.lang.NoSuchMethodException: oracle.j2ee.ws.wsdl.extensions.soap.SOAPBodyImpl.getElementType()</tt></h5>

<p><a href="#ApplicationServerSpecificConfigurationGuide-f2">See this</a></p>

<h5><a name="ApplicationServerSpecificConfigurationGuide-Icannotgetittoworkstill"></a>I
cannot get it to work still</h5>

<p>Try something simple. Download OC4J standalone and bootstrap it from command line
directly: <tt>java [options] &#45;jar oc4j.jar</tt>. Enable <a href="http://java.sun.com/javase/6/docs/api/javax/xml/parsers/SAXParserFactory.html#newInstance()"
class="external-link" rel="nofollow">SAX debugging</a>. Be sure You don't include
douplicated jars in Your application like <tt>xercesImpl, xalan, xml-apis and geronimo-ws-metadata_2.0_spec-1.1.1.jar</tt>.
Review steps above once more. It works <img class="emoticon" src="/confluence/images/icons/emoticons/wink.gif"
height="20" width="20" align="absmiddle" alt="" border="0"/>.</p>

<h2><a name="ApplicationServerSpecificConfigurationGuide-IntegrationwithApplicationServerFAQ"></a>Integration
with Application Server FAQ</h2>

<p>1.<br/>
Q: I have this error: javax.xml.ws.WebServiceException: Cannot create SAAJ factory instance.<br/>
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.</p>

<h2><a name="ApplicationServerSpecificConfigurationGuide-Resources"></a>Resources</h2>

<p><a href="http://download-uk.oracle.com/docs/cd/B25221_03/web.1013/b14433/classload.htm"
class="external-link" rel="nofollow">Utilizing the OC4J Class Loading Framework</a><br/>
<a href="http://xfire.codehaus.org/XFire+on+WebLogic+9.2" class="external-link" rel="nofollow">Deploy
XFire in WebLogic</a><br/>
<a href="http://edocs.bea.com/wls/docs92/programming/classloading.html" class="external-link"
rel="nofollow">Understanding WebLogic ClassLoader</a><br/>
<a href="http://www.jboss.org/wiki/Wiki.jsp?page=ClassLoadingConfiguration" class="external-link"
rel="nofollow">JBoss Class Configuration</a><br/>
<a href="http://java.sun.com/javase/6/docs/api/javax/xml/parsers/SAXParserFactory.html#newInstance()"
class="external-link" rel="nofollow">Troubleshooting SAX</a></p>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/CXF20DOC/Application+Server+Specific+Configuration+Guide">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=68526&revisedVersion=44&originalVersion=43">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CXF20DOC/Application+Server+Specific+Configuration+Guide?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message