Servlet spring 目前不可用

发布于 2024-12-28 07:37:37 字数 10568 浏览 0 评论 0原文

我正在使用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.RELEASE 和 org.apache.tiles = 2.2.2

可能出了什么问题?

I am using intellij, spring mvc and tiles. At least I am trying :)
I get this error when executing on tomcat:

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

I really don't know what is wrong.
Here is the tomcat output:

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

My web.xml is:

<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>

My spring-servlet.xml is:

<?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>

I am using maven in order to load dependencies. Here are my dependencies:

<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>

I am using org.springframework.version = 3.1.0.RELEASE and org.apache.tiles = 2.2.2

What can be wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独留℉清风醉 2025-01-04 07:37:37

可能出了什么问题?

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

但是,您提供的 catalina.out 文件中没有证据证明这一点。 OTOH,日志文件中没有任何来自 Spring 的内容。所以我敢打赌,您的 web 应用程序的日志记录配置已设置为忽略所有 Springs 日志事件......或将它们记录在其他地方。

无论如何,您需要证据来找出真正的问题是什么。所以我的建议是更改日志配置,使 Spring 类的有效日志级别为 DEBUG,然后查看日志内容。请注意,将会有很多DEBUG日志消息:如果您没有看到任何消息,那么您仍然日志配置有误。


实际上,还有其他一些可疑的事情:

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

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

    SLF4J:类路径包含多个 SLF4J 绑定。
    SLF4J:在 [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:在 [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:请参阅 http://www.slf4j.org/codes.html#multiple_bindings 了解说明。
    

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

What can be wrong?

My guess is that Spring initialization failed.

However, there is no evidence for this in the catalina.out file you provided. OTOH, there is nothing whatsoever from Spring in the logfile. So I'm betting that your webapp's logging configuration have been set up to ignore all of Springs log events ... or to log them somewhere else.

Anyway, you need that evidence to find out what the real problem is. So my advice is to change the logging configs so that the effective logging level for Spring classes is DEBUG, and see what the logs say. Note, there will be a lot of DEBUG log messages: if you don't see any then you've still got the logging configs wrong.


Actually, there's a couple of other fishy things:

  • The catalina.out file doesn't say anything about deploying or starting your webapp.

  • The catalina.out file seems to be saying that there's a problem with the logging:

    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.
    

    It looks like your WAR file contains two SLF4J binding JARs, and that one of them is for the "nop" binding. I imagine that the effect of the "nop" binding is to disable all logging via the the SFL4J facade ... and that's how Spring does its logging IIRC.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文