node-jt400 icon indicating copy to clipboard operation
node-jt400 copied to clipboard

Multiple instances of node-java based programs causing "Aborted (core dumped)"

Open crimsonhawk009 opened this issue 6 years ago • 1 comments

I have been using node-jt400 for some time now and I have run into an interesting problem.

I was integrating some custom internal Java programs and ran into this when I started to include them on models that I was using node-jt400.

As soon as two modules using node-java are called it will core dump.

I have an example of it failing located here. node-java-error

Though I feel the problem lies in node-java I have been developing a version of node-jt400 for internal use that allows me to pass an existing node-java instance to it.

I am not sure if you have run into the same problem and either have worked around it or have a fix for it. But if there is interest I will develop it further and make a pull request when done, if not close the issue stating as such.

I have it working but it is not ready for a pull request yet. The changes are not in Typescript and it is a breaking change as you have initialize it before use, but here is the branch. use-existing-node-java

There is two ways of using it.

First without an existing node-java instance.

const as400 = require('node-jt400')();
const pool = as400.pool(config);

Then with an existing instance

const java = require('java');
java.classpath.push(`${__dirname}/java`);
const as400 = require('node-jt400')(java);
const pool = as400.pool(config);

A major caveat with the second one is because node-java requires that you to set up the classpath before calling any Java methods. You have to pass any class paths to node-java before you initialize node-jt400.

crimsonhawk009 avatar Jul 02 '18 14:07 crimsonhawk009

Hi crimsonhawk009

We have not been running into this problem at Tryggingamiðstöðin as we don't use other Java programs together with node-jt400.

But as it might be useful for someone else who would like to use this library, we'd be happy to see it developed further and merged.

OlafurTorfi avatar Jul 04 '18 10:07 OlafurTorfi