• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Help needed with Simple Spring Application

 
Ranch Hand
Posts: 390
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to develop my first Spring web based application, but it seems I am not hitting the controller class. Do not know what I am doing wrong. Here are the codes I have in place

For the controller class

public class HomeController implements Controller {

private String title;

public void setTitle(String title)
{
this.title= title;
System.out.print("HomeController::setTitle--->title = "+title);
}
/* (non-Javadoc)
* @see org.springframework.web.servlet.mvc.Controller#handleRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
public ModelAndView handleRequest(HttpServletRequest request,
HttpServletResponse response) throws Exception {
// TODO Auto-generated method stub
return new ModelAndView("index", "title", title);
}

}


In my web.xml; I have something like

<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app 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"
version="2.4">
<description>Innoveation Medical Supplies</description>

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

<servlet-mapping>
<servlet-name>innovationmedicalsupplies</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>

</web-app>

and in my innovationmedicalsupplies-servlet.xml; I have

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">

<beans>
<bean id="simpleUrlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/index.htm">com.innovation.controller.HomeController</prop>
</props>
</property>
<property name="title">
<value>Innovation Medical Supplies</value>
</property>
</bean>

<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
</beans>
My innovationmedicalsupplies-servlet and my web.xml are in the WEB-INF directory.

During startup I have this exception been thrown in my log file
Dec 8, 2006 8:45:06 AM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /innovationmedicalsupplies threw load() exception
java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatchServlet
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1355)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1201)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1034)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:932)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3951)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4225)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
at org.apache.catalina.core.StandardService.start(StandardService.java:450)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:709)
at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)
Dec 8, 2006 8:45:07 AM org.apache.catalina.core.ApplicationContext log
INFO: org.apache.webapp.balancer.BalancerFilter: init(): ruleChain: [org.apache.webapp.balancer.RuleChain: [org.apache.webapp.balancer.rules.URLStringMatchRule: Target string: News / Redirect URL: ,]http://www.cnn.com], [org.apache.webapp.balancer.rules.RequestParameterRule: Target param name: paramName / Target param value: paramValue / Redirect URL: ,]http://www.yahoo.com], [org.apache.webapp.balancer.rules.AcceptEverythingRule: Redirect URL: ]]http://jakarta.apache.org]]
Dec 8, 2006 8:45:07 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Dec 8, 2006 8:45:07 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Dec 8, 2006 8:45:08 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Dec 8, 2006 8:45:08 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()

Though I have the spring.jar in my lib directory and this I suppose contains the DispatcherServlet

Any help would be appreciated.
Thanks,
Anselm.

[ December 08, 2006: Message edited by: Anselm Paulinus ]
[ December 08, 2006: Message edited by: Anselm Paulinus ]
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I see two possible problems;
First are you sure the jar is in your classpath ?
Two, check if your jar contains the spring-web.jar ? I think that the missing class is in this package and not in the common spring jar
 
Time is mother nature's way of keeping everything from happening at once. And this is a tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic