Meaningless Drivel is fun!*
The moose likes Spring and the fly likes Spring WEB MVC 3.0  using org.springframework.jdbc.core.simple.SimpleJdbcDaoSupport Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring WEB MVC 3.0  using org.springframework.jdbc.core.simple.SimpleJdbcDaoSupport" Watch "Spring WEB MVC 3.0  using org.springframework.jdbc.core.simple.SimpleJdbcDaoSupport" New topic
Author

Spring WEB MVC 3.0 using org.springframework.jdbc.core.simple.SimpleJdbcDaoSupport

Dushyant Chhetri
Ranch Hand

Joined: Oct 28, 2009
Posts: 75
Hi All,

I am trying a basic tutorial to write a Web MVC Spring applicationusing Spring 3

In short
an html form is used to capture some i/p data and the Spring classes using SimpleJdbcDaoSupport is trying to push the data to some DB table.

I have my project structure as attached image.

My xml files are as follows:

web.xml


dispatcher-servlet.xml


applicationContext.xml


On trying to execute I am getting an error as :

SEVERE: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'personsDao' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'jdbcTemplateBean' while setting bean property 'jdbcTemplate'; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.jdbc.core.jdbcTemplate] for bean with name 'jdbcTemplateBean' defined in ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.jdbc.core.jdbcTemplate
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1305)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1067)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:557)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:842)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:416)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:261)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:192)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
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:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.jdbc.core.jdbcTemplate] for bean with name 'jdbcTemplateBean' defined in ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.jdbc.core.jdbcTemplate
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1208)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:427)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
... 30 more
Caused by: java.lang.ClassNotFoundException: org.springframework.jdbc.core.jdbcTemplate
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:258)
Dushyant Chhetri
Ranch Hand

Joined: Oct 28, 2009
Posts: 75
attachments,



[Thumbnail for structure_project.JPG]

[Thumbnail for lib.JPG]

Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1632
    
    7

java.lang.ClassNotFoundException: org.springframework.jdbc.core.jdbcTemplate


Are you not using maven? If not I would. Apparently you do not have spring-jdbc jar on the classpath.

You can get the maven info or download the jar from this link.
http://mvnrepository.com/artifact/org.springframework/spring-jdbc


[How To Ask Questions][Read before you PM me]
Dushyant Chhetri
Ranch Hand

Joined: Oct 28, 2009
Posts: 75
Hi Thanks,

Seems funny but the error was just a typo.

I had typed in


instead of


in the applicationContext.xml file

 
 
subject: Spring WEB MVC 3.0 using org.springframework.jdbc.core.simple.SimpleJdbcDaoSupport
 
Similar Threads
Spring DI help
No unique bean of type [javax.persistence.EntityManagerFactory] is defined: expected single bean but
Context initialization failed ----org.springframework.beans.factory.BeanCreationException: Error cre
problem while loading the welcome page
Error with Spring 3.0 in deployment.