2013-06-20 153 views
1

我是新手,並試圖運行一個簡單的Spring MVC example.I添加了所有繼tutorialClassNotFoundException的:org.springframework.web.servlet.DispatcherServlet

的罐子,但我在運行時得到一個異常 java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet

我的jar包括DispatcherServlet類。

12:50:40,218 ERROR [[/Spring_MVC_20june]] Servlet /Spring_MVC_20june threw load() exception 
java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet 
    at java.net.URLClassLoader$1.run(Unknown Source) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.net.URLClassLoader.findClass(Unknown Source) 
    at java.lang.ClassLoader.loadClass(Unknown Source) 
    at java.lang.ClassLoader.loadClass(Unknown Source) 
    at org.jboss.web.tomcat.service.TomcatInjectionContainer.newInstance(TomcatInjectionContainer.java:262) 
    at org.jboss.web.tomcat.service.TomcatInjectionContainer.newInstance(TomcatInjectionContainer.java:256) 
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1006) 
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:950) 
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4122) 
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4421) 
    at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:310) 
    at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:142) 
    at org.jboss.web.deployers.AbstractWarDeployment.start(AbstractWarDeployment.java:461) 
    at org.jboss.web.deployers.WebModule.startModule(WebModule.java:118) 
    at org.jboss.web.deployers.WebModule.start(WebModule.java:97) 
    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.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157) 
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96) 
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) 
    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264) 
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668) 
    at org.jboss.system.microcontainer.ServiceProxy.invoke(ServiceProxy.java:206) 
    at $Proxy38.start(Unknown Source) 
    at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:42) 
    at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:37) 
    at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62) 
    at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71) 
    at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51) 
    at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348) 
    at org.jboss.system.microcontainer.ServiceControllerContext.install(ServiceControllerContext.java:286) 
    at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631) 
    at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934) 
    at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082) 
    at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984) 
    at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822) 
    at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553) 
    at org.jboss.system.ServiceController.doChange(ServiceController.java:688) 
    at org.jboss.system.ServiceController.start(ServiceController.java:460) 
    at org.jboss.system.deployers.ServiceDeployer.start(ServiceDeployer.java:163) 
    at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:99) 
    at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:46) 
    at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62) 
    at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50) 
    at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171) 
    at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439) 
    at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157) 
    at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178) 
    at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098) 
    at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348) 
    at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631) 
    at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934) 
    at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082) 
    at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984) 
    at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822) 
    at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553) 
    at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781) 
    at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702) 
    at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117) 
    at org.jboss.system.server.profileservice.hotdeploy.HDScanner.scan(HDScanner.java:362) 
    at org.jboss.system.server.profileservice.hotdeploy.HDScanner.run(HDScanner.java:255) 
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) 
    at java.util.concurrent.FutureTask$Sync.innerRunAndReset(Unknown Source) 
    at java.util.concurrent.FutureTask.runAndReset(Unknown Source) 
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(Unknown Source) 
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(Unknown Source) 
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
    at java.lang.Thread.run(Unknown Source) 
+1

您是否檢查過您的lib是否在war文件的WEB-INF/lib下? – Ioan

+0

2013年...不遵循不依賴於依賴管理工具的教程(例如Maven)。 –

+0

請參閱http://stackoverflow.com/questions/17423551/beginner-spring-mvc-with-eclipse-tomcat-not-loading-dispatcher-servlet – Raedwald

回答

0

這個問題是由於缺少庫引起的。所以確保這些庫位於你的類路徑中(將它們放在/ WEB-INF/lib文件夾中)。

相關問題