Automatic data source linking

I have a JDBC datasource defined in WebSphere named "jdbc / dataSource1".
In my Spring based application, I want to get the datasource using jndi lookup but with a different name like "jdbc / dataSource2".
To do this, I created an ibm-web-bnd.xml file in which I defined the link as follows:

<resource-ref binding-name="jdbc/dataSource2" name="jdbc/dataSource1"/>

      

Also I have defined the datasource in the web.xml file like this:

<resource-ref>
    <description>some awesome datasource</description>
    <res-ref-name>jdbc/dataSource2</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
</resource-ref>

      

The solution only works when deployed using the IBM Web Console. When I try to deploy it using a custom jython script using the wsadmin tool, I get the following error:

ADMA0007E: A Validation error occurred in task Mapping resource references to re
sources. The Java Naming and Directory Interface (JNDI) name is not specified f
or reference binding jdbc/dataSource2 in module <application_name>.war"

      

In the wsadmin script, I am using AdminApp.install (path_to_ear, options) where the options variable only contains options for mapping virtual hosts.

So the question is, what should I do, so WebSphere will get the data source mapping parameters from the ibm-web-bnd.xml file?

+3


source to share


2 answers


Try to call AppAdmin.install (path_to_ear) without parameters. Then the options are read from the bnd file and there is no validation error. And make sure the file ibm-web-bnd.xml

is in the ear file.

UPDATE

Ok, I noticed your mistake. In your binding file, it should be the other way around:



<resource-ref name="jdbc/MyRef" binding-name="jdbc/JNDI" />

      

so in your case the name is datasource2 and the binding is jndiname - so datasource1:

<resource-ref binding-name="jdbc/dataSource1" name="jdbc/dataSource2"/>

      

+3


source


You need to add an option MapResEnvRefToRes

to call AdminApp.install

to map a resource link to a resource. Check this link for more information:

http://www-01.ibm.com/support/knowledgecenter/api/content/SSEQTP_8.5.5/com.ibm.websphere.nd.multiplatform.doc/ae/rxml_taskoptions.html#rxml_taskoptions__cmd56

The quickest way to do this is to enable "help logging" and continue with the installation through the AdminConsole. Check the Command Support Log for the exact syntax AdminApp.install

for deploying and mapping resource references to real resources.



Advertising Mode (I am contributing to the OSS project mentioned below)

If you are considering a more complex automation project (not just a single application installation), you can find the WDR library. With WDR, you can export all of your application settings to a manifest file that includes the settings MapResEnvRefToRes

. Then you can deploy your application based on this manifest.

+2


source







All Articles