File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Frameworks
»
Spring
Author
Error while instantiating JdbcTemplate in spring-config.xml?
Vish Joshi
Greenhorn
Joined: Dec 22, 2010
Posts: 16
posted
Aug 25, 2011 23:39:02
0
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
Sheriff
Joined: Feb 05, 2001
Posts: 17233
1
I like...
posted
Aug 27, 2011 14:36:07
0
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
-
Two Laptop Bag
-
Tube Organizer
How to Ask Questions the Smart Way FAQ
apurav chauhan
Greenhorn
Joined: Aug 07, 2010
Posts: 21
posted
Aug 28, 2011 11:13:55
0
Are you migrating the spring to some other version.
Check this:
https://jira.springsource.org/browse/SPR-4823
Vish Joshi
Greenhorn
Joined: Dec 22, 2010
Posts: 16
posted
Aug 29, 2011 02:20:00
0
I have resolved the problem..it was commons-logging.jar's version problem!
I agree. Here's the link:
http://ej-technologies/jprofiler
- if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
subject: Error while instantiating JdbcTemplate in spring-config.xml?
Similar Threads
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
Spring DI help
Spring AOP HELP needed
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter