错误:找不到文件/home/vcap/app/xs-app.json

时间:2019-04-29 06:45:03

标签: s4sdk

按照本教程尝试当前安装approuter:

https://blogs.sap.com/2017/07/18/step-7-with-sap-s4hana-cloud-sdk-secure-your-application-on-sap-cloud-platform-cloudfoundry/

将approuter推到CF时,出现错误:

 2019-04-29T08:39:34.43+0200 [APP/PROC/WEB/0] ERR /home/vcap/app/approuter/lib/environment.js:19
   2019-04-29T08:39:34.43+0200 [APP/PROC/WEB/0] ERR       throw new Error('File not found ' + xsappFile);
   2019-04-29T08:39:34.43+0200 [APP/PROC/WEB/0] ERR       ^
   2019-04-29T08:39:34.43+0200 [APP/PROC/WEB/0] ERR Error: File not found /home/vcap/app/xs-app.json

这是我的manifest.yml:

---
applications:
- name: xyz
  command: 'node approuter/approuter.js'
  host: xyz-93deb1cd-7b72-4060-94e7-30baef85d259
  path: approuter
  memory: 128M
  buildpack: https://github.com/cloudfoundry/nodejs-buildpack
  env:
    TENANT_HOST_PATTERN: 'xyz(.*).cfapps.eu10.hana.ondemand.com'
    destinations: '[{"name":"service-destination", "url": "https://gfuowb4ett234agtuthorizations-srv.cfapps.eu10.hana.ondemand.com", "forwardAuthToken": true}]'
    SAP_JWT_TRUST_ACL: '[{"clientid" : "*", "identityzone" : "*"}]'

  services:
    - my-xsuaa
    - service-destination

这是我的xs-app.json,位于我的“ approuter”文件夹中。

{
  "routes": [{
    "source": "/",
    "target": "/",
    "destination": "service-destination"
  }]
}

This is my folder structure

当我将xs-app.json移到期望的根文件夹中时,出现以下错误消息:

xs-app.json/routes/0: Format validation failed (Route references unknown destination "service-destination")

1 个答案:

答案 0 :(得分:1)

我猜想approuter正在研究绑定的目标服务,而不是目标环境变量。

我注意到,有一个名为“ service-destination”的目的地服务实例,但是您已经在环境变量中定义了一个具有相同名称的 destination

任何一个都应该在场。

我建议要么在环境变量中维护目标,然后从服务部分删除条目

---
applications:
- name: xyz
  command: 'node approuter/approuter.js'
  host: xyz-93deb1cd-7b72-4060-94e7-30baef85d259
  path: approuter
  memory: 128M
  buildpack: https://github.com/cloudfoundry/nodejs-buildpack
  env:
    TENANT_HOST_PATTERN: 'xyz(.*).cfapps.eu10.hana.ondemand.com'
    destinations: '[{"name":"service-destination", "url": "https://gfuowb4ett234agtuthorizations-srv.cfapps.eu10.hana.ondemand.com", "forwardAuthToken": true}]'
    SAP_JWT_TRUST_ACL: '[{"clientid" : "*", "identityzone" : "*"}]'

  # remove the service-destination from here and unbind any destination service if already bound
  services:
    - my-xsuaa

或不维护目标环境变量-而是在目标服务实例GUI(从驾驶舱)中维护它

---
applications:
- name: xyz
  command: 'node approuter/approuter.js'
  host: xyz-93deb1cd-7b72-4060-94e7-30baef85d259
  path: approuter
  memory: 128M
  buildpack: https://github.com/cloudfoundry/nodejs-buildpack
  env:
    TENANT_HOST_PATTERN: 'xyz(.*).cfapps.eu10.hana.ondemand.com'
    SAP_JWT_TRUST_ACL: '[{"clientid" : "*", "identityzone" : "*"}]'

  services:
    - my-xsuaa
    - service-destination

enter image description here

注意:

  1. 目标名称目标实例名称保持相同 可能会引起很多混乱。

  2. 在以下情况下手动取消绑定服务目标/目标实例 您正在采用第一种方法。从服务中删除条目 部分不会自动取消绑定。