0

AWS NodeJS lambda function with JDK package

I am trying to use a DATABASE driver (Sybase driveR) with AWS NodeJS lambda. This driver uses JConnect which needs JDK at runtime. But it seems AWS Lambda for NodeJS does not come with Java runtime. It is failing with the following error

{
    "errorType": "Error",
    "errorMessage": "spawn java ENOENT",
    "code": "ENOENT",
    "errno": -2,
    "syscall": "spawn java",
    "path": "java",
    "spawnargs": [
        "-jar",
        "/var/task/node_modules/sybase-fork/JavaSybaseLink/dist/JavaSybaseLink.jar",
 // othe args
    ],
    "stack": [
        "Error: spawn java ENOENT",
        "    at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)",
        "    at onErrorNT (internal/child_process.js:467:16)",
        "    at processTicksAndRejections (internal/process/task_queues.js:82:21)"
    ]
}

Has someone tried spawning java process from node in AWS Lambda?

1 Answer 1

3

AWS Lambda runtimes are supposed to be high performance, low latency and minimal. That's why they run on the Firecracker MicroVM with a OSv micro kernel. Packing hundreds of megabytes of unused runtimes into them would be counter-productive.

That means the provided NodeJS runtime will not contain any Java, Python etc., which is obviously sub-optimal if you need any of these.

At the moment your best bet is to create your own custom runtime using a Docker image.

You can find the relevant AWS documentation here:

https://docs.aws.amazon.com/lambda/latest/dg/images-create.html

Your could start with official NodeJS docker image and then install the Java version you need and any other dependencies you might need.


Personal note: if this Lambda is on the critical path of your applications (e.g. users waiting for a response in a web application) you should make sure that your image is as small as possible to reduce cold start times. This is further worsened by the fact that you are trying to do something with Java, which has possibly the worst cold start times in the AWS Lambda world. If possible, I'd look for other options like using Go with the official Sybase (ASE) driver.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.