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:RM开发者_如何学JAVAB_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?
Thanks to Ketan, who is awesome!
Needed a jboss-web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<resource-ref>
<res-ref-name>RMB_DS</res-ref-name>
<jndi-name>java:/RMB_DS</jndi-name>
</resource-ref>
</jboss-web>
And changed the original web.xml to have:
<resource-ref>
<description>DB Connection</description>
<res-ref-name>RMB_DS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Which matches 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>
精彩评论