X

Metro on Tomcat 6.x

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

Join the discussion

Comments ( 37 )
  • Jim Monday, August 6, 2007
    The link labeled "Endorsed Directory Mechanism" above is now http://java.sun.com/javase/6/docs/technotes/guides/standards/index.html



    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.

    ?
  • Jim Monday, August 6, 2007
    Sorry - the point of the above comment was that placing the jaxb-api.jar into the same endorsed directory (as the web-services.api) seems to have no effect.
  • Arun Gupta Monday, August 6, 2007
    Are you using a clean Java SE 6 installation ? JAXB APIs are already bundled in webservices-api.jar. Is there an additional jaxb-api.jar in your JDK installation ?
  • Ken Hofsass's Blog Wednesday, August 22, 2007
    [Trackback] Previously WSIT didn't support installing to Tomcat 6. However, the WSIT install script for Tomcat has now been updated and will handle both Tomcat 5.5 and Tomcat 6.
  • Ken Hofsass's Blog Wednesday, August 22, 2007
    [Trackback] Previously WSIT didn't support installing to Tomcat 6. However, the WSIT install script for Tomcat has now been updated and will handle both Tomcat 5.5 and Tomcat 6.
  • Rich Wednesday, October 17, 2007

    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


  • Rich Wednesday, October 17, 2007

    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


  • Arun Gupta Wednesday, October 17, 2007

    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


  • Rich Thursday, October 18, 2007

    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.


  • Arun Gupta Thursday, October 18, 2007

    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.


  • Axel Rose Friday, October 19, 2007

    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.


  • Rich Friday, October 19, 2007

    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


  • Axel Rose Monday, October 22, 2007

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


  • Salil Surendran Monday, March 24, 2008

    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


  • Arun Gupta Monday, March 24, 2008

    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


  • Salil Surendran Monday, March 24, 2008

    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.


  • Arun Gupta Monday, March 24, 2008

    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


  • Phoebe Wednesday, July 23, 2008

    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.


  • A Cup of Silverlight, RIA &amp; Interoperability Wednesday, August 6, 2008
    [Trackback] The How-To series demo Silverlight accessing Web Services in various configuration. In this post, we
  • laptop batteries Wednesday, November 26, 2008

    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.


  • cecilia Wednesday, December 17, 2008

    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.


  • Arun Gupta Wednesday, December 17, 2008

    Did you install Metro on Tomcat ? Alternatively, you can use GlassFish as deployment platform and everything is baked in there.


  • cecilia Wednesday, December 17, 2008

    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.


  • Arun Gupta Thursday, December 18, 2008

    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


  • Jan-Rudolph Buhrmann Tuesday, April 14, 2009

    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.


  • Andy Basu Thursday, April 23, 2009

    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.


  • Arun Gupta Thursday, April 23, 2009

    Andy,

    Please post your questions to users@metro.dev.java.net.


  • Andre Tuesday, May 12, 2009

    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


  • Arun Gupta Tuesday, May 12, 2009

    Andre, Transactional services will work on GlassFish only.


  • marshal Wednesday, May 20, 2009

    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


  • Luis V Tuesday, May 26, 2009

    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.


  • Arun Gupta Tuesday, May 26, 2009

    Luis, please post your question to users@metro.dev.java.net for a wider audience.


  • tarek7elmy Tuesday, November 3, 2009

    i did all setting for tomcat and start tomcat

    but how can i test that the installintion of metro in tomcat was success


  • Arun Gupta Tuesday, November 3, 2009

    tarek7elmy,

    Please post your question to users@metro.dev.java.net for a better response time.

    -Arun


  • Priya Friday, January 22, 2010

    I faced some issues running the sample app on tomcat 6 with JDK6 and posted here, May be of some help to others.

    http://software-wikipedia.blogspot.com/2010/01/trying-to-run-jax-ws-sample-application.html


  • RonnieSpike Thursday, February 4, 2010

    I had to go way back to rich's <tomcat>/endorsed solution (Posted by Rich on October 17, 2007 at 01:38 PM PDT) to avoid a java.lang.NoSuchMethodError: javax.xml.ws.WebFault.messageName()Ljava/lang for a web service that used the WebFault annotation


  • RonnieSpike Friday, February 5, 2010

    I had to go way back to rich's <tomcat>/endorsed solution (Posted by Rich on October 17, 2007 at 01:38 PM PDT) to avoid a java.lang.NoSuchMethodError: javax.xml.ws.WebFault.messageName()Ljava/lang for a web service that used the WebFault annotation


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.