darkstar
darkstar

Reputation: 31

Websphere liberty 19 configure jndi datasource

I have deployed two ears and to one of them i do not have access. There is a file application-web-bnd.xml where is reference to datasource

In my server.xml file i have defined datasource

 <application id="MyCustomApp.war" location="F:\programming\source\MyCustomApp\target\MyCustomApp" name="MyCustomApp" type="war">
    <application-bnd>
      <security-role name="admin">
        <special-subject type="ALL_AUTHENTICATED_USERS" />
      </security-role>
      <data-source binding-name="jdbc/Sample" name="java:comp/env/jdbc/db" />
    </application-bnd>
  </application>

  <dataSource id="Sample" jndiName="jdbc/Sample" type="javax.sql.DataSource">
    <jdbcDriver>
      <library name="JdbcJarFiles">
        <fileset dir="${shared.resource.dir}" includes="db2jcc4.jar, db2jcc_license_cisuz.jar, db2jcc_license_cu.jar, pdq.jar, pdqmgmt.jar" />
        <folder dir="${shared.resource.dir}" />
      </library>
    </jdbcDriver>
  </dataSource>

In code in ear where i do not have access there is initialContext java:comp/env/jdbc/db.

Reference to data source exists but datasource does not exists. I do not have access to web.xml for create reference . I do not have ide how override it.

Could You help ?

My ear looks that:

 <module>
    <ejb>PRE-BF.jar</ejb>
  </module>
  <module>
    <web>
      <web-uri>PRE-WS.war</web-uri>
      <context-root>/PRE-WS</context-root>
    </web>
  </module>
  <module>
    <web>
      <web-uri>PRE-RS.war</web-uri>
      <context-root>/PRE-RS</context-root>
    </web>
  </module>
  <module>
    <web>
      <web-uri>PRE-PF.war</web-uri>
      <context-root>/PRE-PF</context-root>
    </web>
  </module>

Upvotes: 2

Views: 1208

Answers (1)

njr
njr

Reputation: 3484

You can override bindings in server configuration as follows. (This will require having your application defined in server configuration rather than dropins).

<application location="MyApp.war">
  <web-bnd moduleName="MyApp">
    <resource-ref name="jdbc/Sample" binding-name="java:comp/env/jdbc/db"/>
  </web-bnd>
</application>

Upvotes: 1

Related Questions