Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Spring
Search Coderanch
Advance search
Google search
Register / Login
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
Jeanne Boyarsky
Ron McLeod
Liutauras Vilda
Paul Clapham
Sheriffs:
paul wheaton
Tim Cooke
Henry Wong
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Piet Souris
Bartenders:
Mike London
Forum:
Spring
Error while instantiating JdbcTemplate in spring-config.xml?
Vish Joshi
Greenhorn
Posts: 16
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
here is the spring-config.xml i am using-
<beans xmlns="http://www.springframework.org/schema/beans" 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.xsd"> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName"> <value>com.mysql.jdbc.Driver</value> </property> <property name="url"> <value>jdbc:mysql://localhost:3306/SpringDao</value> </property> <property name="username"> <value>root</value> </property> <property name="password"> <value>root</value> </property> </bean> <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> <constructor-arg type="javax.sql.DataSource"><ref bean="dataSource"></ref></constructor-arg> </bean> <bean id="customerDAOImpl" class="dao.CustomerDAOImpl"> <property name="jdbcTemplate" ref="jdbcTemplate"/> </bean> </beans> [color=#444444][/color] I am getting the following error while executing the project- [color=red][/color] Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdbcTemplate' defined in class path resource [spring-config.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.jdbc.core.JdbcTemplate]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.springframework.beans.factory.ListableBeanFactory.getBeanDefinitionNames(Ljava/lang/Class;)[Ljava/lang/String; at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:254) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:925) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:835) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) at client.JavaClient.main(JavaClient.java:22) Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.jdbc.core.JdbcTemplate]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.springframework.beans.factory.ListableBeanFactory.getBeanDefinitionNames(Ljava/lang/Class;)[Ljava/lang/String; at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:115) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87) at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:248) ... 17 more Caused by: java.lang.NoSuchMethodError: org.springframework.beans.factory.ListableBeanFactory.getBeanDefinitionNames(Ljava/lang/Class;)[Ljava/lang/String; at org.springframework.jdbc.support.SQLErrorCodesFactory.<init>(SQLErrorCodesFactory.java:110) at org.springframework.jdbc.support.SQLErrorCodesFactory.<clinit>(SQLErrorCodesFactory.java:71) at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.setDataSource(SQLErrorCodeSQLExceptionTranslator.java:99) at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.<init>(SQLErrorCodeSQLExceptionTranslator.java:88) at org.springframework.jdbc.support.JdbcAccessor.getExceptionTranslator(JdbcAccessor.java:74) at org.springframework.jdbc.support.JdbcAccessor.afterPropertiesSet(JdbcAccessor.java:87) at org.springframework.jdbc.core.JdbcTemplate.<init>(JdbcTemplate.java:115) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:100) ... 19 more
Mark Spritzler
ranger
Posts: 17347
11
I like...
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Here is your error
Caused by: java.lang.NoSuchMethodError: org.springframework.beans.factory.ListableBeanFactory.getBeanDefinitionNames(Ljava/lang/Class;)
Which to me means that your configuration looks fine. But how are you starting up Spring. What does your code look like.
Mark
Perfect World Programming, LLC
-
iOS Apps
How to Ask Questions the Smart Way FAQ
apurav chauhan
Greenhorn
Posts: 21
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Are you migrating the spring to some other version.
Check this:
https://jira.springsource.org/browse/SPR-4823
Vish Joshi
Greenhorn
Posts: 16
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I have resolved the problem..it was commons-logging.jar's version problem!
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Spring DI help
Spring AOP HELP needed
Spring+Hibernate can't create SessionFactory bean
java.lang.VerifyError,runtime exception,can anyone explain when or why get this runtime exception
Getting Error in setting property values
More...