Servlet调度程序目前不可用

时间:2010-12-22 10:08:17

标签: java spring

<?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"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" />

    <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql://127.0.0.1:3306/spring"/>
        <property name="username" value="monty"/>
        <property name="password" value="indian"/>
    </bean>

    <bean id="mySessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource" ref="myDataSource" />
        <property name="annotatedClasses">
            <list>
                <value>uk.co.vinoth.spring.domain.User</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.hbm2ddl.auto">create</prop>
            </props>
        </property>
    </bean>

    <bean id="myUserDAO" class="uk.co.vinoth.spring.dao.UserDAOImpl">
        <property name="sessionFactory" ref="mySessionFactory"/>
    </bean>

    <bean name="/user/*.htm" class="uk.co.vinoth.spring.web.UserController" >
        <property name="userDAO" ref="myUserDAO" />
    </bean>

</beans>

以上是我的bean配置,为什么我运行我的应用程序时会出错。我的日志文件夹是空的......

org.apache.catalina.loader.StandardClassLoader@122c9df
 org.springframework.web.servlet.DispatcherServlet
java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1436)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1282)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1068)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:966)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3996)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4266)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(StandardService.java:448)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
Dec 22, 2010 3:44:48 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /interMedix threw load() exception
java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1436)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1282)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1068)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:966)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3996)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4266)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(StandardService.java:448)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
Dec 22, 2010 3:44:48 PM org.apache.coyote.http11.Http11BaseProtocol start
INFO: Starting Coyote HTTP/1.1 on http-8181
Dec 22, 2010 3:44:48 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Dec 22, 2010 3:44:48 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/27  config=null
Dec 22, 2010 3:44:48 PM org.apache.catalina.storeconfig.StoreLoader load
INFO: Find registry server-registry.xml at classpath resource
Dec 22, 2010 3:44:49 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 558 ms
Dec 22, 2010 3:44:50 PM org.apache.catalina.core.StandardWrapperValve invoke
INFO: Servlet dispatcher is currently unavailable
Dec 22, 2010 3:50:18 PM org.apache.catalina.core.StandardWrapperValve invoke
INFO: Servlet dispatcher is currently unavailable

但我已将spring-web-mvc添加到包含此类文件的类路径中。

2 个答案:

答案 0 :(得分:4)

  

但是我已经将spring-web-mvc添加到我的   包含这个的类路径   类文件。

你是如何向CLASSPATH添加内容的?

如果您正在创建一个Web应用程序,唯一合适的方法是将.class文件放在WEB-INF / classes和WEB-INF / lib下的.jar文件下。如果你做了别的什么,我会说这是错的。不应该修改启动脚本;本地环境变量将被忽略,并且不太可能在您部署到的服务器上设置。

更新:

如果你告诉我你已经根据你的IDE做了一切,我建议你最后检查一下:查看你实际部署到Tomcat的压缩或爆炸的WAR文件,并确保你可以看到JAR使用错误提到的.class文件。如果它不是WAR的一部分,你必须弄清楚你的包装出了什么问题。如果你认为JAR在那里,打开它并找到.class并检查路径。

您必须相信您看到的错误消息。而不是说“我做的一切都是正确的”,最好说“我错过了什么?”

答案 1 :(得分:3)

ClassNotFoundException表示你在类路径上有Spring。确保它在WAR的lib目录中。

另外,请确保您的类路径中还有commons-logging.jar。春天取决于此。