2016-05-01 34 views
0

私はSpring 3.2.13 jarsとibatis 2.3.4.726のバージョンを使用して設定していますGetting:java.lang.IllegalStateException:型[java.lang.String]の値を必須の型[javax.sql.DataSource]に変換できません

<bean id="commonDataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> 
    <property name="jndiName" value="jdbc/ds_GOLD" /> 
    <property name="defaultObject" value="jdbc/ds_SILVERR" /> 
</bean> 

<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"> 
    <property name="configLocation"> 
     <value> 
      classpath:com/dav/dao/config/sqlMapConfig.xml 
     </value> 
    </property> 
    <property name="dataSource"> 
     <ref bean="commonDataSource" /> 
    </property> 
    <property name="transactionConfigClass"> 
     <value>com.ibatis.sqlmap.engine.transaction.external.ExternalTransactionConfig 
     </value> 
    </property> 
    <property name="transactionConfigProperties"> 
     <props> 
      <prop key="DefaultAutoCommit">false</prop> 
      <prop key="SetAutoCommitAllowed">false</prop> 
     </props> 
    </property> 
</bean> 

構成は、私にとっては良いようだが、例外 Oを取得:

の下に、私は以下の例外を取得していますなどのdataSource Caused by: java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource': no matching editors or conversion strategy found

私のxml春の構成は以下の通りです"jdbc/ds_GOLD"がAppサーバーで設定されていない場合はnly。この場合、defaultObject JNDIが選択されます。 "jdbc/ds_GOLD"がAppサーバーに設定されていると、ログにエラーは表示されません。しかし、フェイルオーバーの場合は動作しません。

[5/1/16 3:32:51:329 EDT] 00000098 webapp  I com.ibm.ws.webcontainer.webapp.WebApp log SRVE0296E: [glow#glow.war][/glow][Servlet.LOG]:.StrutsServlet: null:.org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gcdSqlMapClient' defined in ServletContext resource [/WEB-INF/config/common-dao.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.lang.String' to required type 'javax.sql.DataSource' for property 'dataSource'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource': no matching editors or conversion strategy found 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:529) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) 
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293) 
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191) 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:618) 
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:934) 
    . 
    . 
    . 
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1862) 
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.lang.String' to required type 'javax.sql.DataSource' for property 'dataSource'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource': no matching editors or conversion strategy found 
    at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:464) 
    at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:495) 
    at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:489) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1465) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1424) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1160) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) 
    ... 114 more 
Caused by: java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource': no matching editors or conversion strategy found 
    at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:267) 
    at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:449) 
    ... 120 more 
`` 

答えて

0

defaultObjectをdataSourceへのプロパティ参照として保持しないでください。私は誤ってそれをプロパティ値として設定しました。

関連する問題