0

Please bear with me since I am beginner to JSP and trying to run my very first JSP application. The question may be possible duplicate of this question. I am trying to run one existing JSP project. I imported the project and built it. When I try to run using Run as -> Run on server it shows me following page:

enter image description here

Console shows the complete exception details as follows:

    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

The solution mentioned on the this post didn't help me since I am unable to see Maven Dependencies in Java Build Path Entries. Also I don't understand how to add Spring libraries. Please help me to run my application. Thanks.

Community
  • 1
  • 1
Tejas Sutar
  • 747
  • 2
  • 11
  • 33
  • Try adding Spring jar files to your lib directory, redeploy and start the application. – Swaraj Sep 25 '14 at 09:25
  • Actually the project I am working on is the Maven project. So I expect Maven to manage all required jar files. How can I do that? If that's not possible, when can I get these jar files from? – Tejas Sutar Sep 25 '14 at 09:28
  • org.springframework spring 2.5.6 '.. Try this by adding to maven file. – Swaraj Sep 25 '14 at 09:31

3 Answers3

0

check your ContextListener in web.xml:

java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

This cause error.

Phong Nguyen
  • 277
  • 4
  • 16
0

I think I can help.

In the Project Properties, look for Deployment Assembly. Click Add -> Java Build Path Entries and add your Spring library. This way the Spring library will be packaged into the assembly deployed to your J2EE server.

If you don't have the Spring library available on your Java Build Path, you can try adding it by finding it in your filesystem.

Davio
  • 4,609
  • 2
  • 31
  • 58
0

This is basically due to the .class file not found,i.e the jar(spring-web.jar) that containing this class is not found by the compiler.To resolve this we have many solutions,couple of them are

1.If you are using maven please add this to your pom.xml

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>3.0.4.RELEASE</version>
</dependency>

Note: This place acts as the central repository for getting jar file.

2.Add jar manually in the application by downloading from Spring jar download.

Then Right click the project in eclipse -> BuildPath ->Configure Build Path -> Select libraries --> Add external jars (Then locate your jar's and add them).

prem
  • 843
  • 1
  • 8
  • 21