请关注我,因为我刚开始使用JSP并尝试运行我的第一个JSP应用程序。问题可能与this问题重复。我正在尝试运行一个现有的JSP项目。我导入了项目并构建了它。当我尝试使用 Run as - >运行时在服务器上运行它向我显示以下页面:
控制台显示完整的异常详细信息,如下所示:
Starting preview server on port 8080
Modules:
ssp (/ssp)
2014-09-25 14:04:47.983:INFO:oejs.Server:jetty-8.1.10.v20130312
2014-09-25 14:04:50.284:WARN:oejw.StandardDescriptorProcessor:Could not instantiate listener org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
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 sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:424)
at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:377)
at org.eclipse.jetty.server.handler.ContextHandler.loadClass(ContextHandler.java:1517)
at org.eclipse.jetty.webapp.StandardDescriptorProcessor.visitListener(StandardDescriptorProcessor.java:1839)
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.eclipse.jetty.webapp.IterativeDescriptorProcessor.visit(IterativeDescriptorProcessor.java:80)
at org.eclipse.jetty.webapp.IterativeDescriptorProcessor.process(IterativeDescriptorProcessor.java:67)
at org.eclipse.jetty.webapp.MetaData.resolve(MetaData.java:332)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1219)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:710)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:454)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:229)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
at org.eclipse.jetty.server.Server.doStart(Server.java:280)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at org.eclipse.wst.server.preview.internal.PreviewStarter.run(PreviewStarter.java:72)
at org.eclipse.wst.server.preview.internal.PreviewStarter.main(PreviewStarter.java:29)
2014-09-25 14:04:50.289:WARN:oejw.WebAppContext:Failed startup of context o.e.j.w.WebAppContext{/ssp,file:/C:/Users/Tejas/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/ssp/},C:/Users/Tejas/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/ssp
java.lang.reflect.InvocationTargetException
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.eclipse.jetty.webapp.IterativeDescriptorProcessor.visit(IterativeDescriptorProcessor.java:80)
at org.eclipse.jetty.webapp.IterativeDescriptorProcessor.process(IterativeDescriptorProcessor.java:67)
at org.eclipse.jetty.webapp.MetaData.resolve(MetaData.java:332)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1219)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:710)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:454)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:229)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
at org.eclipse.jetty.server.Server.doStart(Server.java:280)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at org.eclipse.wst.server.preview.internal.PreviewStarter.run(PreviewStarter.java:72)
at org.eclipse.wst.server.preview.internal.PreviewStarter.main(PreviewStarter.java:29)
Caused by:
java.lang.ClassCastException: org.eclipse.wst.server.preview.internal.WTPErrorHandler cannot be cast to org.eclipse.jetty.servlet.ErrorPageErrorHandler
at org.eclipse.jetty.webapp.StandardDescriptorProcessor.visitErrorPage(StandardDescriptorProcessor.java:1117)
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.eclipse.jetty.webapp.IterativeDescriptorProcessor.visit(IterativeDescriptorProcessor.java:80)
at org.eclipse.jetty.webapp.IterativeDescriptorProcessor.process(IterativeDescriptorProcessor.java:67)
at org.eclipse.jetty.webapp.MetaData.resolve(MetaData.java:332)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1219)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:710)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:454)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:229)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
at org.eclipse.jetty.server.Server.doStart(Server.java:280)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at org.eclipse.wst.server.preview.internal.PreviewStarter.run(PreviewStarter.java:72)
at org.eclipse.wst.server.preview.internal.PreviewStarter.main(PreviewStarter.java:29)
2014-09-25 14:04:50.328:INFO:oejs.AbstractConnector:Started SelectChannelConnector@0.0.0.0:8080
此post中提到的解决方案对我没有帮助,因为我无法在 Java构建路径条目中看到 Maven Dependencies 。另外,我不了解如何添加Spring库。请帮我运行我的应用程序。感谢。
答案 0 :(得分:0)
检查web.xml中的ContextListener:
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
这会导致错误。
答案 1 :(得分:0)
我想我可以提供帮助。
在“项目属性”中,查找Deployment Assembly
。点击Add
- > Java Build Path Entries
并添加您的Spring库。这样,Spring库将被打包到部署到J2EE服务器的程序集中。
如果您的Java Build Path上没有可用的Spring库,您可以尝试通过在文件系统中找到它来添加它。
答案 2 :(得分:0)
这基本上是由于找不到.class文件,即编译器找不到包含此类的jar(spring-web.jar)。为了解决这个问题,我们有很多解决方案,其中几个是
1.如果您使用的是maven,请将其添加到您的pom.xml
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.0.4.RELEASE</version>
</dependency>
注意:此place充当获取jar文件的中央存储库。
2.从Spring jar download下载。在应用程序中手动添加jar。
然后右键单击eclipse中的项目 - &gt; BuildPath - &gt;配置Build 路径 - &gt;选择库 - &gt;添加外部罐子(然后找到你的罐子 并添加它们。)