JBoss 中的 JNDI 绑定(LiveCycle 交钥匙)
我正在使用 Adobe LiveCycle ES 2 交钥匙项目,它在 JBoss AS 4.2.1.GA 上运行。我在 JNDI 绑定在 JBoss 中工作时遇到问题。它看起来与之前的文章非常相似,配置 JBoss 与 JNDI 配合使用时出现问题,但我当然没有找到解决方案。
这是我的设置。我有一个 -ds.xml 文件:
C:\Adobe\Adobe LiveCycle ES2\jboss\server\lc_turnkey\deploy\rmb-ds.xml
该文件的内容如下:
<datasources>
<local-tx-datasource>
<jndi-name>RMB_DS</jndi-name>
<connection-url>jdbc:sqlserver://localhost\SQLEXPRESS;DatabaseName=rmb</connection-url>
<driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
<user-name>sa</user-name>
<password>password</password>
<check-valid-connection-sql>SELECT 1 FROM sysobjects</check-valid-connection-sql>
<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
<metadata>
<type-mapping>MS SQLSERVER2000</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>
我有一个 Java 项目,其 /RMB/WebContent/WEB-INF/web.xml 包含以下内容:
<resource-ref>
<description>DB Connection</description>
<res-ref-name>java:RMB_DS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
现在,每次我部署WAR,它失败并出现以下错误:
2011-09-06 15:44:17,786 ERROR [org.jboss.deployment.MainDeployer] Could not start deployment: file:/C:/Adobe/Adobe LiveCycle ES2/jboss/server/lc_turnkey/deploy/RMB.war
org.jboss.deployment.DeploymentException: Error during deploy; - nested throwable: (javax.naming.NamingException: resource-ref: java:RMB_DS has no valid JNDI binding. Check the jboss-web/resource-ref.)
at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:384)
...
Caused by: javax.naming.NamingException: resource-ref: java:RMB_DS has no valid JNDI binding. Check the jboss-web/resource-ref.
at org.jboss.web.AbstractWebDeployer.linkResourceRefs(AbstractWebDeployer.java:623)
我 100% 肯定 JNDI 绑定本身是正确的。我可以在网络控制台中看到以下内容>系统> JMX Bean > jboss.jdbc> jboss.jdbc:service=metadata,datasource=RMB_DS
MBean Name: Domain Name: jboss.jdbc
service: metadata
datasource: RMB_DS
MBean Java Class: org.jboss.ejb.plugins.cmp.jdbc.metadata.DataSourceMetaData
另外,使用 LiveCycle 工作台,我可以创建一个进程来命中此服务并对数据源 java:/RMB_DS 运行一些 SQL ..
所以,我的 WAR 或 web 一定有问题.xml 对吧?我错过了一些明显的东西吗?
I am using Adobe LiveCycle ES 2 turnkey project, which runs on JBoss AS 4.2.1.GA. I am having a problem getting a JNDI binding to work in JBoss. It seems eerily similar to an earlier post, problem configure JBoss to work with JNDI, but I certainly have found no solution.
This is my setup. I have a -ds.xml file in place:
C:\Adobe\Adobe LiveCycle ES2\jboss\server\lc_turnkey\deploy\rmb-ds.xml
The contents of that file are as follows:
<datasources>
<local-tx-datasource>
<jndi-name>RMB_DS</jndi-name>
<connection-url>jdbc:sqlserver://localhost\SQLEXPRESS;DatabaseName=rmb</connection-url>
<driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
<user-name>sa</user-name>
<password>password</password>
<check-valid-connection-sql>SELECT 1 FROM sysobjects</check-valid-connection-sql>
<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
<metadata>
<type-mapping>MS SQLSERVER2000</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>
I have a Java project, whose /RMB/WebContent/WEB-INF/web.xml contains the following:
<resource-ref>
<description>DB Connection</description>
<res-ref-name>java:RMB_DS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Now, every time I deploy the WAR, it fails with the following error:
2011-09-06 15:44:17,786 ERROR [org.jboss.deployment.MainDeployer] Could not start deployment: file:/C:/Adobe/Adobe LiveCycle ES2/jboss/server/lc_turnkey/deploy/RMB.war
org.jboss.deployment.DeploymentException: Error during deploy; - nested throwable: (javax.naming.NamingException: resource-ref: java:RMB_DS has no valid JNDI binding. Check the jboss-web/resource-ref.)
at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:384)
...
Caused by: javax.naming.NamingException: resource-ref: java:RMB_DS has no valid JNDI binding. Check the jboss-web/resource-ref.
at org.jboss.web.AbstractWebDeployer.linkResourceRefs(AbstractWebDeployer.java:623)
I am 100% positive that the JNDI binding itself is correct. I can see the following in web console > System > JMX Beans > jboss.jdbc > jboss.jdbc:service=metadata,datasource=RMB_DS
MBean Name: Domain Name: jboss.jdbc
service: metadata
datasource: RMB_DS
MBean Java Class: org.jboss.ejb.plugins.cmp.jdbc.metadata.DataSourceMetaData
Also, using LiveCycle workbench I can make a process that hits this service and runs some SQL against datasource java:/RMB_DS..
SO, there has to be something wrong with my WAR or web.xml right? Am I missing something obvious?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
感谢 Ketan,他太棒了!
需要一个 jboss-web.xml:
并将原来的 web.xml 更改为:
与 rmb-ds.xml 匹配
Thanks to Ketan, who is awesome!
Needed a jboss-web.xml:
And changed the original web.xml to have:
Which matches rmb-ds.xml