13
votes

What does this error mean?

What do I need to do to resolve it?

I'm trying to run a java based module for node.js (specifically, xslt4node) on Mac OS El Captain but every time I get this error. Everything seems to work OK for windows users. The full error is below:

dyld: lazy symbol binding failed: Symbol not found: _JNI_CreateJavaVM Referenced from: /projects/main-project/node_modules/java/build/Release/nodejavabridge_bindings.node Expected in: flat namespace

dyld: Symbol not found: _JNI_CreateJavaVM Referenced from: /projects/main-project/node_modules/java/build/Release/nodejavabridge_bindings.node Expected in: flat namespace

I found Undefined symbols for architecture x86_64: JNI_CreateJavaVM OS-X Xcode which is the closest I could find that explains my exact problem, but I'm not using xcode for development, I'm on a node.js platform.

Has anyone else seen this before? What does it mean?

So far I have tried:

  1. Changing Java versions
  2. Deleting and rebuilding node_moudles
  3. Adding JVM capabilities <string>JNI</string>
  4. Uninstalling Java, per documentation here: https://www.java.com/en/download/help/mac_uninstall_java.xml running those commands does nothing:

user:~ kawnah$ sudo rm -fr /Library/PreferencePanes/JavaControlPanel.prefPane user:~ kawnah$ sudo rm -fr ~/Library/Application\ Support/Java user:~ kawnah$ java -version java version "9.0.1" Java(TM) SE Runtime Environment (build 9.0.1+11) Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)

  1. Trying different version of node (7.10.0)
  2. Completely uninstalling node/npm, and reinstalling
4
dyld is the dynamic linking utility in mac osx, JNI is a java technology that allows java to interact with native applications. The error means it can't find this function from JNI interface .. So it may be a clue for you to search. as I have no mac to dig deep - Shady Atef
How are you linking node-java? with flags or extension in a setup file? - RickyM
Have you updated node-java or node.js on the system? Maybe try a different version of node. If you do change versions you may still want to remove node_modules and reinstall. And you may want to try to uninstall node-java completely then do a clean install. - RickyM
I did try a different version with same results (specifically 7.10.0 - which is the version that works for everyone else)I've done multiple clean wipes with different versions of java and node and nothing is working. - kawnah

4 Answers

0
votes

Basically, what this error is telling you is that there's an issue with a symbolic link to a file in this module you're trying to use.

Mac OS X's DYLD is the OS's dynamic linker. Its job is, more or less, to load shared libraries for the OS when resources are requested.

There are a number of reasons this could happen, from a failed update process on the module itself to drive corruption, etc.

The most common fix (1) to this specific issue is to delete your node_modules folder and run a fresh NPM install in both the local and global directories:

rm -rf node_modules/
npm install

You could alternatively attempt a npm rebuild, but a clean install is generally the best route to go.


  1. from the accepted answer here
0
votes

Try to manually enable JNI by editing /Library/Java/JavaVirtualMachines/<version>.jdk/Contents/Info.plist and adding JNI as an option in JVMCapabilities:

<key>JVMCapabilities</key>
<array>
    ...
    <string>JNI</string>
</array>

As found in https://github.com/joeferner/node-java/issues/223#issuecomment-110408072

0
votes

Try an xcode-select --install and then npm rebuild Check this thread, problem seems to be apple's xcode (in your case it could be the c++ compiler),discussion is for ruby vm but might be similar for jvm.

Generally check/update your c++/c compiler and then try anything else ,like choosing another java version and adding JNI to capabilities. Last thing to mention node-gyp needs python version 2.x as mentioned in the README of node-java.

-2
votes

I FINALLY figured it out!

I needed this npm package for node-java to work properly on my machine https://www.npmjs.com/package/winreg

npm install winreg resolved all issues