Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem using nw.js with node-java #5398

Closed
vrmerlin opened this issue Oct 24, 2016 · 9 comments
Closed

problem using nw.js with node-java #5398

vrmerlin opened this issue Oct 24, 2016 · 9 comments

Comments

@vrmerlin
Copy link

I'm attempting to put together a simple example that demonstrates NW.js working with the node-java package. Here is my package.json file:

{
  "name": "nw_java_test",
  "version": "1.0.0",
  "description": "",
  "main": "index_plain.html",
  "dependencies": {
    "bower": "^1.7.9",
    "java": "^0.7.2",
    "nw": "^0.18.2"
  }
}

I have an index_plain.html file that's fairly simple, and references a sample.js file. In that sample.js file, I have this entry:

var java = require('java');

When I run nw on the index_plain.html (node_modules/.bin/nw .), I get this error:

/u/fisher23/nwJavaTest/node_modules/nw/nwjs/nw: symbol lookup error: /u/fisher23/nwJavaTest/node_modules/java/build/Release/nodejavabridge_bindings.node: undefined symbol: _ZN2v816FunctionTemplate3NewEPNS_7IsolateEPFvRKNS_20FunctionCallbackInfoINS_5ValueEEEENS_5LocalIS4_EENSA_INS_9SignatureEEEi

If I remove the require('java') line, this error goes away (but of course I can't use Java).

Why am I getting this error?

Thanks,
John

@vrmerlin
Copy link
Author

Any ideas out there? This is a "show stopper" for us, and NW.js looks really promising. :-(

@RohitSharma27
Copy link

Your NW and OS' version?

@vrmerlin
Copy link
Author

The NW version is 0.18.2 and the OS version is Red Hat Enterprise Linux Workstation release 7.2 (Maipo).

@vrmerlin
Copy link
Author

Well, I'm not quite sure what changed to make it start working, but with this package.json:

{
  "name": "nw_java_test",
  "version": "1.0.0",
  "description": "",
  "main": "index_plain.html",
  "dependencies": {
    "bower": "^1.7.9",
    "java": "^0.7.2",
    "nw": "^0.18.3"
  }
}

I'm getting this error:

module.js:642
  return process.dlopen(module, path._makeLong(filename));
                 ^

Error: The module '/u/fisher23/nwJavaTest/node_modules/java/build/Release/nodejavabridge_bindings.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 48. This version of Node.js requires
NODE_MODULE_VERSION 51. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or`npm install`).
    at Object.Module._extensions..node (module.js:642:18)
    at Module.load (module.js:514:32)
    at tryModuleLoad (module.js:473:12)
    at Function.Module._load (module.js:465:3)
    at Module.require (module.js:524:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/u/fisher23/nwJavaTest/node_modules/java/lib/nodeJavaBridge.js:21:16)
    at Module._compile (module.js:597:32)
    at Object.Module._extensions..js (module.js:612:10)
    at Module.load (module.js:514:32)

My impression from reading http://docs.nwjs.io/en/latest/For%20Users/Advanced/Use%20Native%20Node%20Modules/ is that I don't need to do any special rebuilds ("In 0.14.x LTS release, native modules built by node-gyp or npm in upstream can be supported.") for this to work. What might I be doing wrong?

Thanks,
John

@RohitSharma27
Copy link

Well...I am a Mac and windows guy. So, can't help you with the Linux. Although I have been doing the development on LTS version yet I remember that the V8 has got ABI changes in 0.18.x. You'll need to rebuild your module using nw-gyp. The line that you have stated above is true for LTS version. See if this helps you. :)

@RohitSharma27
Copy link

See this #5025

@ghostoy
Copy link
Member

ghostoy commented Oct 27, 2016

The V8 version used in NW.js 0.18.2 is different from official Node.js. You have to rebuild all native modules with nw-gyp. If it still won't work, please respond here.

@vrmerlin
Copy link
Author

Ok, I was able to get it to work. For future reference, here is my package.json:

{
  "name": "nw_java_test",
  "version": "1.0.0",
  "description": "",
  "main": "index_plain.html",
  "dependencies": {
    "java": "git+https://github.com/joeferner/node-java.git",
    "nw": "^0.18.3"
  }
}

(I'm grabbing the node-java out of the master branch because of a problem described in node-java #359 ). My build script is as follows:

#!/bin/bash

npm install 

cd node_modules/java
nw-gyp rebuild --target=0.18.3 --arch=x64
npm run postinstall
cd ../..

@AnnamrajuSarvani
Copy link

AnnamrajuSarvani commented May 23, 2017

Hi,
I am getting version issues I am using nw 0.22.3 and tried lower nw versions but I get above error. Node: 6.10.3, java: jdk 1.8.0 and jre 1.8.0
The module '/home/cronj-10/Sarvani/offline-sample-app-new/node_modules/java/build/Release/nodejavabridge_bindings.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 47. This version of Node.js requires
NODE_MODULE_VERSION 51.

I re-compiled with nw-gyp build --target=nw-version(0.22.3)
My node-java version 0.8.0.
What is issue in building? How to fix this?
I am using ubuntu14.04

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants