Developing Webservices using Glassfish AS 9.1 and JDK 6
Posted by bhaktimehta on January 02, 2007 at 11:08 AM | 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 :
- Check the following file where AS_HOME is the location where
Glassfish is installed
<$AS_HOME>/config/asenv.conf for AS_JAVA
- 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/
- Run :
java -jar javaee5-samples-installer-1.0-b08.jar
- Edit : <location of samples>/bp-project/build.properties
to point to $AS_HOME for e.g
javaee.home="location of Glassfish"
- 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
-
mkdir -p $AS_HOME/lib/endorsed
-
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
- 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
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>
- 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
Bookmark blog post: del.icio.us Digg DZone Furl Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment
-
Thanks Bhakti, this is useful.
Do you also have a link for JAX-WS 2.0 vs 2.1?
What are the risks of relying on 2.1 and getting a 2.0 runtime?
Posted by: alexismp on January 02, 2007 at 01:10 PM
-
Thanks Alexismp for your feedback
Here is the changelog from JAX-WS 2.0 to 2.1
http://jcp.org/aboutJava/communityprocess/maintenance/jsr224/224changes.pdf
With the steps using endorsed standards you should not run into problems with 2.0 runtime
Please let me know if you run into issues
Posted by: bhaktimehta on January 03, 2007 at 01:42 PM
|