Sunday July 22, 2007
Rama described how to run JAX-WS samples with Tomcat 6.x. JAX-WS is part of Metro - the Web services stack in GlassFish. Another key component of Metro is WSIT (aka Project Tango) that provides Secure, Reliable, Transactional and Interoperable Web service. Read more about Project Tango in this 26-page article.
A stable version of Metro is integrated in
GlassFish V2 and the
latest nightlies of stand-alone bundle are also available. The stand-alone
bundle comes with an install scipt (wsit-on-tomcat.xml) that allows
it install on Tomcat 5.x. I followed the steps in
Rama's blog to install Metro on Tomcat 6.x. But first, a little bit of
explanation and then the actual code fragments.
Tomcat's classloading mechanism has changed slightly between
5.x
and
6.x. The first change is that Tomcat 5.x used to have shared/lib
directory to share classes across all web applications. This directory in turn
used to be specified as value of shared.loader property in
conf/catalina.properties. In Tomcat 6.x, the property still exists
but it's value is set to nothing and shared/lib directory no longer
exists in the default installation. I see the motivation behind this change as
it keeps the Tomcat installation directory clean and any shared resources can
still be specified in conf/catalina.properties. But this means that
wsit-on-tomcat.xml script, that copies the files in
shared/lib directory, will work on Tomcat 5.x only. In order for this
script to work on Tomcat 6.x, the value of shared.loader property
need to be changed to include Metro jars.
Now, the code fragments! The value of shared.loader property in
Tomcat 5.x is:
shared.loader=${catalina.base}/shared/classes,${catalina.base}/shared/lib/*.jar
And in Tomcat 6.x is the value of this property is:
shared.loader=
If Metro is installed in c:\metro then changing its value to:
shared.loader=file:///c:/metro/lib/*.jar
will enable Tomcat 6.x to host Secure, Reliable, Transactional and .NET 3.0-Interoperable Web services. And this mechanism will work for Tomcat 5.x too, so changing the value of this property in Tomcat 5.x installation to:
shared.loader=${catalina.base}/shared/classes,${catalina.base}/shared/lib/*.jar,file:///c:/metro/lib/*.jar
instead of copying the files in shared/lib will be sufficient as
well.
The second change in Tomcat's classloading mechanism is required if you are
using Java SE 6. Tomcat 5.x used to have common/endorsed directory
which no longer exists in Tomcat 6.x. Java SE 6 is bundled with JAX-WS 2.0 and
Metro needs JAX-WS 2.1. So if you are using Java SE 6 then copy
webservices-api.jar in c:/jdk6/jre/lib/endorsed directory.
Read
Endorsed Directory Mechanism for more details.
Several screencasts are available that show how to develop Secure, Reliable and Transactional and Interoperable Web service. All the screencasts use NetBeans IDE but if you are more of a command-line user then follow this entry that shows how to develop a reliable endpoint and invoke it from WCF and vice versa.
Technorati: metro webservices wsit jax-ws glassfish tomcat
Posted by Arun Gupta in webservices | Comments[17]
|
|
|
|
Today's Page Hits: 5658
But now - I placed the web-services.api in the jkd6\jre\lib\endorsed directory as instructed (had to create the directory - does that seem right?). But now the Tomcat 6 context loader is complaining about jaxb-api.jar being downlevel, and "WSServletException: WSSERVLET11: ... Use the endorsed directory mechanism to place jaxb-api.jar in the bootstrap classloader. (See http://java.sun.com/j2se/1.5.0/docs/guide/standards/)" - though I _am_ using Tomcat 6.0.13 despite the referenced URL.
?
Posted by Jim on August 06, 2007 at 08:28 AM PDT #
Posted by Jim on August 06, 2007 at 08:30 AM PDT #
Posted by Arun Gupta on August 06, 2007 at 09:12 AM PDT #
Posted by Ken Hofsass's Blog on August 22, 2007 at 03:23 PM PDT #
Posted by Ken Hofsass's Blog on August 22, 2007 at 03:35 PM PDT #
I'm having the same problem as Jim. Tomcat 6.0.14, JDK 1.6.0_02. It is a clean install.
The JDK will not see anything in the lib/endorsed, the only way it is recognizing the webservices-api.jar is if i place it with the shared.loader
Posted by Rich on October 17, 2007 at 12:24 PM PDT #
I have it working now. As I said before lib/endorsed does not seem to be wokring, I even tried setting the JAVA_ENDORSED_DIRS env var that catalina.bat uses, and that failed.
I deduced solution from this link
http://mail-archives.apache.org/mod_mbox/portals-pluto-dev/200706.mbox/%3C15994695.1180798155862.JavaMail.jira@brutus%3E
it says the new tomcat endorsed is <tomcat>/endorsed where <tomcat> = $CATALINA_HOME or your base install.
I created the endorsed directory and dropped the webservices-api.jar
Posted by Rich on October 17, 2007 at 01:38 PM PDT #
If you are using Tomcat 6.x, then the stand-alone Metro bundle downloadable from metro.dev.java.net comes with an install script and takes care of this for you. Have you tried that ?
-Arun
Posted by Arun Gupta on October 17, 2007 at 03:01 PM PDT #
yes, I downloaded right from your link the Metro 1.0 FCS and tried the wsit download also because another site said the script had been fixed for tomcat 6. (are you using nightly builds?)
The first thing I did was use the script .... Both of those scripts (ie. from metro and wsit download) place the webservices-api.jar in $java.home/lib/endorsed. That is not working for me, perhaps I'm missing something. I have tried this on windows and unix, both have same java and tomcat versions installed.
Posted by Rich on October 18, 2007 at 08:31 AM PDT #
Rich, can you try the nightly builds ? Sorry, I've been traveling so can't follow up in detail for now. But will look into this after I get back home.
Posted by Arun Gupta on October 18, 2007 at 12:59 PM PDT #
I thought I could just copy JAXWS-RI 2.1 jar files into tomcat-home/endorsed.
This seemed to work but as soon as I deploy a second time (updating) or deploy another JAXWS app I'll constantly get:
java.lang.LinkageError: loader constraints violated when linking javax/xml/soap/SOAPFactory class
at com.sun.xml.ws.binding.BindingImpl.create(BindingImpl.java:137)
The only remedy is to shutdown and startup Tomcat 6.
Perhaps someone has an idea how to resolve this.
Posted by Axel Rose on October 19, 2007 at 07:56 AM PDT #
Arun, I got the metro nightly build. The 1.1x has the correct script and it does exactly what you described, i.e. place webservices-api.jar in the java_home/lib/endorsed, but that does not work for me.
Axel, I'm assuming you followed the steps above, just in case, I did not copy all the jars into tomcat-home/ednorsed just the webservices-api.jar. The rest go wherever you have set the shard.loader= var to.
Have you tried Arun's approach? Also, I'm not deploying with the manager, I just drop my war in the webapps. hope that helps
Posted by Rich on October 19, 2007 at 11:05 AM PDT #
Hi Rich,
no, I tried myself, only using JAXWS-RI-212 as basis.
All packages starting with "javax" went to tomcat-home/endorsed, all others to tomcat-home/webapps/myapp/WEB-INF/lib.
Deploying via filesystem or http doesn't make any different.
If I only I could understand the LinkageError ...
Posted by Axel Rose on October 22, 2007 at 12:26 AM PDT #
Hello,
I am new to webservices. I just installed glassfish and jwsdp2.0. I was able to run all the samples in glassfish directory very easily. Now I want to run the samples in the jwsdp2.0 directory too. I am using JDK 6.0. When I use JDK 5.0 the jaxb samples works fine but not with JDK 6.0. I get this error "C:\Sun\jwsdp-2.0\jaxb\samples\unmarshal-read\build.xml:34: java.lang.IllegalArgu
mentException: Expected class javax.xml.bind.annotation.XmlAccessType but found
class javax.xml.bind.annotation.AccessType"
I saw that the javax.xml.bind.annotation.XmlAccessType is in the webservices-api.jar in the glassfish installation and in jre 6.0. I created the endorsed directory in ${java.home}/jre/lib and copied the webservices-api.jar there. This again gave the same error. I can change the ant script that builds the samples to first pick up from the webservices-api.jar but I was wondering if the endorsed directory way or a cleaner way would work
Posted by Salil Surendran on March 24, 2008 at 01:47 PM PDT #
Hi Salil,
If you are new to Web services then I'll recommend using the Web services stack (Metro) baked into GlassFish instead of using JWSDP 2.0. JWSDP 2.0 is almost 3-years old toolkit and is no longer updated. JDK 6 U4 contains all the JAX-WS & JAXB APIs so there is no need to even set endorsed directories with them. If you really need to use Tomcat, then a a stand-alone bundle of Metro can be downloaded from metro.dev.java.net that comes with an installation script to install on Tomcat.
-Arun
Posted by Arun Gupta on March 24, 2008 at 03:02 PM PDT #
I have downloaded glassfish and I am using that as my app server. As mentioned in my previous post I could easily compile it's samples. I was trying to compile the samples in jwsdp 2.0, since they are more numerous than the ones included in glassfish. So I guess I should copy the samples to the glassfish directory or change the build.xml to point to the webservices-api.jar? Are there any other jars that would need to be included? Should I just include all the jars in the glassfish lib directory.
Posted by Salil Surendran on March 24, 2008 at 07:43 PM PDT #
Salil, Metro 1.1 download bundle (available from metro.dev.java.net) has a pretty comprehensive & updated list of samples. They should work very easily with GlassFish as well. I recommend you to try those samples instead.
-Arun
Posted by Arun Gupta on March 24, 2008 at 08:29 PM PDT #