javavisual-studio-codeopen-liberty

VS Code and Liberty: DataSource defined in server.xml not found by server


Here is my server.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<server description="new server">

    <!-- Enable features -->
    <featureManager>
        <feature>json-1.0</feature>     
        <feature>localConnector-1.0</feature>   
        <feature>distributedMap-1.0</feature>
        <feature>webCache-1.0</feature>
    </featureManager>

    <!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" -->
    <httpEndpoint id="defaultHttpEndpoint"
                  httpPort="9080"
                  httpsPort="9443" />

    <!-- Automatically expand WAR files and EAR files -->
    <applicationManager autoExpand="true"/>
    
    <!--Data Config-->
    
    <library id="DB2JCC4Lib">
        <fileset dir="C:/Munka/SQLLIB/java_new" includes="db2jcc4.jar"/>
    </library>
    
    <jdbcDriver id="DB2JDBCDriver" libraryRef="DB2JCC4Lib" javax.sql.DataSource="javax.sql.ConnectionPoolDataSource"/>
    
    
    <connectionManager id="defaultConnectionManager" maxConnectionsPerThread="10" purgePolicy="EntirePool"/>
    
    <dataSource transactional="false" id="sss_ha_csn_DS" jndiName="jdbc/sss_ha_csn_DS" connectionManagerRef="defaultConnectionManager" jdbcDriverRef="DB2JDBCDriver" type="javax.sql.XADataSource">
        <properties.db2.jcc databaseName="SYSSUPT" user="RETRACTED" password="RETRACTED" portNumber="50000" serverName="localhost"/>
    </dataSource>

    <!-- Default SSL configuration enables trust for default certificates from the Java runtime --> 
    <ssl id="defaultSSLConfig" trustDefaultCerts="true" />
</server>

My application has the following line:

DataSource ds = (DataSource) context.lookup(dataBasePoolURLStr);

The application establishes the DataSource correctly when I am running Liberty server from Eclipse. However when I want to run the same config in VS Code I get the following error:

ERROR com.ibm.esup.css.common.dataaccess.CSSDAOFactory - getDataSource(String): Error = javax.naming.NameNotFoundException: Intermediate context does not exist: jdbc/sss_ha_csn_DS

Any advice is welcome!


Solution

  • Adding JDBC could solve this problem.

    <feature>jdbc-4.1</feature>