[java] INFO: No Spring WebApplicationInitializer types detected on classpath

I have a spring project that runs fine on my tomcat7 server when I deploy from eclipse: Run As >> Run on server. In the eclipse tab "Servers" I see:

Servers
 Tomcat v7.0 Server at localhost [Started, Synchronized]
   my_project [Synchronized]
     spring-web-3.2.4-RELEASE.jar

My project:

  • does not use web.xml, I use javaconf @ annotations.
  • does not use maven, I use a User Library

I see that the project is in:

/srv/applications/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0

And, I also see the folders: conf,logs,temp,webapps,work,wtpwebapps

I confirm that all runs fine on my tomcat7 server when I deploy from eclipse!

In eclipse console I get:

Apr 08, 2014 3:26:59 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:my_project' did not find a matching property.
Apr 08, 2014 3:27:00 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8888"]
Apr 08, 2014 3:27:00 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8843"]
Apr 08, 2014 3:27:01 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 3215 ms
Apr 08, 2014 3:27:01 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Apr 08, 2014 3:27:01 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.26
Apr 08, 2014 3:27:11 PM org.apache.catalina.core.ApplicationContext log
INFO: Spring WebApplicationInitializers detected on classpath: [my_project.web.context.WebApplicationInitializer@3599e94c]
Apr 08, 2014 3:27:12 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Apr 08, 2014 3:27:24 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'dispatcher'
Apr 08, 2014 3:27:24 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8888"]
Apr 08, 2014 3:27:24 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8843"]
Apr 08, 2014 3:27:24 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 23821 ms

Now: The problem It is when I deploy the same app (using a file .war) in the same tomcat7 server /var/lib/tomcat7/webapps

I can open the my initial page web BUT without data,

I see in the log:

INFO: No Spring WebApplicationInitializer types detected on classpath

When I restart tomcat7 I get in the log file:

INFO: Destroying ProtocolHandler ["http-bio-8843"]
Apr 8, 2014 3:25:30 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:my_project' did not find a matching property.
Apr 8, 2014 3:25:30 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8888"]
Apr 8, 2014 3:25:31 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8843"]
Apr 8, 2014 3:25:31 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1664 ms
Apr 8, 2014 3:25:31 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Apr 8, 2014 3:25:31 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.26
Apr 8, 2014 3:25:38 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8888"]
Apr 8, 2014 3:25:38 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8843"]
Apr 8, 2014 3:25:38 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 7576 ms

This question is related to java spring spring-mvc tomcat7

The answer is


I had similar problem with Tomcat 8 embedded in java7 application.

When I launched Tomcat in my application, it worked. But when I launched it through Maven for integration test purpose, I got this error : "No Spring WebApplicationInitializer types detected on classpath".

I fixed it by upgrading org.apache.tomcat.embed:tomcat-embed-* dependencies from version 8.0.29 to 8.0.47.


For eclipse users: solution is simple just change the nature of project Spring Tools->add spring project nature

done.


I had this info message "No Spring WebApplicationInitializer types detected on classpath" while deploying a WAR with spring integration beans in WebLogic server. Actually, I could observe that the servlet URL returned 404 Not Found and beside that info message with a negative tone "No Spring ...etc" in Server logs, nothing else was seemingly in error in my spring config; no build or deployment errors, no complaints. Indeed, I suspected that the beans.xml (spring context XML) was actually not picked up at all and that was bound to the very specific organizing of artefacts in Oracle's jDeveloper. The solution is to play carefully with the 'contributors' and 'filters' for the WEB-INF/classes category when you edit your deployment profile under the 'deployment' topic in project properties.

Precisely, I would advise to name your spring context by the jDeveloper default "beans.xml" and place it side by side to the WEB-INF subdirectory itself (under your web Apllication source path, e.g. like <...your project path>/public_html/). Then in the WEB-INF/classes category (when editing the deployment profile) your can check the Project HTML root directory in the 'contributor' list, and then select the beans.xml in filters, and then ensure your web.xml features a context-param value like classpath:beans.xml.

Once that was fixed, I was able to progress and after some more bean config changes and implementations, the message "No Spring WebApplicationInitializer types detected on classpath" came back! Actually, I did not notice when and why exactly it came back. This second time, I added a

public class HttpGatewayInit implements WebApplicationInitializer { ... }

which implements empty inherited methods, and the whole application works fine!

...If you feel that java EE development has been getting a bit too crazy with cascades of XML configuration files (some edited manually, others through wizards) intepreted by cascades of variant initializers, let me insist that I fully share your point.


This is common error, make sure that your file.war is built correctly. Just open .war file and check that your WebApplicationInitializer is there.


My silly reason was: Build Automatically was disabled!


Make sure that your log4j is configured correctly, there's probably an exception that is being thrown, but you're only seeing half of the picture.

Please see https://stackoverflow.com/a/16817018/1249304


I found the error: I have a library that it was built using jdk 1.6. The Spring main controller and components are in this library. And how I use jdk 1.7, It does not find the classes built in 1.6.

The solution was built all using "compiler compliance level: 1.7" and "Generated .class files compatibility: 1.6", "Source compatibility: 1.6".

I setup this option in Eclipse: Preferences\Java\Compiler.

Thanks everybody.


<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>          
    <configuration>
        <source>1.8</source>
        <target>1.8</target>
    </configuration>
 </plugin>

This is the important plugin that should be in pom.xml. I spent my two days debugging and researching. This was the solution. This is Apache plugin to tell maven to use the the given Compiler.


I also had the same problem. My maven had tomcat7 plugin but the JRE environment was 1.6. I changed my tomcat7 to tomcat6 and the error was gone.


Examples related to java

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How much should a function trust another function How to implement a simple scenario the OO way Two constructors How do I get some variable from another class in Java? this in equals method How to split a string in two and store it in a field How to do perspective fixing? String index out of range: 4 My eclipse won't open, i download the bundle pack it keeps saying error log

Examples related to spring

Are all Spring Framework Java Configuration injection examples buggy? Two Page Login with Spring Security 3.2.x Access blocked by CORS policy: Response to preflight request doesn't pass access control check Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified Spring Data JPA findOne() change to Optional how to use this? After Spring Boot 2.0 migration: jdbcUrl is required with driverClassName The type WebMvcConfigurerAdapter is deprecated No converter found capable of converting from type to type

Examples related to spring-mvc

Two Page Login with Spring Security 3.2.x ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean Spring 5.0.3 RequestRejectedException: The request was rejected because the URL was not normalized The type WebMvcConfigurerAdapter is deprecated RestClientException: Could not extract response. no suitable HttpMessageConverter found Spring boot: Unable to start embedded Tomcat servlet container UnsatisfiedDependencyException: Error creating bean with name 8080 port already taken issue when trying to redeploy project from Spring Tool Suite IDE Error creating bean with name 'entityManagerFactory' defined in class path resource : Invocation of init method failed Difference between the annotations @GetMapping and @RequestMapping(method = RequestMethod.GET)

Examples related to tomcat7

Could not load the Tomcat server configuration INFO: No Spring WebApplicationInitializer types detected on classpath Name [jdbc/mydb] is not bound in this Context I cannot access tomcat admin console? Tomcat 7.0.43 "INFO: Error parsing HTTP request header" jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class Tomcat Server not starting with in 45 seconds HTTP Status 500 - Servlet.init() for servlet Dispatcher threw exception How to fix JSP compiler warning: one JAR was scanned for TLDs yet contained no TLDs? java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver