Announcement Announcement Module
Collapse
No announcement yet.
WebApplicationInitializer implementation not found when using tcServer v2.5 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • WebApplicationInitializer implementation not found when using tcServer v2.5

    I have recently installed Spring Tool Suite 2.7.1.RELEASE.

    I have created a template Spring MVC application and upgraded the Spring dependencies to use 3.1.0.M2. I am currently trying to replace the web.xml with an instance of WebApplicationInitializer. However this class isn't found when running the application using the built in tcServer.

    If I build a war using maven and then deploy it to a Tomcat 7 install in C:\Program Files outside of STS the WebApplicationInitializer is found.

    Is this a known problem or is there likely to be something which I have missed?

    Thanks,

    Alex

    Here is the WebApplicationInitializer which I am using.

    Code:
    public void onStartup(ServletContext servletContext)
    			throws ServletException {
    
    		XmlWebApplicationContext rootContext = new XmlWebApplicationContext();
    		rootContext.setConfigLocation("/WEB-INF/spring/root-context.xml");
    
    		servletContext.addListener(new ContextLoaderListener(rootContext));
    
    		XmlWebApplicationContext dispatcherContext = new XmlWebApplicationContext();
    		dispatcherContext
    				.setConfigLocation("/WEB-INF/spring/appServlet/servlet-context.xml");
    
    		// Register and map the dispatcher servlet
    		ServletRegistration.Dynamic dispatcher = servletContext.addServlet(
    				"dispatcher", new DispatcherServlet(dispatcherContext));
    		dispatcher.setLoadOnStartup(1);
    		dispatcher.addMapping("/");
    	}

  • #2
    Not much uptake for this one. Is there any more information that I can provide which would get people interested?

    Comment


    • #3
      Hi Alex!

      Would it be possible for you to attach a small sample project that reproduces the problem?

      -Martin

      Comment


      • #4
        Sample Project

        Martin,

        Thanks for your reply. I have attached a sample project which shows this problem. I created the project as a Spring MVC Project from the Templates in 2.7.1.RELEASE. The changes I made are as follows:

        pom.xml

        Changed the Spring dependency to 3.1.0.M2
        Upgraded the servlet API dependency to 3.0
        Added failOnMissingWebXml = false to the maven-war-plugin

        I then created an implementation of WebApplicationInitalizer and deleted web.xml.]

        I then executed a maven clean and package and deployed the resultant war to a seperate Tomcat 7 install. The output in tomcat7-stdout.YYYY-MM-DD is as follows:

        Code:
        INFO : org.springframework.web.SpringServletContainerInitializer - Delegating ServletContext to the following WebApplicationInitializer instances: [com.test.project.config.WebApplicationInitializer@2130c2]
        This was what I expected to see when I start the same project in the tcServer install included with STS.

        If you need anything else give me a shout.

        Alex

        Comment


        • #5
          Martin,

          Any luck replicating this using the sample project?

          Alex

          Comment


          • #6
            Hey Alex!

            I tried the sample project and it doesn't show any error message, but it doesn't seem to do anything. So there seems to be something not working...
            I tried the WAR file that Maven produces and put that directly into the tc server instance, but that doesn't work either. So my current guess is that the problem might be related to tc server running the app instead of just tomcat. But when I deploy the project to a standard Tomcat, I get the message you described, but I don't get anything back when accessing the app from the browser.

            I would recommend to ask this question in the web forum, I think there are better experts for this problem. Sorry for not being able to help more here...

            HTH,
            Martin

            Comment


            • #7
              Martin,

              Thanks for your reply. Everything you described is as I found. The sample project doesn't have any code to return anything when accessing the app from a browser. All that I included is enough configuration code to show that the tc server fails to find the WebApplicationInitializer implementation.

              Should I raise a issue for this and link this conversation? Since this seems to be an issue with the way tc server uses tomcat.

              Alex

              Comment


              • #8
                I moved the issue to the tc server issue tracker:
                https://issuetracker.springsource.com/browse/TCS-2363

                Comment


                • #9
                  I can't see that issue

                  Permission Violation!

                  Comment


                  • #10
                    Oooops... Why that? Need to check that...

                    Comment


                    • #11
                      Moved this thread to the tc server forum...

                      Comment


                      • #12
                        The problem's down to the configuration of the tomcat.util.scan.DefaultJarScanner.jarsToSkip property in catalina.properties. In tc Server, we add a number of Spring (and other) JARs that are known not to contain TLDs. Unfortunately, this also means that Spring 3.1's new SpringServletContainerInitializer isn't found either as it's in a JAR that's included in the list of JARs to be skipped. We'll fix this problem in a forthcoming tc Server release. In the meantime, you can fix the issue by removing the line "spring-web-*.jar,\" from your instance's "conf/catalina.properties" file. Apologies for the inconvenience.

                        Comment


                        • #13
                          Thanks for the workaround and explanation.

                          Alex

                          Comment

                          Working...
                          X