I would like to configure my DataSources in a central place and provide them to client apps via JNDI. So I've set up the JCA configuration in JBoss (and made sure its in the global namespace). I have also been able to get a DBCP BasicDataSource configured with Spring to work. When I try to use the JNDI DataSource, I get the following stack trace (the TypeMismatchException is the culprit):
My DataSource config in Spring:Code:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in file [D:\cwn\da\conf\spring-hub-config.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'] PropertyAccessExceptionsException (1 errors) 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.BeanWrapperImpl.doTypeConversionIfNecessary(BeanWrapperImpl.java:1035) at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:803) at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:716) at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:844) at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:871) at org.springframework.beans.BeanWrapperImpl.setPropertyValues(BeanWrapperImpl.java:860) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:926) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:727) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:336) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:223) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:271) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:312) at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:82) at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:67) at com.shps.da.spring.AbstractSpringUnitTest.setUp(AbstractSpringUnitTest.java:42) at junit.framework.TestCase.runBare(TestCase.java:125) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:436) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:311) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Code:<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName"> <value>jdbc/SdsrDS</value> </property> <property name="resourceRef"> <value>false</value> </property> </bean>


Reply With Quote