Skip to main content

Update to Developing Webservices using Glassfish AS 9.1 and JDK 6

Posted by bhaktimehta on January 24, 2007 at 12:10 PM PST

In the previous  href="">blog 
we tried running glassfish-samples using href="">Glassfish
v2  using
JDK 6.

We walked through what was different when trying with JDK 6 and I
mentioned to use a temporary

work-around of putting javaee.jar in $AS_HOME/lib/endorsed..

However this href="">bug
is now fixed since href="">Glassfish
v2 b31 .

The latest Glassfish v2 installs webservices-api.jar in
$AS_HOME/lib/endorsed. and hence we do not need to put javaee.jar there.

So here is the updated blog.

Steps to run the sample with

Install JDK 6 from href=""
style="font-weight: bold;">

Install  GlassFish

You can install  the latest nightly or the latest promoted v2
build from href="">

Follow these href="">instructions
to unbundle and configure glassfish .

Check the version of JDK used by
Glassfish to be JDK 6.0

For those users who have
already installed GlassFish and wish to change the JDK version. That's
equally simple. The JDK path is
stored in one location :

  1. Check the following file where AS_HOME is the location where
    Glassfish is installed
    <$AS_HOME>/config/asenv.conf for AS_JAVA
  2. Modify  $AS_JAVA to point to JDK 6 if that is not
    already set
    AS_JAVA="location of JDK 6"

Download the  glassfish-samples
from the following site
style="font-weight: bold;">

  1. Run :
    java -jar javaee5-samples-installer-1.0-b09.jar
  2. Edit : /bp-project/
    to point to $AS_HOME for e.g
      javaee.home="location of Glassfish"
  1. Check the java version on the client side
      /usr/glassfish-samples/javaee5/webservices %java -version
      java version "1.6.0-rc"
      Java(TM) SE Runtime Environment (build 1.6.0-rc-b104)
      Java HotSpot(TM) Client VM (build 1.6.0-rc-b104, mixed mode, sharing)


/usr/glassfish/bin %$AS_HOME/bin/asadmin* start-domain domain1

Run the Sample

  1. /usr/glassfish-samples/javaee5/webservices/hello-jaxws %ant
  2. This is how the output looks like on the client side

/usr/glassfish-samples/javaee5/webservices/hello-jaxws %ant

Buildfile: build.xml



     [echo] /usr/glassfish


     [exec] parsing WSDL...

     [exec] generating code...




    [javac] Compiling 1 source file to /usr/glassfish-samples/javaee5/webservices



     [exec] Hello result = Hello Administrator!





Total time: 13 seconds

Please note:

As seen in the following sample.

Clients should set the fololowing property to run with JDK 6

 <sysproperty key="java.endorsed.dirs" value="${javaee.home}/lib/endorsed"/>

Also for ant tasks like wsimport,xjc :

The solution is to copy $AS_HOME/lib/endorsed/webservices-api.jar
to $JAVA_HOME/jre/lib/endorsed.

Neither jvmargs nor sysproperty will work in this case
because by the time ant loads this class it would have already loaded the 2.0 classes
and we did not get the chance to override the 2.0 classes with 2.1 classes.

Related Topics >>