The Source for Java Technology Collaboration
User: Password:



Bhakti Mehta's Blog

January 2007 Archives


Update to Developing Webservices using Glassfish AS 9.1 and JDK 6

Posted by bhaktimehta on January 24, 2007 at 12:10 PM | Permalink | Comments (1)

In the previous  blog  we tried running glassfish-samples using 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 bug is now fixed since 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 http://download.java.net/jdk6/binaries/

Install  GlassFish v2

You can install  the latest nightly or the latest promoted v2 build from https://glassfish.dev.java.net/public/downloadsindex.html
Follow these 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 https://glassfish-samples.dev.java.net/

  1. Run :
     java -jar javaee5-samples-installer-1.0-b09.jar
  2. Edit : <location of samples>/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.

Developing Webservices using Glassfish AS 9.1 and JDK 6

Posted by bhaktimehta on January 02, 2007 at 11:08 AM | Permalink | Comments (2)

Developing Webservices using Glassfish AS 9.1 and JDK 6

This blog will show how to develop, run and deploy JAX-WS  based webservices with Glassfish v2 Milestone 3 build using JDK 6.
It will demonstrate step by step instructions using the hello-jaxws sample from the following glassfish-samples.

What is different when trying with JDK 6?

JDK 6.0 has  JAXB/JAX-WS 2.0 versions of the apis.
In the latest Glassfish v2 we are integrating the implementation classes compliant with JAXB/JAX-WS 2.1 versions
of the apis which are present in  javaee.jar .

So when we run with Glassfish and JDK 6.0 (without putting anything in the <AS HOME>/lib/endorsed directory),
the APIs/Annotation classes for JAX-WS 2.0 and JAXB 2.0 will be picked up instead of JAX-WS 2.1 and JAXB 2.1.

To avoid this we need to use the endorsed standards to override the 2.0 apis by putting javaee.jar in $AS_HOME/lib/endorsed.
This is a temporary workaround for now and this issue will be fixed soon.

Steps to run the sample with JDK 6

Install JDK 6 from http://download.java.net/jdk6/binaries/

Install  GlassFish v2 Milestone 3

Install  from https://glassfish.dev.java.net/public/downloadsindex.html
Follow these 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 https://glassfish-samples.dev.java.net/

  1. Run :
     java -jar javaee5-samples-installer-1.0-b08.jar
  2. Edit : <location of samples>/bp-project/build.properties to point to $AS_HOME for e.g
     javaee.home="location of Glassfish"
  3. 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)

Add javaee.jar to $AS_HOME/lib/endorsed

As mentioned earlier this extra step will be required for running with JDK 6.0

  1. mkdir -p $AS_HOME/lib/endorsed
  2. mv $AS_HOME/lib/javaee.jar $AS_HOME/lib/endorsed
Start Appserver
/usr/glassfish/bin %$AS_HOME/bin/asadmin* start-domain domain1


Run the Sample
  1. Modify <location  of samples>/javaee5/webservices/hello-jaxws/build.xml to point to
    $AS_HOME/lib/endorsed/javaee.jar in classpath. Currently the samples point to j2ee.jar in the build.xml
  2. Replace references of j2ee.jar with location of javaee.jar
    <path id="classpath">
        <pathelement location="${javaee.home}/lib/endorsed/javaee.jar"/>
        <pathelement location="${classesdir}"/>
    </path>

    and
    <target name="compile-deploy-service" depends="init">
    <mkdir dir="${classesdir}"/>
    <echo message="${javaee.home}"/>
    <javac
    srcdir="./src"
    includes="endpoint/**"
    destdir="${autodeploydir}"
    classpath="${javaee.home}/lib/endorsed/javaee.jar"
    />
    ...
    </target>


  3. Run:
    /usr/glassfish-samples/javaee5/webservices/hello-jaxws %ant

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














Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds