cancel
Showing results for 
Search instead for 
Did you mean: 

SAP HANA XSA - connecting nodejs to HANA with multiple container of type HANA

0 Kudos

Hello Community,

How do we connect node js to HANA, when we have multiple container of type hana in the same project? When i tried to get hana connection with xsenv.getService({hana:{tag:'hana'}}), Its throwing the below error,

Yeah i have two hdb container and 1 cross container access defined in my mta.yaml file. How do i specify or obtain connection for all of this??

here is the code snippet from my index.js

How do i resolve this issue?? am i doing anything wrong here?

version: HANA 2.0 SP03

any leads to resolve this is much appreciated.

craig.cmehil thomas.jung could you help me here or provide some leads?

Thanks in advance.

Regards,

Girish

Accepted Solutions (0)

Answers (2)

Answers (2)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

If that were the case then you would not be getting this error. Did you have multiple requires in the past? Maybe try stopping the Node.js service to delete any old bindings. Or look at the bindings with xs env. That error is clear: you have more than one binding with tag Hana.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Just because you have multiple HDI containers in your project doesn’t mean you should bind all of them to your Node.js module. You can only really use one of them as your primary connection. Choose that one and make it your only one listed in the requires section of the Node.js module. Otherwise you can’t load them by tag and will have to load the one you want by name.

0 Kudos

Thanks for the response,

But the mta is defined as node module requires only one connection. Below is the mta.yaml

ID: CustomerPoc
_schema-version: '2.0'
description: POC for 
version: 0.0.1

modules:
 - name: hdb
   type: hdb
   path: hdb
   requires:
    - name: hdi_hdb
      properties:
        TARGET_CONTAINER: ~{hdi-container-name}
    - name: cross-container-service-abap
      group: SERVICE_REPLACEMENTS
      properties:
        key: abap_container
        service: ~{abap-service}                   
    - name: cross-container-service-customer
      group: SERVICE_REPLACEMENTS
      properties:
        key: customer_container
        service: ~{customer-service}
                          
 - name: nodejs
   type: nodejs
   path: nodejs
   requires:
    - name: hdb
    - name: hdi_hdb
   provides:
    - name: nodejs_api
      properties:
         url: ${default-url}

resources:
 - name: hdi_hdb
   parameters:
      config:
         schema: CUSTOMER_POC
   properties:
      hdi-container-name: ${service-name}
   type: com.sap.xs.hdi-container

 - name: cross-container-service-abap
   parameters:
      service-abap: GBANGALO-opq99lyoiu266qci-ERP_TLA_MM-hdi_hdb
   properties:
      abap-service: ${service-abap}
   type: org.cloudfoundry.existing-service

 - name: cross-container-service-customer
   parameters:
      service-cust: GBANGALO-opq99lyoiu266qci-CustomerPOC-hdi_HDB
   properties:
      customer-service: ${service-cust}
   type: org.cloudfoundry.existing-service

Not Sure whats wrong here.

So How do we load connection by name instead of tags? What should i change here to make them load by name

	var hanaOptions = xsenv.getServices({	
		hana: {
			tag: 'hana'
		}
	});