[英]Class Not found : org.springframework.web.servlet.DispatcherServlet
In spring-hibernate project, I have added all jars required in some User created library in eclipse.在 spring-hibernate 项目中,我在 eclipse 中添加了一些用户创建的库中所需的所有 jars。 But still it is giving the exception that, ServletDispatcher is not available.但它仍然给出了一个例外,即 ServletDispatcher 不可用。 Below all jar files included are shown, just help me which one I left.下面显示了包含的所有 jar 文件,请帮我看看我留下了哪一个。
org.springframework.aop-3.0.4.RELEASE.jar
org.springframework.asm-3.0.4.RELEASE.jar
org.springframework.aspects-3.0.4.RELEASE.jar
org.springframework.beans-3.0.4.RELEASE.jar
org.springframework.context.support-3.0.4.RELEASE.jar
org.springframework.context-3.0.4.RELEASE.jar
org.springframework.core-3.0.4.RELEASE.jar
org.springframework.expression-3.0.4.RELEASE.jar
org.springframework.instrument.tomcat-3.0.4.RELEASE.jar
org.springframework.instrument-3.0.4.RELEASE.jar
org.springframework.jdbc-3.0.4.RELEASE.jar
org.springframework.jms-3.0.4.RELEASE.jar
org.springframework.orm-3.0.4.RELEASE.jar
org.springframework.oxm-3.0.4.RELEASE.jar
org.springframework.test-3.0.4.RELEASE.jar
org.springframework.transaction-3.0.4.RELEASE.jar
org.springframework.web.portlet-3.0.4.RELEASE.jar
org.springframework.web.servlet-3.0.4.RELEASE.jar
org.springframework.web.struts-3.0.4.RELEASE.jar
org.springframework.web-3.0.4.RELEASE.jar
hibernate3.jar
jstl.jar
standard.jar
org.springframework.webflow-2.2.1.RELEASE.jar
StackTrace is:堆栈跟踪是:
SEVERE: Servlet /PersonLoanManegment threw load() exception
java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:525)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:507)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:124)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1136)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5015)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5302)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1566)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1556)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
I found adding to the POM:我发现添加到 POM:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring-framework.version}</version>
</dependency>
Added the needing file and IntelliJ was able to resolve the DispatcherServlet.添加了需要的文件,IntelliJ 能够解析 DispatcherServlet。
You need jar spring-web-3.0.4.RELEASE.jar in your classpath.您的类路径中需要 jar spring-web-3.0.4.RELEASE.jar。 With Maven:使用 Maven:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.0.4.RELEASE</version>
</dependency>
Regards问候
You need jar org.springframework.web.servlet-3.0.4.RELEASE.jar
in your classpath.您的类路径中需要 jar org.springframework.web.servlet-3.0.4.RELEASE.jar
。 Which contains org.springframework.web.servlet.DispatcherServlet
其中包含org.springframework.web.servlet.DispatcherServlet
Maybe, it's not because you lost dependency configuration.也许,这不是因为您丢失了依赖项配置。 you should check whether the jar is really available, follow this:您应该检查jar是否真的可用,请按照以下步骤操作:
package your project, then unzip it, check: /WEB-INF/lib, see if the org.springframework.web.servlet-3.0.4.RELEASE.jar exists!打包你的项目,然后解压,检查:/WEB-INF/lib,查看org.springframework.web.servlet-3.0.4.RELEASE.jar是否存在! if yes, unzip this jar, see if it's corrupt!如果是,请解压这个 jar,看看它是否已损坏! it it's not existing or corrupt, check your maven repository, you can remove this artifact from your maven repository, and rebuild, let maven re-download it.如果它不存在或损坏,请检查您的 Maven 存储库,您可以从 Maven 存储库中删除此工件,然后重建,让 Maven 重新下载它。 Good luck!祝你好运!
This is a very old question这是一个很老的问题
According to an article I read "Most probably the necessary Spring MVC related jar files are not loaded and deployed on tomcat startup. But note: these files are in your classpath and hence you are not getting any error in Eclipse IDE during development time. Happens only during runtime."根据我读过的一篇文章“很可能在 tomcat 启动时没有加载和部署必要的 Spring MVC 相关 jar 文件。但请注意:这些文件在您的类路径中,因此您在开发期间在 Eclipse IDE 中没有收到任何错误。发生了仅在运行时。”
This is how I resolved mine:我是这样解决我的:
Clean the project and you are good to go.清理项目,你就可以开始了。
每当您遇到 ClassNotFound 异常时,请尝试使用jarFinder等各种在线工具查找丢失的 jar
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.