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[34]
|
|
|
|
|
Today's Page Hits: 2975
Total # blog entries: 1002
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 #
It is hard to tell each comment from another. I think each block of comments should be separated by bigger space or the "Posted by..." should be in any color but gray. Other than that. I think your site is a good site.
Posted by Phoebe on July 23, 2008 at 11:50 AM PDT #
Posted by A Cup of Silverlight, RIA & Interoperability on August 06, 2008 at 06:34 AM 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 laptop batteries on November 26, 2008 at 08:59 PM PST #
I'm trying to use Tomcat 6.0.18 to run the SecureCalculatorApp example in NetBeans 6.5. When I deploy the SecureCalculatorApp into Tomcat, I got an error as below:
...
正在部署...
deploy?config=file:/C:/DOCUME~1/CECILI~1/LOCALS~1/Temp/context43083.xml&path=/SecureCalculatorApp
OK - Deployed application at context path /SecureCalculatorApp
正在启动...
start?path=/SecureCalculatorApp
OK - Started application at context path /SecureCalculatorApp
F:\Program Files\NetBeans 6.5\workspace\SecureCalculator\SecureCalculatorApp\nbproject\wsit-deploy.xml:53: Must set Sun app server root
生成失败(总时间:1 秒)
Do you have any idea to resolve this problem? Thanks.
Posted by cecilia on December 17, 2008 at 01:27 AM PST #
Did you install Metro on Tomcat ? Alternatively, you can use GlassFish as deployment platform and everything is baked in there.
Posted by Arun Gupta on December 17, 2008 at 10:42 PM PST #
Yes, I installed Metro on Tomcat 6.0.18 following this blog. On GlassFish, the sample SecureCalculatorApp works well. However, on Tomcat 6.0, it even cannot be deployed from NetBean 6.5. Our developers prefer Tomcat since we are familiar with Tomcat.
Posted by cecilia on December 17, 2008 at 11:32 PM PST #
Cecilia, please ask your question on nbj2ee@netbeans.org or users@metro.dev.java.net. This sample is also explained in detail at:
http://www.netbeans.org/kb/docs/websvc/wsit.html
Posted by Arun Gupta on December 18, 2008 at 05:07 AM PST #
I tried shared.loader=file:///c:/metro/lib/*.jar
but tomcate gave me
SEVERE: Error configuring application listener of class com.sun.xml.ws.transport.http.servlet.WSServletContextListener
java.lang.ClassNotFoundException: com.sun.xml.ws.transport.http.servlet.WSServletContextListener
shared.loader=c:/metro/lib/*.jar worked for me instead.
Posted by Jan-Rudolph Buhrmann on April 14, 2009 at 06:35 AM PDT #
I have installed Metro 1.4 , NetBeans IDE 6.0.1 and tomcat 6.0.14 on my windows machine and followed the instruction you posted. When I try to configure a web-service properties from the NetBeans by clicking on the menu item, I get the following error:
"WSIT Runtime was not detected on target server of this project: Apache Tomcat 6.0.14. "
Any idea, why I am getting this.
Posted by Andy Basu on April 23, 2009 at 07:58 AM PDT #
Andy,
Please post your questions to users@metro.dev.java.net.
Posted by Arun Gupta on April 23, 2009 at 08:53 AM PDT #
Hello,
Are Transactional Services really possible within Tomcat ? I heard that metro WS-Coordination is based on GlassFish JTA System .
pse clarify,
Thanks, Andre, Berlin
Posted by Andre on May 12, 2009 at 07:58 AM PDT #
Andre, Transactional services will work on GlassFish only.
Posted by Arun Gupta on May 12, 2009 at 08:53 AM PDT #
In tomcat 6.0.18, you have to change shared.loader=file:///c:/metro/lib/*.jar to shared.loader=c:/metro/lib/*.jar Otherwise, the classloader still can't see them
Posted by marshal on May 20, 2009 at 06:14 PM PDT #
Hello Arun, i need some help.
I want to deploy my webapp as a war, but with(inside) all the runtime libraries that metro needs.
The reason is that i dont want install nothing about metro in apache , glasfish, etc.
I want to know if is possible to do it.
Maybe I need to put some filters o listener in my web.xml... something that references the metro *.jars.
Right now i had put all the libraries of metro inside WEB-INF/lib inside my war deployment.
But i have this error:
"runtime modeler error: Wrapper class -wslanzador.ExecutePL- is not found. Have you run APT to generate them"
And it's 'cause i didn't install metro as shared lib in my servlet container.
Other questions..how i can install metro inside weblogic?
Why i should install metro runtime libraries in the servlet container?????I dont wanna to do this.(I think that to do it makes my war no portable )
Please i hope your answer as soon as possible..thank you.
Posted by Luis V on May 26, 2009 at 01:32 AM PDT #
Luis, please post your question to users@metro.dev.java.net for a wider audience.
Posted by Arun Gupta on May 26, 2009 at 10:28 AM PDT #
i did all setting for tomcat and start tomcat
but how can i test that the installintion of metro in tomcat was success
Posted by tarek7elmy on November 03, 2009 at 04:22 AM PST #
tarek7elmy,
Please post your question to users@metro.dev.java.net for a better response time.
-Arun
Posted by Arun Gupta on November 03, 2009 at 09:53 AM PST #