Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting JAX-WS client work on Weblogic 9.2 with ant
    primarykey
    data
    text
    <p>I've recently had lots of issues trying to deploy a JAX-WS web servcie client on Weblogic 9.2. It turns out there is no straightforward guide on how to achieve this, so I decided to put together this short wiki entry hoping it might be useful for others.</p> <p>Firstly, Weblogic 9.2 does not support web servcies using JAX-WS in general. It comes with old versions of XML-related java libraries that are incompatible with the latest JAX-WS (similar issues occur with Axis2, only Axis1 seems to be working flawlessly with Weblogic 9.x but that's a very old and unsupported library).</p> <p>So, in order to get it working, some hacking is required. This is how I did it (note that we're using ant in our legacy corporate project, you probably should be using maven which should eliminate 50% of those steps below):</p> <p>1.Download the most recent JAX-WS distribution from <a href="https://jax-ws.dev.java.net/" rel="nofollow noreferrer">https://jax-ws.dev.java.net/</a> (The exact version I got was JAXWS2.2-20091203.zip)</p> <p>2.Place the JAX-WS jars with the dependencies in a separate folder like <em>lib/webservices</em>.</p> <p>3.Create a patternset in ant to reference those jars:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;patternset id="jaxws.classpath"&gt; &lt;include name="webservices/jsr173_api.jar" /&gt; &lt;include name="webservices/jsr181-api.jar" /&gt; &lt;include name="webservices/jaxb-api.jar" /&gt; &lt;include name="webservices/jaxb-impl.jar" /&gt; &lt;include name="webservices/jaxb-xjc.jar" /&gt; &lt;include name="webservices/jaxws-tools.jar" /&gt; &lt;include name="webservices/jaxws-rt.jar" /&gt; &lt;include name="webservices/jaxws-api.jar" /&gt; &lt;include name="webservices/policy.jar" /&gt; &lt;include name="webservices/woodstox.jar" /&gt; &lt;include name="webservices/streambuffer.jar" /&gt; &lt;include name="webservices/stax-ex.jar" /&gt; &lt;include name="webservices/saaj-api.jar" /&gt; &lt;include name="webservices/saaj-impl.jar" /&gt; &lt;include name="webservices/gmbal-api-only.jar" /&gt; &lt;/patternset&gt; </code></pre> <p>4.Include the patternset in your WAR-related goal. This could look something like:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;copy todir="${wardir.lib}" includeEmptyDirs="false" flatten="true"&gt; &lt;fileset dir="${libs}"&gt; &lt;!--lots of libs here, related to your project --&gt; &lt;patternset refid="jaxws.classpath"/&gt; &lt;/fileset&gt; &lt;/copy&gt; </code></pre> <p>(not the <em>flatten="true"</em> parameter - it's important as Weblogic 9.x is by default not smart enough to access jars located in a different lcoation than WEB-INF/lib inside your WAR file)</p> <p>5.In case of clashes, Weblogic uses its own jars by default. We want it to use the JAX-WS jars from our application instead. This is achieved by preparing a <em>weblogic-application.xml</em> file and placing it in META-INF folder of the deplotyed EAR file. It should look like this:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;weblogic-application xmlns="http://www.bea.com/ns/weblogic/90" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt; &lt;prefer-application-packages&gt; &lt;package-name&gt;javax.jws.*&lt;/package-name&gt; &lt;package-name&gt;javax.xml.bind.*&lt;/package-name&gt; &lt;package-name&gt;javax.xml.crypto.*&lt;/package-name&gt; &lt;package-name&gt;javax.xml.registry.*&lt;/package-name&gt; &lt;package-name&gt;javax.xml.rpc.*&lt;/package-name&gt; &lt;package-name&gt;javax.xml.soap.*&lt;/package-name&gt; &lt;package-name&gt;javax.xml.stream.*&lt;/package-name&gt; &lt;package-name&gt;javax.xml.ws.*&lt;/package-name&gt; &lt;package-name&gt;com.sun.xml.api.streaming.*&lt;/package-name&gt; &lt;/prefer-application-packages&gt; &lt;/weblogic-application&gt; </code></pre> <p>6.Remember to place that <em>weblogic-application.xml</em> file in your EAR! The ant goal for that may look similar to:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;target name="build-ear" depends="war, manifest"&gt; &lt;delete dir="${dist}"/&gt; &lt;mkdir dir="${dist}"/&gt; &lt;jar destfile="${warfile}" basedir="${wardir}"/&gt; &lt;ear destfile="${earfile}" appxml="resources/${app.name}/application.xml"&gt; &lt;fileset dir="${dist}" includes="${app.name}.war"/&gt; &lt;metainf dir="resources/META-INF"/&gt; &lt;/ear&gt; &lt;/target&gt; </code></pre> <p>7.Also you need to tell weblogic to prefer your WEB-INF classes to those in distribution. You do that by placing the following lines in your <em>WEB-INF/weblogic.xml</em> file:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;container-descriptor&gt; &lt;prefer-web-inf-classes&gt;true&lt;/prefer-web-inf-classes&gt; &lt;/container-descriptor&gt; </code></pre> <p>8.And that's it for the weblogic-related configuration. Now only set up your JAX-WS goal. The one below is going to simply generate the web service stubs and classes based on a locally deployed WSDL file and place them in a folder in your app:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;target name="generate-jaxws-client"&gt; &lt;taskdef name="wsimport" classname="com.sun.tools.ws.ant.WsImport"&gt; &lt;classpath path="classpath.main"/&gt; &lt;/taskdef&gt; &lt;wsimport destdir="${src}" package="acme.somewhere.in.your.package.tree.webservices." keep="true" wsdl="http://localhost:8088/mockWebService?WSDL"&gt; &lt;/wsimport&gt; &lt;/target&gt; </code></pre> <p>Remember about the keep="true" parameter. Without it, wsimport generates the classes and... deletes them, believe it or not!</p> <p>For mocking a web service I suggest using SOAPUI, an open source project. Very easy to deploy, crucial for web servcies intergation testing.</p> <p>9.We're almost there. The final thing is to write a Java class for testing the web service, try to run it as a standalone app first (or as part of your unit tests)</p> <p>10.And then try to run the same code from withing Weblogic. It should work. It worked for me. After some 3 days of frustration. And yes, I know I should've put 9 and 10 under a single bullet-point, but the title "10 steps to deploy a JAX-WS web service under Web logic 9.2 using ant" sounds just so much better.</p> <p>Please, edit this post and improve it if you find something missing!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload