Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: WebApplicationInitializer implementation not found when using tcServer v2.5

  1. #1

    Default 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. #2

    Default

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

  3. #3
    Join Date
    Sep 2008
    Location
    Hamburg, Germany
    Posts
    1,640

    Default

    Hi Alex!

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

    -Martin
    Martin Lippert
    SpringSource, a division of VMware
    SpringSource Tools Team
    http://www.springsource.com
    http://twitter.com/martinlippert

  4. #4

    Default 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
    Attached Files Attached Files

  5. #5

    Default

    Martin,

    Any luck replicating this using the sample project?

    Alex

  6. #6
    Join Date
    Sep 2008
    Location
    Hamburg, Germany
    Posts
    1,640

    Default

    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
    Martin Lippert
    SpringSource, a division of VMware
    SpringSource Tools Team
    http://www.springsource.com
    http://twitter.com/martinlippert

  7. #7

    Default

    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

  8. #8
    Join Date
    Sep 2008
    Location
    Hamburg, Germany
    Posts
    1,640

    Default

    I moved the issue to the tc server issue tracker:
    https://issuetracker.springsource.com/browse/TCS-2363
    Martin Lippert
    SpringSource, a division of VMware
    SpringSource Tools Team
    http://www.springsource.com
    http://twitter.com/martinlippert

  9. #9

    Default

    I can't see that issue

    Permission Violation!

  10. #10
    Join Date
    Sep 2008
    Location
    Hamburg, Germany
    Posts
    1,640

    Default

    Oooops... Why that? Need to check that...
    Martin Lippert
    SpringSource, a division of VMware
    SpringSource Tools Team
    http://www.springsource.com
    http://twitter.com/martinlippert

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •