2010-12-22 88 views
0
<?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配置,爲什麼我在運行我的應用程序時出現錯誤。我的日誌文件夾爲空...Servlet調度程序當前不可用

[email protected] 
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 

但我已經加入春季的Web-MVC到不包含此類文件的類路徑中。

+0

請發佈導致問題的代碼,以便我們可以查找並發現錯誤(如果有) – mvg 2010-12-22 10:15:07

+0

請檢查服務器日誌,在您的$ TOMCAT_HOME/logs目錄中。通常你可以看到catalina.out,localhost - *。out中發生的事情。您是否將tomcat連接器jar添加到您的項目中? – ivy 2010-12-22 10:19:26

回答

4

但我已經加入春季的Web-MVC到包含此 類文件我 類路徑。

你是怎麼給你的CLASSPATH添加東西的?

如果您要創建一個Web應用程序,唯一適合的方法是將.class文件放在WEB-INF/classes下的WEB-INF/classes和.jar文件下。如果你做了其他任何事情,我會說這是錯誤的。不應該修改啓動腳本;本地環境變量將被忽略,並且不太可能在您部署到的服務器上設置。

UPDATE:

如果你告訴我,你所做的一切權利,根據您的IDE,我建議最後一個檢查:先看壓縮或展開WAR文件,您實際部署到Tomcat,使確保您可以看到錯誤提及的.class文件的JAR。如果它不是WAR的一部分,你必須弄清楚你的包裝出了什麼問題。如果您認爲JAR在那裏,請打開它並找到.class並檢查路徑。

你必須相信你看到的錯誤信息。不要說「我一切正常」,最好是說「我錯過了什麼?」

3

A ClassNotFoundException建議你不要在classpath上有Spring。確保它位於WAR的lib目錄中。

此外,請確保您的類路徑中也有commons-logging.jar。春天取決於此。

相關問題