遇到一个问题,我们的两个不同 DBMS(MS-SQLServer 和 Informix)的数据源没有在 login-config.xml 文件中获取安全域配置。
我们的数据源如下所示:
<datasources>
<local-tx-datasource>
<jndi-name>ourTX</jndi-name>
<connection-url>jdbc:informix-sqli://our.server.com:1526/wlms:informixserver=ol_db</connection-url>
<driver-class>com.informix.jdbc.IfxDriver</driver-class>
<security-domain>ourDS</security-domain>
<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
<metadata>
<type-mapping>InformixDB</type-mapping>
</metadata>
<min-pool-size>5</min-pool-size>
<max-pool-size>50</max-pool-size>
<prefill>yes</prefill>
<prepared-statement-cache-size>10</prepared-statement-cache-size>
<idle-timeout-minutes>5</idle-timeout-minutes>
<new-connection-sql>set lock mode to wait 4;set isolation to cursor stability;</new-connection-sql>
<check-valid-connection-sql>SELECT count(*) FROM dummy;</check-valid-connection-sql>
</local-tx-datasource>
</datasources>
我们的 login-config.xml 有以下条目:
<application-policy name="ourDS">
<authentication>
<login-module code="org.jboss.resource.security.SecureIdentityLoginModule" flag="required">
<module-option name="userName">user</module-option>
<module-option name="password">-4e5f8b6c4217c342c03b57ed16d31678</module-option>
<module-option name="managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=ourTX</module-option>
</login-module>
</authentication>
</application-policy>
但是,一旦部署了 JBoss 服务器,我们就会收到类似 Informix 的错误:
13:23:13,521 WARN [JBossManagedConnectionPool] Throwable while attempting to get a new connection: null
org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (java.sql.SQLException: Incorrect password or user com.informix.asf.IfxASFRemoteException: user@my.computer.com is not known on the database server.)
对于 MS-SQLServer,我们会收到与 Informix 类似的错误,如下所示:
13:25:23,053 WARN [JBossManagedConnectionPool] Throwable while attempting to get a new connection: null
org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user ''. The user is not associated with a trusted SQL Server connection.)
现在,如果我们注释掉 *-ds.xml 文件中的 security-domain 元素并将其替换为简单的用户名和明文密码,那么两个数据源都可以与两个数据库引擎一起使用。我们在 JBoss 中使用“所有”服务器配置。我们已经确保 login-config.xml 在启动时被加载。并且使用 security-domain 元素的 hqsqldb-ds.xml 有效。但是使用我们在 login-config.xml 中添加的应用程序策略,似乎数据源在建立新连接时没有获取值。
任何想法我们做错了什么?我们错过了什么吗?