Metro on Tomcat 6.x

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

Comments:

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

Posted by Jim on August 06, 2007 at 01:28 AM PDT #

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.

Posted by Jim on August 06, 2007 at 01:30 AM PDT #

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 ?

Posted by Arun Gupta on August 06, 2007 at 02:12 AM PDT #

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

Posted by Ken Hofsass's Blog on August 22, 2007 at 08:23 AM PDT #

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

Posted by Ken Hofsass's Blog on August 22, 2007 at 08:35 AM 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 05:24 AM 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 06:38 AM 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 08:01 AM 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 01: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 05:59 AM 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 12: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 04: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 21, 2007 at 05:26 PM 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 06:47 AM 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 08:02 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 Salil Surendran on March 24, 2008 at 12: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 01: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 04:50 AM PDT #

[Trackback] The How-To series demo Silverlight accessing Web Services in various configuration. In this post, we

Posted by A Cup of Silverlight, RIA & Interoperability on August 05, 2008 at 11:34 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 laptop batteries on November 26, 2008 at 12: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 16, 2008 at 05:27 PM 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 02: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 03: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 17, 2008 at 09:07 PM 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 13, 2009 at 11:35 PM 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 12:58 AM PDT #

Andy,

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

Posted by Arun Gupta on April 23, 2009 at 01: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 12:58 AM PDT #

Andre, Transactional services will work on GlassFish only.

Posted by Arun Gupta on May 12, 2009 at 01: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 11:14 AM 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 25, 2009 at 06:32 PM 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 03: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 02, 2009 at 08:22 PM 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 01:53 AM PST #

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

Posted by Priya on January 22, 2010 at 06:22 AM PST #

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

Posted by RonnieSpike on February 04, 2010 at 08:43 AM PST #

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

Posted by RonnieSpike on February 04, 2010 at 09:25 PM PST #

Post a Comment:
Comments are closed for this entry.
About

profile image
Arun Gupta is a technology enthusiast, a passionate runner, author, and a community guy who works for Oracle Corp.


Java EE 7 Samples

Stay Connected

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today