Servlet弹簧目前无法使用

时间:2012-01-21 00:58:33

标签: java spring java-ee servlets

我正在使用intellij,spring mvc和tiles。至少我在尝试:) 在tomcat上执行时出现此错误:

HTTP Status 503 - Servlet spring is currently unavailable
The requested service (Servlet spring is currently unavailable) is not currently available.

我真的不知道出了什么问题 这是tomcat输出:

cmd /c "C:\Program Files\apache-tomcat-6.0.35\bin\catalina.bat" run
Using CATALINA_BASE:   "C:\Documents and Settings\�€…˜\.IntelliJIdea10\system\tomcat\Unnamed_project"
Using CATALINA_HOME:   "C:\Program Files\apache-tomcat-6.0.35"
Using CATALINA_TMPDIR: "C:\Program Files\apache-tomcat-6.0.35\temp"
Using JRE_HOME:        "C:\Program Files\Java\jdk1.7.0_01"
Using CLASSPATH:       "C:\Program Files\apache-tomcat-6.0.35\bin\bootstrap.jar"
ינו 21, 2012 2:51:16 AM org.apache.catalina.core.AprLifecycleListener init
INFO: Loaded APR based Apache Tomcat Native library 1.1.22.
ינו 21, 2012 2:51:16 AM org.apache.catalina.core.AprLifecycleListener init
INFO: APR capabilities: IPv6 [false], sendfile [true], accept filters [false], random [true].
ינו 21, 2012 2:51:17 AM org.apache.coyote.http11.Http11AprProtocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
ינו 21, 2012 2:51:17 AM org.apache.coyote.ajp.AjpAprProtocol init
INFO: Initializing Coyote AJP/1.3 on ajp-8009
ינו 21, 2012 2:51:17 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 2135 ms
ינו 21, 2012 2:51:17 AM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
ינו 21, 2012 2:51:17 AM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.35
ינו 21, 2012 2:51:17 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor ROOT.xml
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/WorkingDirectory/Projects/GreenWheels/green-wheels-project/web-app-module/target/web-app-module/WEB-INF/lib/slf4j-log4j12-1.6.4.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/WorkingDirectory/Projects/GreenWheels/green-wheels-project/web-app-module/target/web-app-module/WEB-INF/lib/slf4j-nop-1.6.4.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
ינו 21, 2012 2:51:19 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory docs
ינו 21, 2012 2:51:19 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory examples
ינו 21, 2012 2:51:19 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory host-manager
ינו 21, 2012 2:51:19 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory manager
ינו 21, 2012 2:51:19 AM org.apache.coyote.http11.Http11AprProtocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
ינו 21, 2012 2:51:19 AM org.apache.coyote.ajp.AjpAprProtocol start
INFO: Starting Coyote AJP/1.3 on ajp-8009
ינו 21, 2012 2:51:19 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1967 ms
Connected to server

我的web.xml是:

<web-app
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    version="2.5">

    <display-name>Archetype Created Web Application</display-name>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

    <servlet>
        <servlet-name>spring</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>spring</servlet-name>
        <url-pattern>*.html</url-pattern>
    </servlet-mapping>
</web-app>

我的spring-servlet.xml是:

<?xml version="1.0" encoding="UTF-8"?>
<beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context
         http://www.springframework.org/schema/context/spring-context-3.0.xsd">

    <context:component-scan
        base-package="Success.GreenWheels.Controller" />

    <bean id="viewResolver"
        class="org.springframework.web.servlet.view.UrlBasedViewResolver">
        <property name="viewClass"
            value="org.springframework.web.servlet.view.tiles2.TilesView" />
        <property name="prefix" value="/WEB-INF/jsp/" />
        <property name="suffix" value=".jsp" />
    </bean>

    <bean id="tilesConfigurer"
        class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
        <property name="definitions">
            <list>
                <value>/WEB-INF/tiles.xml</value>
            </list>
        </property>
    </bean>
</beans>

我正在使用maven来加载依赖项。以下是我的依赖项:

<dependencies>
        <dependency>
            <groupId>success.green-wheels</groupId>
            <artifactId>domain-library-module</artifactId>
            <version>1</version>
        </dependency>

        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
            <version>1.8.3</version>
        </dependency>

        <dependency>
            <groupId>commons-digester</groupId>
            <artifactId>commons-digester</artifactId>
            <version>2.1</version>
        </dependency>

        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.1.1</version>
        </dependency>

        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.16</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.6.4</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.6.4</version>
        </dependency>

        <dependency>
            <groupId>org.apache.tiles</groupId>
            <artifactId>tiles-api</artifactId>
            <version>${org.apache.tiles}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.tiles</groupId>
            <artifactId>tiles-core</artifactId>
            <version>${org.apache.tiles}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.tiles</groupId>
            <artifactId>tiles-servlet</artifactId>
            <version>${org.apache.tiles}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.tiles</groupId>
            <artifactId>tiles-jsp</artifactId>
            <version>${org.apache.tiles}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.tiles</groupId>
            <artifactId>tiles-template</artifactId>
            <version>${org.apache.tiles}</version>
        </dependency>

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

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

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

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

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

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

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

我正在使用org.springframework.version = 3.1.0.RELEASEorg.apache.tiles = 2.2.2

有什么不对?

1 个答案:

答案 0 :(得分:0)

  

有什么不对?

我的猜测是Spring初始化失败。

但是,您提供的catalina.out文件中没有此证据。 OTOH,日志文件中的Spring中没有什么。所以我打赌你的webapp的日志记录配置已经设置为忽略所有Springs日志事件......或者将它们记录在其他地方。

无论如何,你需要那些证据才能找出真正的问题所在。所以我的建议是更改日志记录配置,以便Spring类的有效日志记录级别为DEBUG,并查看日志的内容。请注意, 会有很多DEBUG日志消息:如果您没有看到任何消息,那么仍然让日志记录配置错误。


实际上,还有其他一些可疑的东西:

  • catalina.out文件没有说明任何有关部署或启动您的网络应用的信息。

  • catalina.out文件似乎在说日志记录存在问题:

    SLF4J: Class path contains multiple SLF4J bindings.
    SLF4J: Found binding in [jar:file:/C:/WorkingDirectory/Projects/GreenWheels/green-wheels-project/web-app-module/target/web-app-module/WEB-INF/lib/slf4j-log4j12-1.6.4.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    SLF4J: Found binding in [jar:file:/C:/WorkingDirectory/Projects/GreenWheels/green-wheels-project/web-app-module/target/web-app-module/WEB-INF/lib/slf4j-nop-1.6.4.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
    

    看起来你的WAR文件包含两个SLF4J绑定JAR,其中一个用于“nop”绑定。我想,“nop”绑定的效果是通过SFL4J外观禁用所有日志记录......这就是Spring如何进行日志记录IIRC。