org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory' defined in class path resource [com/atomic/springjndi/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyAccessExceptionsException: PropertyAccessExceptionsException (1 errors); nested propertyAccessExceptions are: [org.springframework.beans.TypeMismatchException: Failed to convert property value of type [javax.naming.Reference] to required type [javax.sql.DataSource] for property 'dataSource']

Spring JIRA | Deepak Kalra | 1 decade ago
  1. 0

    Hi I am trying to run the simple example. I am getting the datasource from JNDI and passing it to the Local Session Factory and I am getting this error. It seems the LocalSessionFactory does not have the corresponding method for JndiObjectFactoryBean. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~- Error creating bean with name 'mySessionFactory' defined in class path resource [com/atomic/springjndi/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyAccessExceptionsException: PropertyAccessExceptionsException (1 errors); nested propertyAccessExceptions are: [org.springframework.beans.TypeMismatchException: Failed to convert property value of type [javax.naming.Reference] to required type [javax.sql.DataSource] for property 'dataSource'] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~- -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~- My application context file is <?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="mySessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean"> <property name="dataSource"> <bean id="myTestDataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName"> <value>jdbc/atomicDB</value> </property> </bean> </property> <property name="mappingResources"> <list> <value>com/atomic/springjndi/Event.hbm.xml</value> </list> </property> </bean> <bean id="myEventDAO" class="com.atomic.springjndi.EventDAOImpl"> <property name="sessionFactory"> <ref bean="mySessionFactory" /> </property> </bean> </beans> -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~- Full Error shows as below ---------------------------------------------------------------------- Client [INFO] XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [com/atomic/springjndi/applicationContext.xml] [INFO] ClassPathXmlApplicationContext - Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext;hashCode=573960176]: org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [mySessionFactory,myEventDAO]; root of BeanFactory hierarchy [INFO] ClassPathXmlApplicationContext - 2 beans defined in application context [org.springframework.context.support.ClassPathXmlApplicationContext;hashCode=573960176] [INFO] ClassPathXmlApplicationContext - Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.StaticMessageSource: {}] [INFO] ClassPathXmlApplicationContext - Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicationEventMulticaster@39ccaff3] [INFO] ClassPathXmlApplicationContext - Refreshing listeners [INFO] DefaultListableBeanFactory - Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [mySessionFactory,myEventDAO]; root of BeanFactory hierarchy] [INFO] DefaultListableBeanFactory - Creating shared instance of singleton bean 'mySessionFactory' [INFO] JndiObjectFactoryBean - Located object with JNDI name [jdbc/atomicDB]: value=[Reference Class Name: atomicDB Type: connectorName Content: atomicDB Type: recoveryClasspath Content: C:\Program Files\IBM\WebSphere Studio\Application Developer IE\v5.1.1\runtimes\ee_v51/lib/rsadapter.rar Type: FactoryJndiName Content: jdbc/atomicDB Address Type: dd AddressContents: ffffffac ffffffed 0 5 73 72 0 25 63 6f 6d 2e 69 62 6d 2e 65 6a 73 2e 6a 32 63 2e 52 65 73 6f 75 72 63 65 ... Address Type: poolProps AddressContents: ffffffac ffffffed 0 5 73 72 0 27 63 6f 6d 2e 69 62 6d 2e 65 6a 73 2e 6a 32 63 2e 43 6f 6e 6e 65 63 74 6f ... Address Type: configProps AddressContents: ffffffac ffffffed 0 5 73 72 0 23 63 6f 6d 2e 69 62 6d 2e 65 6a 73 2e 6a 32 63 2e 43 6f 6e 6e 65 63 74 6f ... Address Type: mmProps AddressContents: ffffffac ffffffed 0 5 73 72 0 14 6a 61 76 61 2e 75 74 69 6c 2e 50 72 6f 70 65 72 74 69 65 73 39 12 ffffffd0 7a ... Address Type: dsProps AddressContents: ffffffac ffffffed 0 5 73 72 0 14 6a 61 76 61 2e 75 74 69 6c 2e 50 72 6f 70 65 72 74 69 65 73 39 12 ffffffd0 7a ... Address Type: mcfProps AddressContents: ffffffac ffffffed 0 5 73 72 0 2d 63 6f 6d 2e 69 62 6d 2e 65 6a 73 2e 6a 32 63 2e 4d 61 6e 61 67 65 64 43 ... Address Type: mbeanProps AddressContents: ffffffac ffffffed 0 5 73 72 0 1a 63 6f 6d 2e 69 62 6d 2e 65 6a 73 2e 6a 32 63 2e 4d 42 65 61 6e 50 72 6f ... ] [INFO] DefaultListableBeanFactory - Destroying singletons in factory {org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [mySessionFactory,myEventDAO]; root of BeanFactory hierarchy} [INFO] DefaultListableBeanFactory - Destroying inner beans in factory {org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [mySessionFactory,myEventDAO]; root of BeanFactory hierarchy} org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory' defined in class path resource [com/atomic/springjndi/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyAccessExceptionsException: PropertyAccessExceptionsException (1 errors); nested propertyAccessExceptions are: [org.springframework.beans.TypeMismatchException: Failed to convert property value of type [javax.naming.Reference] to required type [javax.sql.DataSource] for property 'dataSource'] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:840) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:648) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:288) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:223) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:236) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:159) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:255) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:317) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:80) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:65) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:56) at com.atomic.springjndi.EventTestClient.main(EventTestClient.java:27) Exception in thread "P=417141:O=0:CT" ----------------------------------------------------------------------

    Spring JIRA | 1 decade ago | Deepak Kalra
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory' defined in class path resource [com/atomic/springjndi/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyAccessExceptionsException: PropertyAccessExceptionsException (1 errors); nested propertyAccessExceptions are: [org.springframework.beans.TypeMismatchException: Failed to convert property value of type [javax.naming.Reference] to required type [javax.sql.DataSource] for property 'dataSource']
  2. 0

    Hi I am trying to run the simple example. I am getting the datasource from JNDI and passing it to the Local Session Factory and I am getting this error. It seems the LocalSessionFactory does not have the corresponding method for JndiObjectFactoryBean. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~- Error creating bean with name 'mySessionFactory' defined in class path resource [com/atomic/springjndi/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyAccessExceptionsException: PropertyAccessExceptionsException (1 errors); nested propertyAccessExceptions are: [org.springframework.beans.TypeMismatchException: Failed to convert property value of type [javax.naming.Reference] to required type [javax.sql.DataSource] for property 'dataSource'] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~- -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~- My application context file is <?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="mySessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean"> <property name="dataSource"> <bean id="myTestDataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName"> <value>jdbc/atomicDB</value> </property> </bean> </property> <property name="mappingResources"> <list> <value>com/atomic/springjndi/Event.hbm.xml</value> </list> </property> </bean> <bean id="myEventDAO" class="com.atomic.springjndi.EventDAOImpl"> <property name="sessionFactory"> <ref bean="mySessionFactory" /> </property> </bean> </beans> -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~- Full Error shows as below ---------------------------------------------------------------------- Client [INFO] XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [com/atomic/springjndi/applicationContext.xml] [INFO] ClassPathXmlApplicationContext - Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext;hashCode=573960176]: org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [mySessionFactory,myEventDAO]; root of BeanFactory hierarchy [INFO] ClassPathXmlApplicationContext - 2 beans defined in application context [org.springframework.context.support.ClassPathXmlApplicationContext;hashCode=573960176] [INFO] ClassPathXmlApplicationContext - Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.StaticMessageSource: {}] [INFO] ClassPathXmlApplicationContext - Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicationEventMulticaster@39ccaff3] [INFO] ClassPathXmlApplicationContext - Refreshing listeners [INFO] DefaultListableBeanFactory - Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [mySessionFactory,myEventDAO]; root of BeanFactory hierarchy] [INFO] DefaultListableBeanFactory - Creating shared instance of singleton bean 'mySessionFactory' [INFO] JndiObjectFactoryBean - Located object with JNDI name [jdbc/atomicDB]: value=[Reference Class Name: atomicDB Type: connectorName Content: atomicDB Type: recoveryClasspath Content: C:\Program Files\IBM\WebSphere Studio\Application Developer IE\v5.1.1\runtimes\ee_v51/lib/rsadapter.rar Type: FactoryJndiName Content: jdbc/atomicDB Address Type: dd AddressContents: ffffffac ffffffed 0 5 73 72 0 25 63 6f 6d 2e 69 62 6d 2e 65 6a 73 2e 6a 32 63 2e 52 65 73 6f 75 72 63 65 ... Address Type: poolProps AddressContents: ffffffac ffffffed 0 5 73 72 0 27 63 6f 6d 2e 69 62 6d 2e 65 6a 73 2e 6a 32 63 2e 43 6f 6e 6e 65 63 74 6f ... Address Type: configProps AddressContents: ffffffac ffffffed 0 5 73 72 0 23 63 6f 6d 2e 69 62 6d 2e 65 6a 73 2e 6a 32 63 2e 43 6f 6e 6e 65 63 74 6f ... Address Type: mmProps AddressContents: ffffffac ffffffed 0 5 73 72 0 14 6a 61 76 61 2e 75 74 69 6c 2e 50 72 6f 70 65 72 74 69 65 73 39 12 ffffffd0 7a ... Address Type: dsProps AddressContents: ffffffac ffffffed 0 5 73 72 0 14 6a 61 76 61 2e 75 74 69 6c 2e 50 72 6f 70 65 72 74 69 65 73 39 12 ffffffd0 7a ... Address Type: mcfProps AddressContents: ffffffac ffffffed 0 5 73 72 0 2d 63 6f 6d 2e 69 62 6d 2e 65 6a 73 2e 6a 32 63 2e 4d 61 6e 61 67 65 64 43 ... Address Type: mbeanProps AddressContents: ffffffac ffffffed 0 5 73 72 0 1a 63 6f 6d 2e 69 62 6d 2e 65 6a 73 2e 6a 32 63 2e 4d 42 65 61 6e 50 72 6f ... ] [INFO] DefaultListableBeanFactory - Destroying singletons in factory {org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [mySessionFactory,myEventDAO]; root of BeanFactory hierarchy} [INFO] DefaultListableBeanFactory - Destroying inner beans in factory {org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [mySessionFactory,myEventDAO]; root of BeanFactory hierarchy} org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory' defined in class path resource [com/atomic/springjndi/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyAccessExceptionsException: PropertyAccessExceptionsException (1 errors); nested propertyAccessExceptions are: [org.springframework.beans.TypeMismatchException: Failed to convert property value of type [javax.naming.Reference] to required type [javax.sql.DataSource] for property 'dataSource'] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:840) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:648) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:288) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:223) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:236) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:159) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:255) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:317) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:80) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:65) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:56) at com.atomic.springjndi.EventTestClient.main(EventTestClient.java:27) Exception in thread "P=417141:O=0:CT" ----------------------------------------------------------------------

    Spring JIRA | 1 decade ago | Deepak Kalra
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory' defined in class path resource [com/atomic/springjndi/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyAccessExceptionsException: PropertyAccessExceptionsException (1 errors); nested propertyAccessExceptions are: [org.springframework.beans.TypeMismatchException: Failed to convert property value of type [javax.naming.Reference] to required type [javax.sql.DataSource] for property 'dataSource']
  3. 0

    Getting error while dynamically providing input,output path

    Stack Overflow | 8 months ago | Varun Maurya
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'step1': Cannot resolve reference to bean 'itemReader' while setting bean property 'itemReader'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'itemReader' defined in class path resource [spring/config/process-config.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type [com.sun.proxy.$Proxy11 implementing org.springframework.batch.item.ItemStreamReader,org.springframework.batch.item.ItemStream,org.springframework.aop.scope.ScopedObject,java.io.Serializable,org.springframework.aop.framework.AopInfrastructureBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [org.springframework.batch.item.file.MultiResourceItemReader] for property 'multiReader'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [com.sun.proxy.$Proxy11 implementing org.springframework.batch.item.ItemStreamReader,org.springframework.batch.item.ItemStream,org.springframework.aop.scope.ScopedObject,java.io.Serializable,org.springframework.aop.framework.AopInfrastructureBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [org.springframework.batch.item.file.MultiResourceItemReader] for property 'multiReader': no matching editors or conversion strategy found
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Issues in serializers config

    GitHub | 3 years ago | dsukhoroslov
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hzInstance': Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public static com.hazelcast.core.HazelcastInstance com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance(com.hazelcast.config.Config)] threw exception; nested exception is com.hazelcast.nio.serialization.HazelcastSerializationException: java.lang.NoSuchMethodException: com.hazelcast.nio.serialization.PortableSerializer.<init>()
  6. 0

    'circle' defined in class path resource [Spring.xml]: Initialization of bean failed; nested exception is java.lang.IllegalAccessError

    Stack Overflow | 3 years ago | user2681868
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'circle' defined in class path resource [Spring.xml]: Initialization of bean failed; nested exception is java.lang.IllegalAccessError

  1. batwalrus76 7 times, last 4 days ago
  2. rlovtangen 1 times, last 7 days ago
  3. tvrmsmith 6 times, last 2 weeks ago
  4. kjhdofjosvs 1 times, last 4 weeks ago
  5. Andreas Häber 2 times, last 4 weeks ago
23 more registered users
72 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. org.springframework.beans.factory.BeanCreationException

    Error creating bean with name 'mySessionFactory' defined in class path resource [com/atomic/springjndi/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyAccessExceptionsException: PropertyAccessExceptionsException (1 errors); nested propertyAccessExceptions are: [org.springframework.beans.TypeMismatchException: Failed to convert property value of type [javax.naming.Reference] to required type [javax.sql.DataSource] for property 'dataSource']

    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues()
  2. Spring Beans
    DefaultListableBeanFactory.preInstantiateSingletons
    1. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:840)
    2. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:648)
    3. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:288)
    4. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:223)
    5. org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:236)
    6. org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:159)
    7. org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:255)
    7 frames
  3. Spring Context
    ClassPathXmlApplicationContext.<init>
    1. org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:317)
    2. org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:80)
    3. org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:65)
    4. org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:56)
    4 frames
  4. com.atomic.springjndi
    EventTestClient.main
    1. com.atomic.springjndi.EventTestClient.main(EventTestClient.java:27)
    1 frame