aspose file tools*
The moose likes Web Services and the fly likes Deploy JAXWS (Mustang) WS to Tomcat? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Deploy JAXWS (Mustang) WS to Tomcat?" Watch "Deploy JAXWS (Mustang) WS to Tomcat?" New topic
Author

Deploy JAXWS (Mustang) WS to Tomcat?

Erak Vegen
Greenhorn

Joined: Mar 08, 2007
Posts: 7
Hi folks,

is it possible to deploy a webservice generated with Java 6 JAXWS under Tomcat? I can't find any information about this topic, besides a very old blog entry stating that I should checkout some jar from the glassfish nightly build - which doesn't seem like a very production stable option.

Any hints to documentation or a simple outline of the procedure would be welcome.

Thanks
TD
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41838
    
  63
Welcome to JavaRanch.

When that blog post was written, JAX-WS 2.0 was not yet released, so there was no released version to point to. By now it's final. Note that the 2.1 version was final, but has been temporarily withdrawn, so 2.0 is currently the version to use.

As an aside, I thought Java 6 includes JAS-WS 2.0, so maybe you already have everything you need?


Ping & DNS - my free Android networking tools app
Erak Vegen
Greenhorn

Joined: Mar 08, 2007
Posts: 7
Thanks for the welcome

Indeed I am talking about the Java 6 included JAXWS (whatever version that is) and my hope actually is that I have everything I need - only I do not know how to use it

I have written a class with annotations, used the wsgen tool shipped with my Java 6 SDK to generate WSDL and XSD files and then used the javax.xml.ws.Endpoint class to test the service. Everything works fine.

Now I am looking for a way to publish this web service via Tomcat ...

Thanks
TD
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41838
    
  63
Section 3.1.2.3 of the User's Guide mentions creating a WAR file, so it looks as if the tools generate a regular web app, which should be deployable in Tomcat.
Erak Vegen
Greenhorn

Joined: Mar 08, 2007
Posts: 7
In th user's guide it says:

The WAR file created can now be published on a JAX-WS 2.0 SI enabled servlet container such as the Sun Java System Application Server Platform Edition 8.1


The war contains a sun-jaxws.xml descriptor that points the server to the webservice. Tomcat can do nothing with that, so I think I have to enable tomcat to be a "JAX-WS 2.0 SI enabled servlet container"? But how?

Or is there maybe another way to publish a Java6 webservice to tomcat (apart from using axis)?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41838
    
  63
Ah. So the web app that gets created does not have some init code or startup listener that sets everything up, including making sense of that file?
Erak Vegen
Greenhorn

Joined: Mar 08, 2007
Posts: 7
I have found another source which explains the web.xml for such a war archive:


The following shows a web.xml file for a simple HelloWorld service. It specifies JAX-WS RI specific listener, servlet classes. These classes are com.sun.ws.transport.http.servlet.JAXRPCContextListener, and com.sun.xml.ws.transport.http.servlet.JAXRPCServlet is servlet


Only I can't find the mentioned classes neither in the Java 6 distribution nor in the jwsdp-2.0. However I found some classes in other packages that seem at least similar: com.sun.xml.rpc.server.http.JAXRPCServlet and com.sun.xml.ws.transport.http.servlet.WSServlet (and also corresponding listeners etc.).

So currently I'm trying to figure out what these classes do ... since there is no source code available this might be a bit tricky
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41838
    
  63
Try configuring the com.sun.xml.ws.transport.http.servlet.WSServletContextListener class as a (surprise!) context listener. It accesses the /WEB-INF/sun-jaxws.xml file.
Erak Vegen
Greenhorn

Joined: Mar 08, 2007
Posts: 7
I found an article in the following Enterprise Java Technologies TECHNICAL TIPS Newsletter. This Tech Tip describes what you need to do to change a JAX-WS-based web service developed using Java WSDP 2.0 and deployed on the J2EE 1.4 platform so that it can be ported to the Java EE5 platform. I tried to deploy the webservice as described in the article to Java EE5 - but this doesn't work since Tomcat AFAIK isn't a Java EE5 compliant enterprise server.

However the text gives a hint that the J2EE 1.4 deployment method will work for tomcat:

JAX-WS technology was initially made available in the Java Web Services Developer Pack (Java WSDP) Version 2.0. This allowed early adopters to develop JAX-WS-based web services and deploy them on J2EE 1.4 implementations such as the J2EE 1.4 SDK (which includes the Sun Java System Application Server 8.2 Platform Edition) or Apache Tomcat.


So far I haven't managed to get the example running but I will keep trying
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41838
    
  63
I think that may turn out to be dead end, as there is a special version of Tomcat (downloadable from java.sun.com somewhere) that has some extra tweaks that make it a J2EE server. But that's not the same thing as the standard Tomcat.

But the article specifically mentions which servlets and listeners to configure, and how they tie in with the sun-jaxws.xml file, so there's hope. Good find!
Erak Vegen
Greenhorn

Joined: Mar 08, 2007
Posts: 7
Ok I found a solution (at least it seems like): I use https://jax-ws.dev.java.net/jax-ws-20-fcs/

I do not exactly know how the JAX-WS RI 2.0 project is related to the JaxWS or Java6 or whatever ... Sun is very very confusing about this. All that OpenSource / Community / java.net / Glassfish ... I don't know what is the latest project and what is outdated

The steps are quite simple though:
  • Download and unpack the jax-ws
  • Copy all *.jar from the lib dir into $CATALINA_HOME/shared/lib
  • Create a directoy for the service under $CATALINA_HOME/webapps
  • Copy the class structure from the web service into WEB-INF/classes in that directory
  • Create a sun-jaxws.xml in WEB-INF
  • Create web.xml in WEB-INF
  • Start tomcat. Done


  • The web.xml should look something like this:



    So the tipps above are not that far away

    My sun-jaxws.xml looks like this:



    After starting tomcat you can access the service under



    Done
    Ulf Dittmer
    Marshal

    Joined: Mar 22, 2005
    Posts: 41838
        
      63
    I just discovered that it's easy to add server-side handlers. All that is needed is an annotation like

    @HandlerChain(file="handlers.xml")

    in the WS implementation class, and a corresponding handler.xml file that lists the handler classes to be called:



    Both javax.xml.ws.handler.LogicalHandler and javax.xml.ws.handler.soap.SOAPHandler can be used, depending on which level the processing is needed.
    [ March 11, 2007: Message edited by: Ulf Dittmer ]
    Erak Vegen
    Greenhorn

    Joined: Mar 08, 2007
    Posts: 7
    Ahhh very nice! Thanks a lot

    I'll keep on trying and report my findings
    aruna sydu
    Ranch Hand

    Joined: Jan 21, 2008
    Posts: 98

    This information is very helpful...

    Thanks a lot..

    -aruna
    Prasath Premkumar
    Ranch Hand

    Joined: Nov 13, 2008
    Posts: 43

    Hi,

    very useful information. Thanks a lot for sharing.
    Tony Ennis
    Ranch Hand

    Joined: May 22, 2003
    Posts: 86
    Where does the handler.xml file go?
    Ulf Dittmer
    Marshal

    Joined: Mar 22, 2005
    Posts: 41838
        
      63
    Tony Ennis wrote:Where does the handler.xml file go?

    I think it was directly inside of WEB-INF.
    John Pradeep.v
    Ranch Hand

    Joined: Jul 21, 2008
    Posts: 59
    Useful content, Understanding web services is simpler than understanding the various techniques available to develop and deploy the web services...

    Anyone aware of any comparisons of various web service development kit with advantages and disadvantages? I might be wrong, but why is it that java web service development is confusing for the beginner as its difficult to find one standard approach for the development
    whether to use Axis, Java 6 JWS etc..
    pedro erg
    Greenhorn

    Joined: Dec 21, 2009
    Posts: 1
    Hello.

    I'm trying to do something similar: I have a webservice in glassfish with jaxrpc, and I have to put it in tomcat.
    Can I do this way?

    I urgently need to put the web service in tomcat...

    Thanks!
    Anitha Narayanan
    Greenhorn

    Joined: Apr 19, 2011
    Posts: 7
    Hi,
    I have one basic question. Is it that latest version of Tomcat have built in support for JaxWs ?
    I'm new to Java Web Service. Can somebody help me in understanding?
    Anitha Narayanan
    Greenhorn

    Joined: Apr 19, 2011
    Posts: 7
    Hi,
    I have one more question, If tomcat does not have built in support, Is it possible to copy jaxws jar files available in JDK to enable Tomcat lib to support JaxWS api ?
    Ulf Dittmer
    Marshal

    Joined: Mar 22, 2005
    Posts: 41838
        
      63
    Anitha Narayanan wrote:Is it that latest version of Tomcat have built in support for JaxWs ?

    No; you need to follow the steps outlined above to use JAX-WS on Tomcat.

    Is it possible to copy jaxws jar files available in JDK to enable Tomcat lib to support JaxWS api ?

    Don't do that; use the JAX-WS RI instead.
    Anitha Narayanan
    Greenhorn

    Joined: Apr 19, 2011
    Posts: 7
    Thanks Dittmer for the quick reply.

    Do we have any reason for not to use Jaxws api available in JDk to enable tomcat ?
    First of all, I dont know which are all the jars in JDK lib are specific to Jaxws lib. But then out of curiosity i'm asking above question.
    Pardon me, if my question is silly.
    Ulf Dittmer
    Marshal

    Joined: Mar 22, 2005
    Posts: 41838
        
      63
    Do we have any reason for not to use Jaxws api available in JDk to enable tomcat ?

    Yes - it's outdated compared to the RI.

    First of all, I dont know which are all the jars in JDK lib are specific to Jaxws lib.

    And there's no reason to care, really.
    Anitha Narayanan
    Greenhorn

    Joined: Apr 19, 2011
    Posts: 7
    Thank you Dittmer for your reply.
    This forum has very useful information. Thanks a lot for maintaining it.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Deploy JAXWS (Mustang) WS to Tomcat?