Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why doesn't Tomcat 7x require WSServletContextListener and WSServlet configured in web.xml for Jax-ws service deployment?

I'm deploying and testing a simple Jax-ws service in both Tomcat6x and Tomcat7x with the jaxws-ri-2.2.8 added to both the server lib directories .
Tomcat6x requires the WSServletContextListener and WSServlet and configured in web.xml whereas in Tomcat 7x the webservices gets deployed without the WSServletContextListener and WSServlet configuration.
Whats different in Tomcat7 that makes the web.xml configuration optional?

like image 249
user68883 Avatar asked Mar 17 '14 13:03

user68883


People also ask

Does Tomcat support JAX-WS?

JAX-WS DependenciesBy default, Tomcat does not comes with any JAX-WS dependencies, So, you have to include it manually. 1. Go here http://jax-ws.java.net/.

Does Tomcat support SOAP?

The Apache Tomcat web server is used to deploy and run the Java SOAP service and SOAP-UI is used to test the service operations. The Java SOAP service that is created here represents a simple product catalog and provides methods to search and insert products.


2 Answers

If you are using Tomcat 7.x and Servlet 3.0, the listener com.sun.xml.ws.transport.http.servlet.WSServletContextListener is dynamically loaded. Since Java EE 6, a new component was added: javax.servlet.ServletContainerInitializer

Interface which allows a library/runtime to be notified of a web application's startup phase and perform any required programmatic registration of servlets, filters, and listeners in response to it.

The file jaxws-rt.jar contains in \META-INF\services a simple file text named javax.servlet.ServletContainerInitializer with one line:

com.sun.xml.ws.transport.http.servlet.WSServletContainerInitializer

This is the fully qualified class name which loads the required listener.

See also Using Servlets 3.0 ServletContainerInitializer.

like image 86
Paul Vargas Avatar answered Sep 23 '22 10:09

Paul Vargas


Tomcat 7 supports Servlet 3.0 that enables annotations to be used to configure various components of a web application including Servlets and Listeners.

like image 33
Mark Thomas Avatar answered Sep 21 '22 10:09

Mark Thomas