Getting JAX-WS client work on Weblogic 9.2 with ant

Posted by michuk on Stack Overflow See other posts from Stack Overflow or by michuk
Published on 2010-05-21T10:56:23Z Indexed on 2010/05/21 11:00 UTC
Read the original article Hit count: 826

Filed under:
|
|
|
|

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.

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

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

  1. Download the most recent JAX-WS distribution from https://jax-ws.dev.java.net/ (The exact version I got was JAXWS2.2-20091203.zip)

  2. Place the JAX-WS jars with the dependencies in a separate folder like lib/webservices.

  3. Create a patternset in ant to reference those jars:







  4. Include the patternset in your WAR-related goal. This could look something like:

(not the flatten="true" 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)

  1. 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 weblogic-application.xml file and placing it in META-INF folder of the deplotyed EAR file. It should look like this:

    javax.jws. javax.xml.bind. javax.xml.crypto. javax.xml.registry. javax.xml.rpc. javax.xml.soap. javax.xml.stream. javax.xml.ws. com.sun.xml.api.streaming.*

  2. Remember to place that weblogic-application.xml file in your EAR! The ant goal for that may look similar to:

    <jar destfile="${warfile}" basedir="${wardir}"/>
    
    
    <ear destfile="${earfile}" appxml="resources/${app.name}/application.xml">
        <fileset dir="${dist}" includes="${app.name}.war"/>
        <metainf dir="resources/META-INF"/>     
    </ear>
    

  3. 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 WEB-INF/weblogic.xml file:

    true

  4. 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:


Remember about the keep="true" parameter. Without it, wsimport generates the classes and... deletes them, believe it or not!

For mocking a web service I suggest using SOAPUI, an open source project. Very easy to deploy, crucial for web servcies intergation testing.

  1. 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)

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

Please, edit this post and improve it if you find something missing!

© Stack Overflow or respective owner

Related posts about weblogic9.x

Related posts about web-services