0

組み込みの Tomcat 接続プールを使用するアプリケーションがあり、ほとんどの部分で動作します。別のプールを使用して、同じデータベースから別の接続セットを取得しようとすると問題が発生しますが、別のユーザー名/パスワードから取得します (これは、2 つのユーザー名を使用してテーブルと関数の異なる名前空間にアクセスする Oracle データベースです)。

最初のプールは受け入れられますが、2 番目のプールではこのエラーが発生します

15:09:47.157 [http-nio-8081-exec-5] ERROR com.applicationname.providers.ConnectionManager - NamingException in MyDataSource
javax.naming.NameNotFoundException: Name [appdb_two] is not bound in this Context. Unable to find [appdb_two].
    at org.apache.naming.NamingContext.lookup(NamingContext.java:818) ~[catalina.jar:8.0.15]

これが私の構成です:

サーバー.xml

<GlobalNamingResources>
    <!-- Editable user database that can also be used by
    UserDatabaseRealm to authenticate users-->

    <Resource name="UserDatabase" 
              auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />

    <Resource name="jdbc/appdb_two"
              auth="Container"
              type="javax.sql.DataSource"
              driverClassName="oracle.jdbc.driver.OracleDriver"
              factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"/>

    <Resource name="jdbc/appdb_one"
              auth="Container"
              type="javax.sql.DataSource"
              driverClassName="oracle.jdbc.driver.OracleDriver"
              factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"/>

</GlobalNamingResources>

context.xml

<ResourceLink name="jdbc/appdb_two" 
              auth="Container"             
              username="DBONE"
              password="xxxx" 
              type="javax.sql.DataSource" 
              url="jdbc:oracle:thin:@xx.xxx.xxx.xxx:1521:XE"
              initialSize="20"
              maxActive="50"
              maxIdle="20"
              factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"/>

<ResourceLink name="jdbc/appdb_one" 
              auth="Container"
              username="DBTWO"
              password="xxxx" 
              type="javax.sql.DataSource" 
              url="jdbc:oracle:thin:@xx.xxx.xxx.xxx:1521:XE"
              initialSize="20"
              maxActive="50"
              maxIdle="20"
              factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"/>
...
4

1 に答える 1

1

I think you're looking up the second datasource via name "appdb_two", but should be using "jdbc/appdb_two" - it's hard to see from the stacktrace alone, code for lookup would be helpful.

Also check that your web.xml has references to both data sources (<resource-ref> elements).

于 2015-10-26T13:55:22.307 に答える