簡體   English   中英

JBOSS eap 6.1.0中的Spring框架JNDI配置問題

[英]Spring framework JNDI Configuration issue in JBOSS eap 6.1.0

我在Jboss eap 6.1.0服務器中部署了一個war文件。 我在我的項目中使用Spring框架。 我使用兩個文件配置了JNDI,即sample-ds.xml(保存在JBOSS部署文件夾下)和dataSourceConfiguration.xml(它是war文件的一部分,由applicationContext.xml文件加載)。 dataSourceConfiguration.xml如下:

<beans>

<jee:jndi-lookup id="awd"               jndi-name="CS/AWD_QA"           resource-ref="false" />


    <!-- Don't change the id of the bean com.dsths.cs.awd.utils.RoutingDataSource -->   
    <bean id="routingDataSource" class="com.dsths.cs.awd.utils.RoutingDataSource">
        <property name="targetDataSources">
            <map key-type="java.lang.String"></map>
        </property>
    </bean>

我的sample-ds.xml如下:

<datasources>
<datasource enabled="true" jndi-name="java:jboss/CS/AWD_QA" jta="true" pool-name="AWDCS" use-ccm="true" use-java-context="false">
<connection-url>jdbc:oracle:thin:@XXXXX:1521:AWD</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<transaction-isolation>TRANSACTION_NONE</transaction-isolation>
<pool>
<min-pool-size>5</min-pool-size>
<max-pool-size>10</max-pool-size>
<prefill>false</prefill>
<use-strict-min>false</use-strict-min>
<flush-strategy>FailingConnectionOnly</flush-strategy>
</pool>
<security>
    <user-name>sample</user-name>
    <password>sample</password>
  </security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
<use-fast-fail>false</use-fast-fail>
<exception-sorter class-name="org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter"/>
</validation>
<timeout>
<idle-timeout-minutes>15</idle-timeout-minutes>
<xa-resource-timeout>0</xa-resource-timeout>
</timeout>
<statement>
<track-statements>false</track-statements>
</statement>
</datasource>
</datasources>  

    </beans>

當我使用上面的JNDI配置部署war文件時,我收到以下錯誤:

Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'AWDScriptController': Injection of autowired dependencies failed; 
nested exception is org.springframework.beans.factory.BeanCreationException:  
Could not autowire field: private com.dsths.cs.awd.services.ScriptTextFetcherService com.dsths.cs.awd.rest.ws.AWDScriptController.scriptService; nested exception is 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scriptTextFetcherService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.dsths.cs.awd.dao.AWDFormDao com.dsths.cs.awd.services.ScriptTextFetcherService.awdDao;
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'AWDFormDao':
Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.sql.DataSource com.dsths.cs.awd.dao.AWDFormDao.dataSource; nested exception is org.springframework.beans.
factory.NoSuchBeanDefinitionException: No qualifying bean of type [javax.sql.DataSource] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations:
{@org.springframework.beans.factory.annotation.Autowired(required=true), @org.springframework.beans.factory.annotation.Qualifier(value=awd)}
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'awd': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: CS/AWD_QA – service jboss.naming.context.java.CS.AWD_QA
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'awd': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: CS/AWD_QA – service jboss.naming.context.java.CS.AWD_QA
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'awd': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: CS/AWD_QA

關於這里出了什么問題的任何想法?

嘗試將java:jboss/添加到數據源名稱。

<jee:jndi-lookup id="awd"               jndi-name="java:jboss/CS/AWD_QA"           resource-ref="false" />

如果這不起作用,您可以將數據源的名稱更改為

Java的:/ JDBC / CS / AWD_QA

<jee:jndi-lookup id="awd"               jndi-name="java:/jdbc/CS/AWD_QA"           resource-ref="false" />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM