春天例外

时间:2010-06-25 22:55:06

标签: spring spring-mvc

我正在学习本教程http://static.springsource.org/docs/Spring-MVC-step-by-step/part4.html以尝试学习Spring。

一切正常但是当我得到part4并在4.3节进行了更改时,我得到了一个运行时异常

        SEVERE: Context initialization failed
        org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.spring.springframework.web.servlet.view.InternalResourceViewResolver] for bean with name 'viewResolver' defined in ServletContext resource [/WEB-INF/springapp-servlet.xml]; nested exception is java.lang.ClassNotFoundException: org.spring.springframework.web.servlet.view.InternalResourceViewResolver
                at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1141)
                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:524)
                at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1177)
                at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:758)
                at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:422)
                at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
                at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
                at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:402)
                at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:316)
                at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:282)
                at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:126)
                at javax.servlet.GenericServlet.init(GenericServlet.java:212)
                at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
                at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
                at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4187)
                at org.apache.catalina.core.StandardContext.start(StandardContext.java:4496)
                at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
                at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
                at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
                at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1041)
                at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:964)
                at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)
                at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
                at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
                at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
                at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
                at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
                at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
                at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
                at org.apache.catalina.core.StandardService.start(StandardService.java:519)
                at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
                at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:597)
                at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
                at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
        Caused by: java.lang.ClassNotFoundException: org.spring.springframework.web.servlet.view.InternalResourceViewResolver
                at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516)
                at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361)
                at org.springframework.util.ClassUtils.forName(ClassUtils.java:211)
                at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:385)
                at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1138)
                ... 37 more
        25-Jun-2010 23:50:52 org.apache.catalina.startup.HostConfig deployDirectory
        INFO: Deploying web application directory xwiki
        25-Jun-2010 23:50:55 org.apache.coyote.http11.Http11Protocol start
        INFO: Starting Coyote HTTP/1.1 on http-8080
        25-Jun-2010 23:50:55 org.apache.jk.common.ChannelSocket init
        INFO: JK: ajp13 listening on /0.0.0.0:8009
        25-Jun-2010 23:50:55 org.apache.jk.server.JkMain start

我不认为它是丢失jar文件或类路径问题的问题,因为它没有在xml文件中指定的bean属性时工作正常。 我不确定为什么会这样,所以任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:1)

如果你正在使用spring 3.0,那么你可能错过了org.springframework.web.servlet jar,或者如果你正在使用spring-webmvc jar(应该在spring 2.5发行版中的\ dist \ modules \中) 2.5