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 Tue, 26 Feb 2013 23:04:07 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/~asoldano">Alessio
Soldano</a>
    </h4>
        <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" > <br>In particular, when willing
to run Apache CXF based applications on top of JBoss AS 7 series, users have basically two
options: <br></td></tr>
            <tr><td class="diff-changed-lines" >* use JBoss AS as if it was a
servlet container with no WS functionalities: this basically implies disabling the webservices
subsystem for the user deployment, hence preventing the AS webservices stack from processing
the ws endpoint deployment and letting the CXF libs included in the archive deal with any
WS invocations when CXFServlet is hit; the webservices subsystem is turned off by adding a
<span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">jboss-deployment-descriptor.xml</span>
<span class="diff-added-words"style="background-color: #dfd;">jboss-deployment-structure.xml</span>
as follows to the ws endpoint deployment: <br></td></tr>
            <tr><td class="diff-unchanged" >{code:xml} <br>&lt;jboss-deployment-structure
xmlns=&quot;urn:jboss:deployment-structure:1.2&quot;&gt; <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.rbtoc1361919802732 {margin-left: 1.5em;padding: 0px;}
div.rbtoc1361919802732 ul {list-style: disc;margin-left: 0px;padding-left: 20px;}
div.rbtoc1361919802732 li {margin-left: 0px;padding-left: 0px;}

/*]]>*/</style><div class='rbtoc1361919802732'>
<ul>
    <li><a href='#ApplicationServerSpecificConfigurationGuide-JBossApplicationServer'>JBoss
Application Server</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-ForWebSphereVersions%3C6.1.0.29'>For
WebSphere Versions &lt; 6.1.0.29</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-ForWebSphere6.1.0.29%2CV7andV8'>For
WebSphere 6.1.0.29+, V7 and V8</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-JBossApplicationServer"></a>JBoss
Application Server</h2>

<p>JBoss Application Server (JBoss AS) comes with its own webservices stack (JBossWS)
in order for providing full JavaEE support.<br/>
Starting from JBoss AS 6 M4, the default webservices stack is internally based on Apache CXF;
as a consequence users might experiment classloading issues with classes from both the CXF
libraries and its dependencies if included in deployments and not properly isolated. Please
refer to the relevant JBoss AS documentation for details on how to turn on classloading isolation
on the application server version in use.</p>

<p>In particular, when willing to run Apache CXF based applications on top of JBoss
AS 7 series, users have basically two options:</p>
<ul>
	<li>use JBoss AS as if it was a servlet container with no WS functionalities: this
basically implies disabling the webservices subsystem for the user deployment, hence preventing
the AS webservices stack from processing the ws endpoint deployment and letting the CXF libs
included in the archive deal with any WS invocations when CXFServlet is hit; the webservices
subsystem is turned off by adding a jboss-deployment-structure.xml as follows to the ws endpoint
deployment:
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;jboss-deployment-structure xmlns=<span class="code-quote">"urn:jboss:deployment-structure:1.2"</span>&gt;</span>
    <span class="code-tag">&lt;deployment&gt;</span>
        <span class="code-tag">&lt;exclude-subsystems&gt;</span>
            <span class="code-tag">&lt;subsystem name=<span class="code-quote">"webservices"</span>
/&gt;</span>
        <span class="code-tag">&lt;/exclude-subsystems&gt;</span>
    <span class="code-tag">&lt;/deployment&gt;</span>
<span class="code-tag">&lt;/jboss-deployment-structure&gt;</span>
</pre>
</div></div>
<p>this approach offers the fastest route to deploying CXF apps on JBoss AS; the drawback
is that no special ws integration with JBoss AS internals is available</p></li>
</ul>


<ul>
	<li>rely on JBossWS integration and the Apache CXF libraries included in the application
server (<a href="https://docs.jboss.org/author/display/AS71/Webservices+reference+guide"
class="external-link" rel="nofollow">documentation</a>): this implies removing any
Apache CXF libs from the ws deployment as well as any other dependencies which is already
included in JBoss AS (including any Java EE API jar); if included, the optional web.xml descriptor
is to be rewritten according to JBossWS convention (see <a href="https://docs.jboss.org/author/display/AS71/JAX-WS+User+Guide"
class="external-link" rel="nofollow">documentation</a>); the Spring support is optional
in JBoss AS and Spring based endpoint declaration is not the default/preferred configuration
approach for ws endpoints, hence users willing to declare endpoints using Spring needs to
create a org.springframework.spring module and put their endpoint declarations in a jbossws-cxf.xml
descriptor; if the user application makes use of any lib besides tha JavaEE api, proper module
<a href="https://docs.jboss.org/author/display/AS71/Class+Loading+in+AS7" class="external-link"
rel="nofollow">dependencies</a> are to be declared either using the jboss-deployment-structure.xml
descriptor or the archive MANIFEST.MF (few directions on ws modules available <a href="https://docs.jboss.org/author/display/AS71/JBoss+Modules+and+WS+applications"
class="external-link" rel="nofollow">here</a>)</li>
</ul>


<p>The second approach allows leveraging the full JavaEE 6 stack (including e.g. JSR-109)
as well as specific ws integration with JBoss AS internals.</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>

<h3><a name="ApplicationServerSpecificConfigurationGuide-ForWebSphereVersions%3C6.1.0.29"></a>For
WebSphere Versions &lt; 6.1.0.29</h3>

<p>Adding jars to the 'endorsed' folder appears to be the main solution:</p>

<h4><a name="ApplicationServerSpecificConfigurationGuide-NoWebServicesFeaturePackforWebSphereinstalled"></a>No
Web Services Feature Pack for WebSphere installed</h4>


<h5><a name="ApplicationServerSpecificConfigurationGuide-putjarintheendorsedfolder"></a>put
jar in the endorsed folder</h5>

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

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

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

<h4><a name="ApplicationServerSpecificConfigurationGuide-WebServicesFeaturePackforWebSphereInstalled"></a>Web
Services Feature Pack for WebSphere Installed</h4>

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

<h3><a name="ApplicationServerSpecificConfigurationGuide-ForWebSphere6.1.0.29%2CV7andV8"></a>For
WebSphere 6.1.0.29+, V7 and V8</h3>

<p>Follow the PDF download given within this IBM developerWorks article:<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>

<p>As described in the PDF, you'll need to change the Classloader order to "Classes
loaded with local class loader first (parent last)" and to disable the IBM web services engine,
either for the JVM as a whole or for the particular module.</p>

<p>To disable for the whole JVM, set the JVM property</p>

<p>com.ibm.websphere.webservices.DisableIBMJAXWSEngine=true</p>

<p>or to disable the engine just for a specific module by adding</p>

<p>DisableIBMJAXWSEngine: true</p>

<p>to WAR/META-INF/MANIFEST.MF.</p>


<p>Another issue that comes up with certain versions of WebSphere is an incompatibility
with the SAAJ implementation.   It is recommended to use the org.apache.servicemix.bundles.saaj-impl-1.3.18_1.jar
saaj impl available from <a href="http://repo1.maven.org/maven2/org/apache/servicemix/bundles/org.apache.servicemix.bundles.saaj-impl/1.3.18_1/"
class="external-link" rel="nofollow">http://repo1.maven.org/maven2/org/apache/servicemix/bundles/org.apache.servicemix.bundles.saaj-impl/1.3.18_1/</a>
as that contains a recent version of SAAJ along with it's required DOM implementation which
will work on the IBM JDK.</p>

<p>One user has reported that he was able to get CXF working on WebSphere with a minimal
set of CXF jars by following the above<br/>
procedures and using the list of jars:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
FastInfoset-1.2.9.jar
aopalliance-1.0.jar
commons-logging-1.1.1.jar
cxf-2.5.2.jar
geronimo-activation_1.1_spec-1.1.jar
geronimo-annotation_1.0_spec-1.1.1.jar
geronimo-javamail_1.4_spec-1.7.1.jar
geronimo-jaxws_2.2_spec-1.1.jar
geronimo-stax-api_1.0_spec-1.0.1.jar
geronimo-ws-metadata_2.0_spec-1.1.3.jar
jars_in_war.txt
jaxb-api-2.2.3.jar
jaxb-impl-2.2.4-1.jar
neethi-3.0.1.jar
org.apache.servicemix.bundles.saaj-impl-1.3.18_1.jar
spring-aop-3.0.6.RELEASE.jar
spring-asm-3.0.6.RELEASE.jar
spring-beans-3.0.6.RELEASE.jar
spring-context-3.0.6.RELEASE.jar
spring-core-3.0.6.RELEASE.jar
spring-expression-3.0.6.RELEASE.jar
spring-web-3.0.6.RELEASE.jar
stax2-api-3.1.1.jar
woodstox-core-asl-4.1.1.jar
wsdl4j-1.6.2.jar
xmlschema-core-2.0.1.jar
</pre>
</div></div>

<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=48&originalVersion=47">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