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

Docker Java Native Library java.lang.UnsatisfiedLinkError: no vw_jni in java.library.path #894

Closed
adgaudio opened this issue Dec 22, 2015 · 4 comments · Fixed by #904
Closed

Comments

@adgaudio
Copy link
Contributor

Hi,

We have a java project that uses VW, and we love it! However, when the java code runs in an Ubuntu 14.04 docker container, it can't load the native bindings. I figured out why this happens and will propose a solution at the bottom of this issue description.

The Error: The following traceback occurs when we run our java program inside a docker container that inherits from Ubuntu:14.04.

[info] java.lang.UnsatisfiedLinkError: no vw_jni in java.library.path
[info]  at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1864)
[info]  at java.lang.Runtime.loadLibrary0(Runtime.java:870)
[info]  at java.lang.System.loadLibrary(System.java:1122)
[info]  at vw.jni.NativeUtils.loadOSDependentLibrary(NativeUtils.java:116)
[info]  at vw.learner.VWLearners.loadNativeLibrary(VWLearners.java:85)
[info]  at vw.learner.VWLearners.initializeVWJni(VWLearners.java:73)
[info]  at vw.learner.VWLearners.create(VWLearners.java:44)

Why this happens:
Looking at VW source code for java/src/main/java/vw/jni/NativeUtils.java, a function named getDistroName directly queries /proc/version (see source). In docker, this returns the host's kernel version, which may not be Ubuntu. (If you use docker-machine, /proc/version returns information about the docker-machine VM that the container runs in). What we actually want it to do, as far as I understand, is query the container OS version, which is Ubuntu 14.04.

Possible Solution:
For better compatibility with VW in docker containers, I suggest we don't query /proc/version. What if, instead, we replace the linux-specific contents of getDistroName with lsb_release -i? Since we already use lsb_release -r for getLinuxVersion, this seems to make quite a bit of sense to me, and I believe it will work in a docker container.

I'd love to get your feedback and would be happy to submit a PR if necessary.

@adgaudio
Copy link
Contributor Author

A colleague just made me aware of a related issue, #807, which suggests querying /etc/os-release.

Previous attempts linked to #807:
#780
#822

@JohnLangford
Copy link
Member

This has been a persistent issue, so it would be nice to get it solved. @jmorra @deaktator have been the primary ones working on the java interface, but if you want to work on a patch for them, that may work well.

@jmorra
Copy link
Collaborator

jmorra commented Dec 23, 2015

I'm fine with changing this as long as it continues to work on Mac and builds with build.sh I have no problem with any change. @adgaudio is this something you can work on?

@adgaudio
Copy link
Contributor Author

Sure, I'd love to do it. I plan to submit a PR by next week.

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

Successfully merging a pull request may close this issue.

3 participants