cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Error while deploying CDS based services on on premise HANA system.

srujan_gannamaneni
Participant
0 Likes
1,311

Hi Everyone

We are trying to deploy a project with db module having a HANA calculation view which further being consumed to create a cds based service using srv node js module. While it is working when we build and test locally, the deployment is failing with below error. Can anyone please guide me in fixing the issue? Please find the package.json (project level and srv module level) and MTA.yaml files in the attachments

/hana/shared/<SID>/xs/app_working/<SYSTEM ALIAS>/executionroot/8db36740-9455-4ff1-aee3-b9c51994fd5f/startCommand: line 8: exec: /hana/shared/<SID>/xs/app_working/<SYSTEM_ALIAS>/executionroot/8db36740-9455-4ff1-aee3-b9c51994fd5f/app/node_modules/.bin/cds-serve: cannot execute: Permission denied

Thanks in advance

Best Regards
Srujan

Accepted Solutions (0)

Answers (3)

Answers (3)

kevin_balboni1
Participant
0 Likes

Hi @rgadirov and @srujan_gannamaneni ,

Where you able to resolve the issue?

I have the same problem: "Error: Cannot find module '../lib'"

Thank you

Kevin

 

EDIT: sorry, missed the reply with the solution

rgadirov
Participant
0 Likes

Hello,

I have found a solution to this deployment issue:

  • In a standard CAP application, cds is often started directly using cds run or cds-serve in start script of package.json.
  • In XSA environments, the platform does not start the app via cds-serve and it doesn´t start with node server.js directly, but instead loads the module as a factory.
  • Hence, a file server.js which exports cds.server as factory is required and the start script can execute server.js file. 
  • E.g. my server.js file:
console.log('Server.js initialized');
// srv/server.js
const cds = require('@sap/cds')

cds.on('bootstrap', app => {
  app.get('/health', (_req,res) => res.status(200).send('OK'))     // 200
  app.get('/', (_req,res) => res.status(200).send('OK'))           // optional: 200 für Root
})

if (require.main === module) cds.server()
else module.exports = cds.server

cds.once('listening', ({ server }) =>
  console.log('CAP listening on', server.address().port)
)
 
and in my package.json my start script is "node server.js".
 
Doing so, 
  • XSA can control the application startup process.
  • Using require.main === module provides the advantage of enabling local development independently of the deployment setup.
  • During deployment, the Node.js buildpack in XSA defines the application startup process.

And my mta.yaml snippet for service module looks like this:

name: cap-srv
    type: nodejs
    path: .
    parameters:
      buildpack: sap_nodejs_buildpack
      memory: 512M
      instances: 1
      # Health-Check robust: checks the port 
      health-check-type: http
      health-check-timeout: 180
      health-check-http-endpoint: /health
 
In addition, I had to bind hdi container, db module, xsuaa/xssec und xsenv into my mta.yaml as modules so that the app was deployable and consistent. 
Note: The health check is a simple fix that if there's no 200 OK response, it may appear as if the app is in a "staging/unstable" state, even though the process is running. A simple fix is to implement a small health endpoint and configure the health check to use that instead. 
 
Best regards
Rufat

 

HakanHaslaman
Product and Topic Expert
Product and Topic Expert
0 Likes

The error message indicates that the `cds-serve` command cannot be executed due to permission issues.

Ensure that the `cds-serve` file has the correct permissions. You can use the `chmod` command to change the permissions. Also, the user must have to running the deployment process the necessary permissions to execute the `cds-serve` command. You may need to run the deployment process as a different user or modify the permissions of the current user.

srujan_gannamaneni
Participant
0 Likes

Hi Hakan

You are correct. I later tried to deploy the code using different user and this error didnt reproduce but I am still facing issue. Now it doesnt seem like access issue but it is unable to find the bin folder or cds-serve. Can you please review this error log screenshot and suggest how this issue can be alleviated?

Screenshot 2024-03-26 at 12.42.28 PM.png

Thanks and Regards
Srujan Gannamaneni

rgadirov
Participant
0 Likes

Hi @HakanHaslaman,

I am experiencing the same issue. This seems to happen with CDS related applications, because it is unknown to classic node js developers. I am trying to deploy a SAP CAP based application to HANA XSA from VS Code, and getting the exact same "Access Denied" issue. I already authorized and used chmod x to cds-serve and the error still occurs (See here: -rwxr-xr-x 1 NT-SBB1+e573091 4096 391 Aug 6 11:55 cds-serve*)

You also mentioned that the user must be authorized to deploy. My colleague is already able to deploy soutions (especially nodejs), but even with his user it doesn´t seem to be possible to deploy, Can you possible advise what else one could consider? Or is a SAP ticket required to solve this issue? The client uses HANA XSA as platform and the idea is to use the latest SAP CAP Framework to develop the appliction. 

@thomas_jung  Maybe you also have some idea. I also tried out your tutorial for SAP CAP development on HANA XSA (which is from 2021 btw. and based on WebIDE).

I can kindly provide more technical details on version etc. (nodeJS v22, CDS 9).

 

Update: In package.json of cap root project, I added now: 

 "scripts": {
     "start": "node ./node_modules/@sap/cds/bin/cds-serve",
          }
 
Now, the "Access denied" issue is also gone for me, but the node module execution script for "cds-serve" is not found. Actually, like in the screenshot of 
@srujan_gannamaneni =>Were you able to solve this issue?

Thank you for your support in advance.

Best regards

Rufat