Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Deploy JAXWS (Mustang) WS to Tomcat?

 
Erak Vegen
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Erak Vegen
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
    Rancher
    Posts: 42967
    73
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 7
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Ahhh very nice! Thanks a lot

    I'll keep on trying and report my findings
     
    aruna sydu
    Ranch Hand
    Posts: 98
    MyEclipse IDE Oracle
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    This information is very helpful...

    Thanks a lot..

    -aruna
     
    Prasath Premkumar
    Ranch Hand
    Posts: 43
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Hi,

    very useful information. Thanks a lot for sharing.
     
    Tony Ennis
    Ranch Hand
    Posts: 86
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Where does the handler.xml file go?
     
    Ulf Dittmer
    Rancher
    Posts: 42967
    73
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Tony Ennis wrote:Where does the handler.xml file go?

    I think it was directly inside of WEB-INF.
     
    John Pradeep.v
    Ranch Hand
    Posts: 59
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 7
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 7
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Rancher
    Posts: 42967
    73
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 7
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Rancher
    Posts: 42967
    73
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 7
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thank you Dittmer for your reply.
    This forum has very useful information. Thanks a lot for maintaining it.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic