Deploy JAX-WS web services on Tomcat

Here’s a guide to show you how to deploy JAX-WS web services on Tomcat servlet container. See following summary steps of a web service deployment.

  1. Create a web service (of course).
  2. Create a sun-jaxws.xml, defines web service implementation class.
  3. Create a standard web.xml, defines WSServletContextListener, WSServlet and structure of a web project.
  4. Build tool to generate WAR file.
  5. Copy JAX-WS dependencies to “${Tomcat}/lib” folder.
  6. Copy WAR to “${Tomcat}/webapp” folder.
  7. Start It.

Directory structure of this example, so that you know where to put your files.


1. WebServices

A simple JAX-WS hello world example.

File :

import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
//Service Endpoint Interface
@SOAPBinding(style = Style.RPC)
public interface HelloWorld{
	@WebMethod String getHelloWorldAsString();

File :

import javax.jws.WebService;
//Service Implementation Bean
@WebService(endpointInterface = "")
public class HelloWorldImpl implements HelloWorld{
	public String getHelloWorldAsString() {
		return "Hello World JAX-WS";

Later, you will deploy this hello world web service on Tomcat.

2. sun-jaxws.xml

Create a web service deployment descriptor, which is also known as JAX-WS RI deployment descriptor – sun-jaxws.xml.

File : sun-jaxws.xml

<?xml version="1.0" encoding="UTF-8"?>

When user access /hello/ URL path, it will fire the declared web service, which is

For detail endpoint attributes , see this article.

3. web.xml

Create a standard web.xml deployment descriptor for the deployment. Defines WSServletContextListener as listener class, WSServlet as your hello servlet.

File : web.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, 
Inc.//DTD Web Application 2.3//EN"

4. WAR Content

Use Ant, Maven or JAR command to build a WAR file to include everything inside. The WAR content should look like this :

For those who are interested, here’s the Ant file to build this project and generate the WAR file.

File : build.xml

<project name="HelloWorldWS" default="dist" basedir=".">
        Web Services build file
  <!-- set global properties for this build -->
  <property name="src" location="src"/>
  <property name="build" location="build"/>
  <property name="dist"  location="dist"/>
  <property name="webcontent"  location="WebContent"/>
  <target name="init">
        <!-- Create the time stamp -->
        <!-- Create the build directory structure used by compile -->
        <mkdir dir="${build}"/>
  <target name="compile" depends="init"
  	description="compile the source " >
        <!-- Compile the java code from ${src} into ${build} -->
        <javac srcdir="${src}" destdir="${build}"/>
  <target name="war" depends="compile"
  	description="generate the distribution war" >
	<!-- Create the war distribution directory -->
  	<mkdir dir="${dist}/war"/>
  	<!-- Follow standard WAR structure -->
  	<copydir dest="${dist}/war/build/WEB-INF/" src="${webcontent}/WEB-INF/" />
  	<copydir dest="${dist}/war/build/WEB-INF/classes/" src="${build}" />
	<jar jarfile="${dist}/war/HelloWorld-${DSTAMP}.war" basedir="${dist}/war/build/"/>

5. JAX-WS Dependencies

By default, Tomcat does not comes with any JAX-WS dependencies, So, you have to include it manually.

1. Go here
2. Download JAX-WS RI distribution.
3. Unzip it and copy following JAX-WS dependencies to Tomcat library folder “{$TOMCAT}/lib“.

  • jaxb-impl.jar
  • jaxws-api.jar
  • jaxws-rt.jar
  • gmbal-api-only.jar
  • management-api.jar
  • stax-ex.jar
  • streambuffer.jar
  • policy.jar

6. Deployment

Copy the generated WAR file to {$TOMCAT}/webapps/ folder and start the Tomcat server.

For testing, you can access this URL : http://localhost:8080/HelloWorld/hello, if you see following page, it means web services are deploy successfully.


Download Source Code

Download It – (13KB)


  1. JAX-WS WAR File Packaging
  2. Deploying Metro endpoint
  3. Publishing a RESTful Web Service with JAX-WS
Tags :

About the Author

Founder of and, love Java and open source stuff. Follow him on Twitter, or befriend him on Facebook or Google Plus. If you like my tutorials, consider make a donation to these charities.


  • Pingback: house blue()

  • Pingback: zak?ad szklarski piotrk√≥w trybunalski()

  • Pingback: plumbers tape home depot()

  • Pingback: bottled alkaline water()

  • Pingback: pay per day loans plan()

  • Pingback: water ionizer pay plan loans()

  • Pingback: parking()

  • Pingback: mobile porn()

  • Pingback: stop parking()

  • Pingback: laane penge nu()

  • Pingback: lan nu og her()

  • Pingback:

  • Pingback: Website()

  • Pingback: enagic kangen water()

  • Pingback: alkaline water benefits()

  • Pingback: alkaline()

  • Pingback: alkaline water()

  • Pingback: watch movies online()

  • Pingback: watch tv show episodes()

  • Pingback: free movie downloads()

  • Pingback: Watch Video()

  • Pingback: Blue Coaster33()

  • Pingback: 404 Nicht gefunden: Invalid Request jax ws web service | Technology & Programming()

  • Pise

    Hi Mkyong, When I deploy above webservice in Jboss 4.2 it is working fine but when I deploy the same in Jboss 5.1 GA deployment fails and I get exception

    java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method “;” the class loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) of the current class, com/sun/xml/ws/util/xml/XMLStreamReaderFilter, and the class loader (instance of ) for interface javax/xml/stream/XMLStreamReader have different Class objects for the type javax/xml/namespace/QName used in the signature

    I googled and come to know that this is due to some conflict in jar files but I am not able to identify which jar file

  • saibal

    I am using tomcat/6.026 in windows.

    A. I got the error “SEVERE: Error listenerStart” after I added the jars in STEP 5
    SOLUTION: Add the following 2 additional jars (as Kaushal has mentioned)
    1. ha-api.jar
    2. jaxb-core.jar

    B. From the download source code I took the HelloWorld-20101123.war and pasted it in the tomcat webapps directory while tomcat was running and automatically the application was deployed (hot deploy).
    Then I typed in the following in the browser
    and it works

    Thanks a lot to Mr. mykong who is doing a wonderful job in helping us with all the examples and to everyone in the post for helping each other.

    I am using Tomcat 6.0.26.
    In addition to what mkyong has mentioned

  • Chris the Viech

    If you run into issues, just copy the whole content of the lib folder from the extracted jaxws-ri to your Tomcat libs folder. Worked for me. Greets

  • Pingback: Tomcat JAX-WS deployment strange message: Prefix ‘ ‘ is already bound to ‘ ‘. Huh? | Ask & Answers()

  • faruk cevik

    How can I publish a web service such folder:

    I tried various combinations but I could not managed

  • Santosh

    When I try to open the Web.xml in browser, I get the below error.

    The XML page cannot be displayed
    Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.


    Unspecified error Error processing resource ‘’.

  • apara

    Hi thanks for this post, how can I create the wsdl file for this web service created ?

    • Beanie

      On a browser, type your web service address followed by ?wsdl, like stated on the 6th point (Deployment one).

  • apara

    Hi, thanks for this post. How can I create a wsdl file for this webservice created ? please help me, im new to WS

  • http://NA Jeet

    Thanks for the brilliant insights in java/jee by giving practical example. it would have been great of you have provided some use-cases where these will work.
    And please recommend a book for Java Web Services (preferably SOAP)

  • Wrushasen Dakhane

    Sorry I tried everything mentioned here but I am stuck at
    SCHWERWIEGEND: WSSERVLET11: Runtime descriptor cannot be parsed: java
    .lang.NoSuchMethodError: me
    thod ()V not found

    Please help me, I am running on Tomcat 7

    • SoapDummy

      you must read the older comments.
      The answer was already posted.

      Best regards.

      • Deniz


        I added the jars you mentioned from jaxws-ri-2.2.8 but still no good :/

        • Kod

          Any errors / stack trace. I am using this example and have now made it possible 3 external companies to connect to our web services(Well with added security measures). Please describe any errors you get or paste your stack trace..

          • Deniz

            Stack trace is:
            SEVERE: WSSERVLET11: failed to parse runtime descriptor: java.lang.NoSuchMethodError: method ()V not found
            java.lang.NoSuchMethodError: method ()V not found
            at org.apache.catalina.core.StandardContext.startInternal(
            at org.apache.catalina.util.LifecycleBase.start(
            at org.apache.catalina.core.ContainerBase.addChildInternal(
            at org.apache.catalina.core.ContainerBase.addChild(
            at org.apache.catalina.core.StandardHost.addChild(
            at org.apache.catalina.startup.HostConfig.deployDescriptor(
            at org.apache.catalina.startup.HostConfig.deployApps(
            at org.apache.catalina.startup.HostConfig.check(
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(
            at java.lang.reflect.Method.invoke(
            at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(
            at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(
            at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(
            at org.apache.catalina.manager.ManagerServlet.check(
            at org.apache.catalina.manager.ManagerServlet.deploy(
            at org.apache.catalina.manager.ManagerServlet.doGet(
            at javax.servlet.http.HttpServlet.service(
            at javax.servlet.http.HttpServlet.service(
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(
            at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(
            at org.apache.catalina.core.StandardWrapperValve.invoke(
            at org.apache.catalina.core.StandardContextValve.invoke(
            at org.apache.catalina.authenticator.AuthenticatorBase.invoke(
            at org.apache.catalina.core.StandardHostValve.invoke(
            at org.apache.catalina.valves.ErrorReportValve.invoke(
            at org.apache.catalina.valves.AccessLogValve.invoke(
            at org.apache.catalina.core.StandardEngineValve.invoke(
            at org.apache.catalina.connector.CoyoteAdapter.service(
            at org.apache.coyote.http11.AbstractHttp11Processor.process(
            at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(
            at java.util.concurrent.ThreadPoolExecutor.runWorker(
            at java.util.concurrent.ThreadPoolExecutor$

        • Kod


          Ok, this is classpath issues. Please try the following, assuming you running
          tomcat 6 or 7 as a stand alone app server (outside an IDE) on windows.

          1. Got to the Tomcat lib folder >> C:\TomcatHome\lib

          find the jaxws-rt.jar (if not found, copy this jar and make sure it exists).

          2. Got to c: \Tomcat \ webapps \ yourappname \ lib folder

          find the jaxws-rt.jar, if found, please remove it, no need for it to be here, Tomcat will find the classes in the main lib folder.

          Restart tomcat and it should work :-)

          As for running from an IDE, well, I cant help you there, but it should be fairly easy.
          Just make sure the IDE class path has valid reference of all 10 jar as listed above.


          • Deniz

            Thanks for the answer. But I am using the Tomcat inside NetBeans.. And I already put the jar files under Tomcat’s lib folder, still no good.

  • Kod

    Much appreciated,thank you.

  • Kaushal

    I think we have to add jaxb-core.jar and ha-api.jar as well to server lib or project lib.
    I have downloaded jaxws-ri-2.2.8 and added following jars to my project lib folder
    1. gmbal-api-only.jar
    2. ha-api.jar
    3. jaxb-core.jar
    4. jaxb-impl.jar
    5. jaxws-api.jar
    6. jaxws-rt.jar
    7. management-api.jar
    8. policy.jar
    9. stax-ex.jar
    10. streambuffer.jar

    Please check and update the post.


  • Pallavi


    I have create new dynamic web project.(using eclipse-indigo & tomcat 6)
    created all classes.web.xml,build.xml,sun-jaxws.xml as specfied above. Also copied below jars :

    and restart the tomcat & i got following exception:
    Jun 20, 2013 1:20:21 PM org.apache.catalina.core.AprLifecycleListener init
    INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre6\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jre7/bin/client;C:/Program Files/Java/jre7/bin;C:/Program Files/Java/jre7/lib/i386;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\ImageConverter Plus;C:\Program Files\ImageConverter Plus\Microsoft.VC90.CRT;C:\Program Files\ImageConverter Plus\Microsoft.VC90.MFC;C:\Program Files\Java\jdk1.6.0_20\bin;C:\Documents and Settings\All Users\Application Data\Titanium\mobilesdk\win32\1.7.3.v20111012114613;C:\apache-ant-1.8.2\bin;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\K-Lite Codec Pack\QuickTime\QTSystem\;D:\GK\SkillSoft Courses\apache-ant-1.8.4-bin\apache-ant-1.8.4\bin;D:\GK\SkillSoft Courses\apache-ant-1.8.4-bin\apache-ant-1.8.4;C:\Program Files\Java\jdk1.6.0_20\bin;C:\Documents and Settings\pallavim;;.
    Jun 20, 2013 1:20:21 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
    WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property ‘source’ to ‘org.eclipse.jst.jee.server:HelloWorld’ did not find a matching property.
    Jun 20, 2013 1:20:21 PM org.apache.coyote.http11.Http11Protocol init
    INFO: Initializing Coyote HTTP/1.1 on http-8080
    Jun 20, 2013 1:20:21 PM org.apache.catalina.startup.Catalina load
    INFO: Initialization processed in 449 ms
    Jun 20, 2013 1:20:21 PM org.apache.catalina.core.StandardService start
    INFO: Starting service Catalina
    Jun 20, 2013 1:20:21 PM org.apache.catalina.core.StandardEngine start
    INFO: Starting Servlet Engine: Apache Tomcat/6.0.26
    Jun 20, 2013 1:20:21 PM org.apache.catalina.core.StandardContext listenerStart
    SEVERE: Error configuring application listener of class
    at org.apache.catalina.loader.WebappClassLoader.loadClass(
    at org.apache.catalina.loader.WebappClassLoader.loadClass(
    at org.apache.catalina.core.StandardContext.listenerStart(
    at org.apache.catalina.core.StandardContext.start(
    at org.apache.catalina.core.ContainerBase.start(
    at org.apache.catalina.core.StandardHost.start(
    at org.apache.catalina.core.ContainerBase.start(
    at org.apache.catalina.core.StandardEngine.start(
    at org.apache.catalina.core.StandardService.start(
    at org.apache.catalina.core.StandardServer.start(
    at org.apache.catalina.startup.Catalina.start(
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(
    at org.apache.catalina.startup.Bootstrap.main(
    Jun 20, 2013 1:20:21 PM org.apache.catalina.core.StandardContext listenerStart
    SEVERE: Skipped installing application listeners due to previous error(s)
    Jun 20, 2013 1:20:21 PM org.apache.catalina.core.StandardContext start
    SEVERE: Error listenerStart
    Jun 20, 2013 1:20:21 PM org.apache.catalina.core.StandardContext start
    SEVERE: Context [/HelloWorld] startup failed due to previous errors

    On searched on net for this, solution was to add “jaxws-rt.jar” its already included.
    Plz help me..Im very new to web-services..
    Thanks in advance


    • SoapDummy

      Hi Pallavi,

      did you copy the jar into the lib directory beneath /lib or somewhere else?
      What about the WARNING about the source parameter?
      >>> WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property ?source? to ?org.eclipse.jst.jee.server:HelloWorld? did not find a matching property.

  • Juan Carlos


    I have a problem, when I deployment the file HelloWorld.war the status aplication?s is false. In the log, the old message is “Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/HelloWorld]]”

    Can you help me?

  • Pallavi

    I tried to run the above example (, but when I tried it in the browser I got an 404 error. Can you please help me?

    • SoapDummy


      Do it step by step:
      Like you know 404 means that the deployment cannot be found.
      404 should not be sent after deploying the application.
      1. Make a new directory under “\webapps\” called HelloWorld.
      2. Create a index.html page with just a text “Hello world” in it
      and put it in the directory.
      3. Start Tomcat
      4. Go to your browser and type: http://localhost:8080/HelloWorld/
      5. Now you should see your text.
      6. Now deploy the zip file again (do not forget to copy the lib directories)
      to the just created directory and it should work!

      • eight.bits

        Hi Soap!

        I was able to successfully execute steps 1-5. But unfortunately, when I included the *.war
        file into the web app/HelloWorld/*.war and even tried extracting them on the HelloWorld folder
        I still get the 404 Http Status. I made sure that the required *.jar files stated above are included and put in the appropriate folder. Can you show me the content of the web app/HelloWorld/ folder?

        Your response is very much appreciated.



  • http://[email protected] SteveH

    Brilliant article! Concise and correct (apart from slight hiccup regarding ha-api.jar). Got me up and running in 5 minutes flat, after spending a few confusing days trawling the net. Many, many thanks.

  • SoapDummy

    Hi there,

    thanks for the tutorial and the example. I tried it but after downloading the JAX-WS dependency files and deploying the example on Tomcat, I keep getting the error:

    27.05.2013 11:35:46
    er parseAdaptersAndCreateDelegate
    SCHWERWIEGEND: WSSERVLET11: Runtime descriptor cannot be parsed: java
    .lang.NoSuchMethodError: me
    thod ()V not found
    : method ()V not found

    Thanks in advance.

    • SoapDummy

      Issue solved! I just read the old comments :-)
      ha-api.jar needed. Thanks for the help.

      Like you all said: great job done by Mkyong.
      Keep it up!

  • siva

    Thank you .. you are doing great work..

  • Shaffic

    Nice Example.. it would be nice if it have code description also..

  • mokhtar

    Very nice tutorial

    I have a question: do we need to run wsgen tool to create server side “artifacts” ? is it left out because we used RPC soap binding but is needed in case of default document binding ? I am a bit confused because i saw this tool mentioned in a couple of articles including this web site.

  • Andrea Spinelli

    Hi, thanks for your guide.

    However, I have to concur with Stefano, because you forgot



  • Stefano

    Note that ha-api.jar has to be included too in your calsspath. You should modify point 5 of this guide. Tested on tomcat 7.

  • Lukashenka

    Thanku very much!!! U saved my life!! God bless u asian man! Your god)