Einrichten einer Datenquelle mit WebSphere-Liberty-Profil 8.5

Mein web app ist immer eine Datenquelle, aus der JNDI-mit:

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

In der app WEB-INF/web.xml habe ich:

<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 der app WEB-INF/ibm-web-bnd.xml habe ich:

<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 der WebSphere-Liberty-Profil server.xml habe ich (halten auf die relevanten Teile):

<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>

Wenn die app versucht, um die JNDI-datasource aus, schlägt es fehl mit der folgenden Fehlermeldung:

CWNEN0030E: The @Resource factory encountered a problem getting
the object instance jdbc/oracle binding object.  The exception message was: 
failed to resolve jdbc/oracle to javax.sql.DataSource: 
javax.naming.NameNotFoundException: 
Intermediate context does not exist: jdbc/oracle

Was ich hier vermisst?

InformationsquelleAutor avernet | 2013-07-23
Schreibe einen Kommentar