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="http://weblogs.java.net/blog/bhaktimehta/archive/2007/01/developing_webs.html">blog 
we tried running glassfish-samples using href="https://glassfish.dev.java.net/public/downloadsindex.html">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="https://glassfish.dev.java.net/issues/show_bug.cgi?id=1290">bug
is now fixed since href="https://glassfish.dev.java.net/public/downloadsindex.html">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
JDK 6



Install JDK 6 from href="http://download.java.net/jdk6/binaries/"
style="font-weight: bold;">http://download.java.net/jdk6/binaries/


Install  GlassFish
v2


You can install  the latest nightly or the latest promoted v2
build from href="https://glassfish.dev.java.net/public/downloadsindex.html">
https://glassfish.dev.java.net/public/downloadsindex.html

Follow these href="https://glassfish.dev.java.net/downloads/v2-b28.html">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
href="https://glassfish-samples.dev.java.net/"
style="font-weight: bold;">https://glassfish-samples.dev.java.net/


  1. Run :
    java -jar javaee5-samples-installer-1.0-b09.jar
  2. Edit : /bp-project/build.properties
    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)



Start
Appserver


/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


init:


compile-deploy-service:

     [echo] /usr/glassfish


get-artifacts-unix:

     [exec] parsing WSDL...




     [exec] generating code...


get-artifacts-windows:


get-artifacts:


compile-client:

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

hello-jaxws/build


run-client-unix:

     [exec] Hello result = Hello Administrator!


run-client-windows:


run-client:


all:


BUILD SUCCESSFUL

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