web-dev-qa-db-fra.com

Aucun type Spring WebApplicationInitializer détecté sur le chemin d'accès aux classes

Mon projet Eclipse ne se déploie soudainement plus correctement. Je ne peux pas le retracer à un changement particulier que j'ai apporté à l'environnement.

J'ai testé avec plusieurs projets contrôlés par la source et ils se comportent tous de la même manière:

May 01, 2013 12:00:45 PM org.Apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in     production environments was not found on the Java.library.path: C:\Program Files   (x86)\Java\jdk1.7.0_11\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files (x86)\NVIDIA     Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows \System32\WindowsPowerShell\v1.0\;.
May 01, 2013 12:00:45 PM org.Apache.Tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.Eclipse.jst.jee.server:fismacm' did not find a matching property.
May 01, 2013 12:00:45 PM org.Apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
May 01, 2013 12:00:45 PM org.Apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
May 01, 2013 12:00:45 PM org.Apache.catalina.startup.Catalina load
INFO: Initialization processed in 296 ms
May 01, 2013 12:00:45 PM org.Apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
May 01, 2013 12:00:45 PM org.Apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.35
May 01, 2013 12:00:46 PM org.Apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
May 01, 2013 12:00:48 PM org.Apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://Java.Sun.com/jstl/core is already defined
May 01, 2013 12:00:48 PM org.Apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://Java.Sun.com/jstl/sql_rt is already defined
May 01, 2013 12:00:48 PM org.Apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://Java.Sun.com/jsp/jstl/sql is already defined
May 01, 2013 12:00:48 PM org.Apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://Java.Sun.com/jstl/core_rt is already defined
May 01, 2013 12:00:48 PM org.Apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://Java.Sun.com/jsp/jstl/core is already defined
May 01, 2013 12:00:48 PM org.Apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://Java.Sun.com/jsp/jstl/functions is already defined
May 01, 2013 12:00:48 PM org.Apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://Java.Sun.com/jstl/fmt is already defined
May 01, 2013 12:00:48 PM org.Apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.Apache.org/taglibs/standard/permittedTaglibs is already defined
May 01, 2013 12:00:48 PM org.Apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://Java.Sun.com/jstl/xml is already defined
May 01, 2013 12:00:48 PM org.Apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.Apache.org/taglibs/standard/scriptfree is already defined
May 01, 2013 12:00:48 PM org.Apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://Java.Sun.com/jstl/fmt_rt is already defined
May 01, 2013 12:00:48 PM org.Apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://Java.Sun.com/jsp/jstl/fmt is already defined
May 01, 2013 12:00:48 PM org.Apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://Java.Sun.com/jsp/jstl/xml is already defined
May 01, 2013 12:00:48 PM org.Apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://Java.Sun.com/jstl/xml_rt is already defined
May 01, 2013 12:00:48 PM org.Apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://Java.Sun.com/jstl/sql is already defined
May 01, 2013 12:00:48 PM org.Apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://www.springframework.org/tags/form is already defined
May 01, 2013 12:00:48 PM org.Apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://www.springframework.org/tags is already defined
May 01, 2013 12:00:48 PM org.Apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://www.springframework.org/security/tags is already defined
May 01, 2013 12:00:48 PM org.Apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
May 01, 2013 12:00:48 PM org.Apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
May 01, 2013 12:00:48 PM org.Apache.catalina.core.ApplicationContext log
INFO: Set web app root system property: 'webapp.root' =     [X:\workspace\.metadata\.plugins\org.Eclipse.wst.server.core\tmp0\wtpwebapps\fismacm\]
May 01, 2013 12:00:48 PM org.Apache.catalina.core.ApplicationContext log
INFO: Initializing log4j from [X:\workspace\.metadata\.plugins\org.Eclipse.wst.server.core\tmp0\wtpwebapps\fismacm\WEB-    INF\log4j.properties]
May 01, 2013 12:00:48 PM org.Apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
May 01, 2013 12:00:49 PM org.Apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
May 01, 2013 12:00:49 PM org.Apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
May 01, 2013 12:00:49 PM org.Apache.catalina.startup.Catalina start
INFO: Server startup in 3898 ms

Cela ressemble au composant clé suivant: INFO: Aucun type Spring WebApplicationInitializer détecté sur classpath. 

J'ai essayé de nettoyer les projets, de redéfinir les serveurs et même de créer de nouveaux espaces de travail. J'ai clairement raté la cible.

Tous les conseils pour le nettoyage seront grandement appréciés. 

15
Raevik

Cela s'est avéré être une erreur stupide. Mon log4j n'a pas été configuré pour capturer ma sortie d'erreur. Je jetais des erreurs de configuration en arrière-plan et une fois que je les corrigeais, j'étais prêt à partir et les mappages de demandes fonctionnaient bien.

10
Raevik

J'ai passé des heures à cela et la solution était:

  • Arrêtez Tomcat
  • Menu "Projet" -> Nettoyer -> Nettoyer tous les projets
  • Onglet Serveurs -> Tomcat -> Clic droit -> Nettoyer ...
  • Faites un clic droit sur le projet -> Exécuter en tant que -> Exécuter sur le serveur
14
Adrian Smith

Faites attention si vous utilisez Maven. La structure de votre dossier doit avoir raison.

Lorsque vous utilisez Maven, le répertoire WEB-INF doit se trouver dans webapp :

src/main/webapp/WEB-INF
7
Rafael Delbel

INFO: Aucun type Spring WebApplicationInitializer détecté sur le chemin d'accès aux classes.

Peut également apparaître si vous utilisez Maven avec Eclipse et déployez votre fichier WAR avec:

(Eclipse, Kepler, avec M2)

(clic droit sur votre projet) -> Exécuter en tant que -> Exécuter sur le serveur

Il en va de la génération et de la suppression du dossier m2e-wtp et de son contenu.

Assurez-vous que Maven Archive les fichiers générés dans le répertoire de construction est cochée.

Sous: "Fenêtre -> Préférences -> Maven -> Intégration Java EE"

Ensuite:

Utilisez M2 pour faire votre construction, c’est-à-dire l’habillage habituel Clean -> package ou Install etc ...

Si "Projet -> Construire automatiquement" n'est pas sélectionné . Vous pouvez forcer la génération "Dossier m2e-wtp et son contenu" en faisant cela;

" (clic droit sur votre projet) -> Maven -> Mettre à jour le projet ... "

Remarque: assurez-vous que l'option "Nettoyer les projets" n'est pas sélectionnée. Sinon, le contenu de la cible/des classes sera supprimé et vous revenez à la case départ.

Aussi, quand;

" Projet -> Construire automatiquement " est sélectionné, le "dossier m2e-wtp et son contenu" sont générés.

ou " Projet -> Construire tout "

ou " (clic droit sur le projet) -> Construire le projet "

4
denOfProgramming

WebApplicationInitializer est une interface que vous pouvez implémenter dans l'une de vos classes. Au démarrage, Spring recherche ces classes tant que vous utilisez la servlet spéc 3 et que vous avez un attribut metadata-complete = "false" dans votre fichier web.xml. Mais cela ne semble pas être le problème. La seule erreur que je peux comprendre est le fichier slf4j-log4j12.jar manquant.

2
Stefan

J'ai aussi eu le même problème. Mon maven avait Tomcat7 plugin mais l'environnement JRE était de 1,6. J'ai changé mon Tomcat7 en Tomcat6 et l'erreur a disparu.

1
Akshay

xml n’était pas dans le dossier WEB-INF, c’est pourquoi j’obtenais cette erreur. Assurez-vous que web.xml et xxx-servlet.xml se trouvent dans le dossier WEB_INF et non dans le dossier webapp.

0
Vishal jotshi

J'ai eu une erreur idiote qu'il m'a fallu un temps embarrassant à résoudre ... Regardez mon pom.xml ... 

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.Apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.Apache.org/POM/4.0.0 http://maven.Apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.outbottle</groupId>
<artifactId>PersonalDetailsMVC</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>

<name>PersonalDetailsMVC</name>

<properties>
    <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <spring.version>4.0.1.RELEASE</spring.version>
    <jstl.version>1.2</jstl.version>
    <javax.servlet.version>3.0.1</javax.servlet.version>
</properties>

<dependencies>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>7.0</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>${javax.servlet.version}</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>jstl</groupId>
        <artifactId>jstl</artifactId>
        <version>${jstl.version}</version>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.Apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                <compilerArguments>
                    <endorseddirs>${endorsed.dir}</endorseddirs>
                </compilerArguments>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.Apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.Apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.6</version>
            <executions>
                <execution>
                    <phase>validate</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${endorsed.dir}</outputDirectory>
                        <silent>true</silent>
                        <artifactItems>
                            <artifactItem>
                                <groupId>javax</groupId>
                                <artifactId>javaee-endorsed-api</artifactId>
                                <version>7.0</version>
                                <type>jar</type>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Le problème était le nom de mon colis. Il DOIT être "com.outbottle" (puis config/controllers/model/etc) pour que cela fonctionne. Comme vous pouvez le voir ci-dessus, j’ai utilisé Maven (pour la première fois), Spring, 1.8 JDK et j’ai presque eu un accident de débogage pour résoudre ce problème. Tout fonctionne sur Glassfish (Tomcat est également correct pour la configuration de pom ci-dessus). Cela dit, je suis tout à fait satisfait de moi-même et je connais beaucoup Maven et Spring pour la prochaine étape de ma courbe d’apprentissage du printemps. En espérant que cela vous aide aussi!

0
John Mulhall

STS a un dossier de métadonnées sous son espace de travail. Vous verrez l'erreur réelle dans le fichier .log sous C:\Utilisateurs\prénom.nom\Documents\workspace-sts-3.9.2.RELEASE.metadata

0
8080_HouseFull