I am trying to minimize required configuration while deploying JAX-WS-based Web service on Tomcat. With the introduction of Servlet 3.0 (supported by Tomcat 7+), web.xml
can be thrown out, but there is still sun-jaxws.xml
. This blog post is interesting:
Of course, with the use of jax-ws annotations, even configuration sun-jaxws.xml can be made optional making it completely descriptor free, but that requires specifying a default url-pattern like in JSR-109 or custom pattern like in Jersey REST services, in the JAX-WS specification.
Is it possible to avoid sun-jaxws.xml
on Tomcat, and how?
sun-jaxws. xml is a proprietary deployment descriptor needed when web services are deployed as a standard WAR archive on a non-Java EE5 servlet container using the SUN's reference implementation.
In this example, the Eclipse Java EE IDE is used to create a new Java SOAP service. 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.
Sadly, the configuration must exist somewhere. That is mandatory, per the source. Believe it or not, the location of the sun-jaxws.xml file is hard-coded to /WEB-INF/sun-jaxws.xml (thanks, guys @ Metro).
Effectively, you need to take control of the following classes
public final class WSServletContextListener
public class WSServlet
What needs to happen:
WSServletContextListener
will obviously not be extended. This listener performs most of the initializations per the sun-jaxws.xml and jaxws-catalog file. Like I mentioned earlier, the location is hard coded. So your path of least resistance here is to
implement your own vanilla servlet listener (with @WebListener
) and call a new WSServletContextListener()
. You'll then delegate your own contextInitialized(ServletContext ctxt)
and contextDestroyed()
methods to the ones in your instance of WSServletContextListener
.
Generate the file on instantiation of the listener, on the fly, using an @XmlRootElement
class that'll represent the sun-jaxws file(I'll provide a sample of this in a short while, don't have the time right now :) ).
It's a lot of trouble for such a dispensable convenience, IMO, but it should work in theory. I'll write some samples and see how they play shortly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With