Search code examples
databasejbosswarjndiweb.xml

JBoss datasource reference in web.xml fails


I have the following configuration in my web.xml

<resource-ref id="ResourceRef_1234567890">
    <res-ref-name>jdbc/pcbDB</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Application</res-auth>
    <res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>

While I deploy my application I am getting the following error.

16:29:57,745 ERROR [org.jboss.as.controller.management-operation] (HttpManagementService-threads - 6) JBAS014612: Operation ("deploy") failed - address: ([("deployment" => "APP-5.3.ear")]) - failure description: {"JBAS014771: Services with missing/unavailable dependencies" => [ "jboss.naming.context.java.module.\"App-5.3\".\"WebArchive-5.1\".env.jdbc.pcbDB is missing [jboss.naming.context.java.jboss.resources.jdbc.pcbDB]" ]}

Rollback happens following that,

16:29:57,777 ERROR [org.jboss.as.server] (HttpManagementService-threads - 6) JBAS015870: Deploy of deployment "APP-5.3.ear" was rolled back with the following failure message: {"JBAS014771: Services with missing/unavailable dependencies" => [ "jboss.naming.context.java.module.\"App-5.3\".\"WebArchive-5.1\".env.jdbc.pcbDB is missing [jboss.naming.context.java.jboss.resources.jdbc.pcbDB]" ]}

I have corresponding datasource created in standalone.xml. From the web console Test Connection Succeeds....

Name: pcbdb

JNDI: java:/jdbc/pcbDB

And this is the datasource definition I have in standalone.xml.....

<!--Here is datasource config.... As I had many spaces in xml config I couldn't add it as code..... Now I have copied it by the char comes with tilt ~ -->
                <datasource jndi-name="java:/jdbc/pcbDB" pool-name="pcbdb" enabled="true">
                    <connection-url>jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=off)(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=XE)(SERVER=DEDICATED)))</connection-url>
                    <driver>com.oracle</driver>
                    <pool>
                        <min-pool-size>3</min-pool-size>
                        <max-pool-size>5</max-pool-size>
                    </pool>
                    <security>
                        <user-name>pcbdb</user-name>
                        <password>passwd</password>
                    </security>
                    <validation>
                        <exception-sorter class-name="org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter"/>
                    </validation>
                    <timeout>
                        <blocking-timeout-millis>5000</blocking-timeout-millis>
                        <idle-timeout-minutes>5</idle-timeout-minutes>
                    </timeout>
                </datasource>

Please give the solution.... For the same I have the context.lookup as well. It looks like initCtx.lookup("java:comp/env/jdbc/pcbDB");... is this correct......?


Solution

  • JDNI lookup fails for this,- java:comp/env/jdbc/pcbDB

    JNDI lookup for this string,- java:/jdbc/pcbDB succeeds....