Skip to main content

Latest JAX-WS with Glassfish

Posted by spericas on March 17, 2006 at 10:13 AM PST

So you just picked up the latest release of JAX-WS from and want to try it out with Glassfish. First, you need to override the version that is bundled with Glassfish, but how do you do that and be certain that you did correctly? There's more than one solution to this problem, but there's one clear winner when you're just interested in a quick test: include the latest JAX-WS runtime in your WAR file!

For that you need to pick up a recent Glassfish build, in particular a build that includes a fix for issue 247. A WAR file can include a lib directory, and if you're using Ant to create your WAR file, you just need a war task as shown below:

<war warfile="${build.home}/war/${}-cvs.war" webxml="${basedir}/etc/web.xml">
  <webinf dir="${basedir}/etc" includes="sun-web.xml sun-jaxws.xml"/>
  <zipfileset dir="${basedir}/etc" includes="*.wsdl, *.xsd" prefix="/WEB-INF/wsdl"/>
  <classes dir="${build.home}/classes/cvs/server" includes="**/*.class/"/>

  <!-- Include latest jars in lib directory -->
  <lib dir="${jaxws.home}/lib" includes="*.jar"/>

Additionally, in order for Glassfish to load the jars in your lib directory, you need to turn off class loading delegation. You can do that using a sun-web.xml configuration file which must be part of your WAR file (see Ant code above).

  <class-loader delegate="false"/>    <!-- Use lib dir in war file -->

That's it! An alternative to bundling jars in a WAR file's lib directory is to modify domain.xml and server.policy in your Glassfish domain configuration directory. However, this is error prone, especially when dozens of jar files need to be added as part of the classpath-prefix attribute in domain.xml. Of course, bundling lots of jar files in your WAR files has it disadvantages too (notably footprint) but it works really nicely for testing purposes.

Hope you find this tip useful.

Related Topics >>