Announcement Announcement Module
No announcement yet.
WSServletContainerInitializer and SpringBeanAutowiringSupport Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • WSServletContainerInitializer and SpringBeanAutowiringSupport


    I have some integration issues regarding the mentioned classes but only with "too new" tomcat versions.

    The base setup:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi=""
    	xmlns="" xmlns:web=""
    	id="FooService" version="2.5" metadata-complete="true">
    @WebService(serviceName = ServiceInfo.SERVICENAME, targetNamespace = ServiceInfo.TARGETNAMESPACE, endpointInterface = "bar.FooService")
    @HandlerChain(file = "/handler-chain.xml")
    public class FooServiceImpl extends SpringBeanAutowiringSupport implements FooService {
    	private Bar bar;
    	<< some methods using the injected bar singleton >>
    JAX-WS dependency:
    compile ''
    Spring version: 3.1.2.RELEASE

    With Tomcat 7.0.22 I don't have the problem. The declared webapp version in the web.xml is 2.5. Tomcat 7.0.22 doesn't process the WSServletContainerInitializer. So as declared in web.xml, ContextLoaderListener is initialized first, so an instance of Bar will be available in the WebApplicationContext. Then WSServletContextListener instantiates FooServiceImpl, aoutowiring works and everybody is happy.

    But... My colleague tried it with Tomcat 7.0.30 and the autowiring didn't work. It really couldn't work, because the new Tomcat version has processed WSServletContainerInitializer, not taking into account the 2.5 webapp version (and metadata-complete="true").

    I've found a possible solution. I commented out the body of the web.xml, changed webapp version to 3.0 and created a WebapplicationInitializer:
    public class MyInitializer implements WebApplicationInitializer {
        public void onStartup(ServletContext servletContext) throws ServletException {
            ContextLoader loader = new ContextLoader();
    This worked perfectly for me. But not for my colleague... If he tried to run the app, WSServletContainerInitializer fired first which created exactly the same wiring problem as above.

    Obviously we can "hack" the problem getting rid of SpringBeanAutowiringSupport and inject Bar manually from a getter or a web method, or any similar way. But SpringBeanAutowiringSupport would be much clearer, so we would like to use it if there's a good solution for the above problems.

    UPDATE: this causes the problems
    Last edited by mihu86; Oct 12th, 2012, 08:08 AM.