Solved

Spring application error

Posted on 2013-06-11
9
1,067 Views
Last Modified: 2013-06-12
Hello,

I was trying to run the sample application. here is the snapshot of it.
I have added all the jars from the spring-framework-3.0.5.RELEASE.
 and the set the jars in the web-inf/lib. But it is not working . here is my  snapshot with the code.

can somebody tell what is the issue on it. when it runs it tells me something like time out  in the tomcat when i set it in the web-inf/lib through deployment assembly of the eclipse
other wise it gives me another error

=============
SEVERE: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1713)
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1558)
      at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:527)
      at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:509)
      at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:137)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4823)
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5381)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
      at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
      at java.util.concurrent.FutureTask.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)



thanks

rosy
spring.docx
0
Comment
Question by:roy_sanu
  • 4
  • 4
9 Comments
 
LVL 35

Expert Comment

by:mccarl
ID: 39239988
In the screenshots attached, the "Libraries" entry in the project tree is not expanded. What is in there? This is where you would need to add the Spring jar files.

To add them, right-click on your project (the top-level item in that tree for your project, not the 'Libraries' entry itself) and then select "Build Path"->"Configure Build Path..."  From here you can add JAR's to the project so that they will be included by Tomcat when running your project.
0
 
LVL 21

Expert Comment

by:Amitkumar Panchal
ID: 39240034
Solution is on the same site which you referred for your application :)

Refer http://www.mkyong.com/spring/spring-error-classnotfoundexception-org-springframework-web-context-contextloaderlistener/
0
 

Author Comment

by:roy_sanu
ID: 39240088
Here is the attachment of  the spring libraries, but i get the same error when i run
http://localhost:8080/SpringExample1/welcome

here is the snapshot

is it any of the jar is missing.........

when i try to add the jars to the WEB-INF/lib through deployment assembly of eclipse

it gave me these errors

SEVERE: Context initialization failed
java.lang.NoSuchMethodError: org.springframework.web.context.ConfigurableWebApplicationContext.setId(Ljava/lang/String;)V
      at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:264)
      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4887)
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5381)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
      at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
      at java.util.concurrent.FutureTask.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)
12 Jun, 2013 10:29:32 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.NoSuchMethodError: org.springframework.web.context.ConfigurableWebApplicationContext.setId(Ljava/lang/String;)V
      at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:264)
      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4887)
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5381)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
      at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
      at java.util.concurrent.FutureTask.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)
12 Jun, 2013 10:29:32 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
12 Jun, 2013 10:29:32 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/SpringExample1] startup failed due to previous errors
12 Jun, 2013 10:29:32 AM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
12 Jun, 2013 10:29:32 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
12 Jun, 2013 10:29:32 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
12 Jun, 2013 10:29:32 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 5921 ms




Thanks
rosy
Spring-library.docx
0
 
LVL 35

Accepted Solution

by:
mccarl earned 500 total points
ID: 39240145
You have version conflicts, hence why you get the "NoSuchMethodError". Remove the spring-2.5.6.jar from the libraries so that everything is at version 3.0.5. Also, you still appear to have different naming of version 3.0.5 jars which you may need to sort out, but it is hard to see exactly what you have with just that screenshot. But try just removing the 3.5.6 version first!
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:roy_sanu
ID: 39240210
Thanks, there is no such above error, removed the spring.2.5.6
I am getting error  as

" No mapping found for HTTP request with URI [/SpringExample1/] in DispatcherServlet with name 'mvc-dispatcher' "

I have two xml file such as web.xml and mvc-dispatcher.xml which is in WEB-INF.              is it  i  have to set the  mvc-dispatcher.xml in the classpath ?

or i have to add to the src ????

my mvc-dispatcher.xml contains
=====================================================

<beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="
        http://www.springframework.org/schema/beans     
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-3.0.xsd">

      <context:component-scan base-package="com.mkyong.common.controller" />

      <bean
            class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="prefix">
                  <value>/WEB-INF/pages/</value>
            </property>
            <property name="suffix">
                  <value>.jsp</value>
            </property>
      </bean>
==========================================================================
my web.xml contains below
==========================================================================
<web-app id="WebApp_ID" version="2.4"
      xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
      http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

      <display-name>Spring Web MVC Application</display-name>

 
      <servlet>
            <servlet-name>mvc-dispatcher</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <load-on-startup>1</load-on-startup>
      </servlet>

      <servlet-mapping>
            <servlet-name>mvc-dispatcher</servlet-name>
            <url-pattern>/</url-pattern>
      </servlet-mapping>

      <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/mvc-dispatcher-servlet.xml</param-value>
      </context-param>

      <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      </listener>

</web-app>
==========================================================================


</beans>
0
 
LVL 35

Expert Comment

by:mccarl
ID: 39240286
This is your web.xml file...

...
      <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/mvc-dispatcher-servlet.xml</param-value>
      </context-param>
...


But you are saying that your beans are in mvc-dispatcher.xml ?  The value in your web.xml file needs to be exactly what the name of the .xml file is
0
 

Author Comment

by:roy_sanu
ID: 39240889
i got it copied from the site

http://www.mkyong.com/spring3/spring-3-mvc-hello-world-example/
it have used  the same name as it is being specified

but i changed the some thing better name as spring-servlet.xml  but as one need to have  servlet as an extension to the name as some other spring mvc sites also refer the same...

let me try from some other web site like
http://viralpatel.net/blogs/spring-3-mvc-create-hello-world-application-spring-3-mvc/
let me see if things works on it......
well at present i do not get any error but also i do not get the output. also.. :)

Thanks
0
 

Author Comment

by:roy_sanu
ID: 39242095
thanks for the help it is working....
0
 
LVL 35

Expert Comment

by:mccarl
ID: 39243554
Not a problem, gald to help!
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Protect jar file - windows app 2 39
Java asynchronous logging 4 50
Eclipse IDE - Cannot copy/paste from console output 8 132
eclipse formatting 6 73
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now