Thursday, 1 June 2017

J2V8 require scope

I am facing some issues with the J2V8 (https://github.com/eclipsesource/J2V8) library. Namely, I am calling nodeJS functions, in a JS file I wrote (eth.js), from Java with the J2V8 library.

I have discovered the functions themselves need to be global in order for J2V8 to call them. Inside of those functions, calls are being made to the web3 ethereum JS library (https://github.com/ethereum/web3.js). The interesting thing is when the eth.js file is executed from the terminal by running "nodejs eth.js" everything works, and the web3 connection status is logged to the screen.

However, when eth.js is executed from the Java application, this does not happen. The execution hangs when it gets to any web3.eth.* call.

My current hypothesis is the web3.eth.* functions being used in eth.js also need to be global in order to execute when J2V8 calls a function in eth.js

Is there a way I could make the web3 module's exported functions global, or the non exported ones global when I require it in the eth.js file?

Is this issue not caused by scope, and something else entirely?



via aj1996

No comments:

Post a Comment