Frühling, konfigurieren Sie die DataSource über JNDI mit remote-JBoss-Server

Möchte ich DataSource im Spring durch JNDI. Die ganze Konfiguration gegeben sind.

Kann mir jemand sagen, was falsch ist mit der Konfiguration.

Eine Sache, die ich erwähnen möchte ist, dass hier eine JNDI DS ist gehostet auf einem JBoss-server, die host nicht die Spring Anwendung.

Konfiguration

datasource-ds.xml

<?xml version="1.0" encoding="UTF-8"?>
<datasources>
  <local-tx-datasource>
    <jndi-name>jdbc/wc-mysql</jndi-name>
    <connection-url>jdbc:mysql://xx.xx.xx.xx:3306/club</connection-url>
    <driver-class>com.mysql.jdbc.Driver</driver-class>
    <user-name>club</user-name>
    <password>club</password>
    <exception-sorter-class-name>
      org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter
    </exception-sorter-class-name>
    <min-pool-size>5</min-pool-size>
    <max-pool-size>20</max-pool-size>
    <use-java-context>false</use-java-context>
    <metadata><type-mapping>mySQL</type-mapping></metadata>
  </local-tx-datasource>
</datasources>

configContext.xml

<bean id="wcDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
  <property name="jndiName" value="jdbc/wc-mysql" />
  <property name="jndiEnvironment">
    <props>
      <prop key="java.naming.provider.url">jnp://yy.yy.yy.yy:1099</prop>
      <!-- 
      <prop key="java.naming.factory.initial">
        org.springframework.mock.jndi.SimpleNamingContextBuilder
      </prop>
      <prop key="java.naming.factory.url.pkgs">yourPackagePrefixesGoHere</prop> -->
      <!-- other key=values here -->
    </props>
  </property>
  <!-- other properties here-->
</bean>

Ausnahme

Caused by: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
        at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
        at org.apache.naming.SelectorContext.lookup(SelectorContext.java:152)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154)

InformationsquelleAutor Talha Ahmed Khan | 2012-07-13

Schreibe einen Kommentar