No Spring WebApplicationInitializer types detected on classpath

Solution 1:

I spent hours on this, and the solution was:

  • Stop Tomcat
  • "Project" menu -> Clean -> Clean all projects
  • Servers tab -> Tomcat -> Right click -> Clean...
  • Right click on project -> Run as -> Run on server

Solution 2:

This turned out to be a stupid error. My log4j wasn't configured to capture my error output. I was throwing configuration errors in the background and once I fixed those I was good to go and my request mappings worked fine.

Solution 3:

Watch out if you are using Maven. Your folder's structure must be right.

When using Maven, the WEB-INF directory must be inside webapp:

src/main/webapp/WEB-INF

Solution 4:

INFO: No Spring WebApplicationInitializer types detected on classpath.

Can also show up if you're using Maven with Eclipse and deploying your WAR using;

(Eclipse, Kepler, with M2)

(right-click on your project) -> Run As -> Run on Server

It's down to the generation and deletion of the m2e-wtp folder and contents.

Make sure, Maven Archive generated files under the build directory is checked.

Under: "Window -> preferences -> Maven -> Java EE Integration"

Then:

Use M2, to do your build, i.e. the usual Clean -> package or Install etc...

If "Project -> Build Automatically" is not selected. You can force the "m2e-wtp folder and contents" generation by doing;

"(right-click on your project) -> Maven -> Update Project..."

Note: make sure the "Clean Projects" option is un-selected. Otherwise the contents of target/classes will be deleted and you're back to square one.

Also,when;

"Project -> Build Automatically" is selected the "m2e-wtp folder and contents" is generated

or "Project -> Build All"

or "(right-click on project) -> Build Project"

Solution 5:

WebApplicationInitializer is an interface you can implement in one of your classes. At startup Spring is scanning for this classes, as long as you are using servlet spec 3 and have a metadata-complete="false" attribute in your web.xml. But that doesn't seem to be the problem. The only error I can figure out is the missing slf4j-log4j12.jar.