jdbc - Setting up a datasource with WebSphere Liberty Profile 8.5 -


my web app getting data source jndi with:

javax.naming.initialcontext ctx = new javax.naming.initialcontext(); javax.sql.datasource ds = (javax.sql.datasource)      ctx.lookup("java:comp/env/jdbc/db"); 

in app's web-inf/web.xml, have:

<resource-ref>     <description>datasource</description>     <res-ref-name>jdbc/db</res-ref-name>     <res-type>javax.sql.datasource</res-type>     <res-auth>container</res-auth> </resource-ref> 

in app's web-inf/ibm-web-bnd.xml, have:

<web-bnd     xmlns="http://websphere.ibm.com/xml/ns/javaee"     xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"     xsi:schemalocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-bnd_1_0.xsd"     version="1.0">     <virtual-host name="default_host"/>     <resource-ref name="jdbc/db" binding-name="jdbc/db"/> </web-bnd> 

in websphere liberty profile's server.xml, have (keeping on relevant parts):

<server description="new server">      <featuremanager>         <feature>jsp-2.2</feature>         <feature>jdbc-4.0</feature>     </featuremanager>      <library id="oracle-lib">         <fileset dir="lib" includes="ojdbc5_g.jar"/>     </library>      <datasource jndiname="jdbc/db" jdbcdriverref="oracle-driver" type="javax.sql.datasource">         <jdbcdriver libraryref="oracle-lib" id="oracle-driver"/>         <connectionmanager numconnectionsperthreadlocal="10" id="connectionmanager" minpoolsize="1"/>         <properties user="user" password="password"                     url="jdbc:oracle:thin:@//db-server:1521/db"/>     </datasource>  </server> 

when app attempts datasource jndi, fails following error:

cwnen0030e: @resource factory encountered problem getting object instance jdbc/oracle binding object.  exception message was:  failed resolve jdbc/oracle javax.sql.datasource:  javax.naming.namenotfoundexception:  intermediate context not exist: jdbc/oracle 

what missing here?

websphere server.xml

<server>         <featuremanager>         <feature>jndi-1.0</feature>         <feature>jdbc-4.1</feature>     </featuremanager>      <httpendpoint id="defaulthttpendpoint"                   host="localhost"                   httpport="9080"                   httpsport="9443" />      <library id="oracle-lib">         <fileset dir="lib" includes="ojdbc6_g.jar"/>     </library>      <datasource jndiname="jdbc/oracle">         <jdbcdriver libraryref="oracle-lib"/>         <properties.oracle user="orbeon" password="password"                            url="jdbc:oracle:thin:@//localhost:1521/orbeon"/>     </datasource>      <application name="orbeon" location="war/orbeon" type="war">         <classloader commonlibraryref="oracle-lib"/>     </application>     </server> 

web-inf/ibm-web-bnd.xml

<web-bnd version="1.0"         xmlns="http://websphere.ibm.com/xml/ns/javaee"         xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"         xsi:schemalocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-bnd_1_0.xsd">     <virtual-host name="default_host"/>     <resource-ref name="jdbc/oracle" binding-name="jdbc/oracle"/> </web-bnd> 

web-inf/web.xml

<resource-ref>     <res-ref-name>jdbc/oracle</res-ref-name>     <res-type>javax.sql.datasource</res-type>     <res-auth>container</res-auth> </resource-ref> 

resource injection (instead of web.xml + ibm-web-bnd.xml):

@resource(lookup = "jdbc/oracle") datasource ds; 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -