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

Unhandled Java exception: java.lang.NoClassDefFoundError: Could not initialize class jnr.enxio.channels.Native$SingletonHolder #3660

Closed
dhinojosa opened this issue Feb 12, 2016 · 5 comments

Comments

@dhinojosa
Copy link

On Ubuntu 15.10 (Wiley) and any JRuby 9000 version. Any invocation of jruby or jirb returns the following error (elided to keep it brief)

Unhandled Java exception: java.lang.NoClassDefFoundError: Could not initialize class jnr.enxio.channels.Native$SingletonHolder
java.lang.NoClassDefFoundError: Could not initialize class jnr.enxio.channels.Native$SingletonHolder
                 libc at jnr/enxio/channels/Native.java:69
                write at jnr/enxio/channels/Native.java:112
                write at jnr/enxio/channels/NativeDeviceChannel.java:86
                write at org/jruby/util/io/PosixShim.java:102
...

Per the documentation I checked that update-alternatives for both java and javac were correct:

sudo update-alternatives --config java   
  Selection    Path                                            Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      auto mode
  1            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      manual mode
  2            /usr/lib/jvm/jdk1.7.0/bin/java                   1         manual mode
  3            /usr/lib/jvm/jdk1.7.0_21/bin/java                1         manual mode
  4            /usr/lib/jvm/jdk1.7.0_45/bin/java                1         manual mode
  5            /usr/lib/jvm/jdk1.7.0_55/bin/java                1         manual mode
  6            /usr/lib/jvm/jdk1.8.0/bin/java                   2         manual mode
  7            /usr/lib/jvm/jdk1.8.0_05/bin/java                1         manual mode
  8            /usr/lib/jvm/jdk1.8.0_40/bin/java                1         manual mode
* 9            /usr/lib/jvm/jdk1.8.0_65/bin/java                1         manual mode
sudo update-alternatives --config javac   
  Selection    Path                                Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/jdk1.8.0/bin/javac      2         auto mode
  1            /usr/lib/jvm/jdk1.7.0/bin/javac      1         manual mode
  2            /usr/lib/jvm/jdk1.7.0_21/bin/javac   1         manual mode
  3            /usr/lib/jvm/jdk1.7.0_45/bin/javac   1         manual mode
  4            /usr/lib/jvm/jdk1.7.0_55/bin/javac   1         manual mode
  5            /usr/lib/jvm/jdk1.8.0/bin/javac      2         manual mode
  6            /usr/lib/jvm/jdk1.8.0_05/bin/javac   1         manual mode
  7            /usr/lib/jvm/jdk1.8.0_40/bin/javac   1         manual mode
* 8            /usr/lib/jvm/jdk1.8.0_65/bin/javac   1         manual mode

The workaround is to add the following to your favorite profile or rc

export JRUBY_OPTS=-J-Djava.library.path=/usr/lib64

Requesting either fix, or better documentation on wiki for Ubuntu users

I can craft a pull-request for docs if needed.

@mkristian
Copy link
Member

never had problems on ubuntu before. it is a bug. how did you install those jdk1.8.x ? via apt ? which repo ? does it fail on any jdk version ? like the openjdk ones ?

@dhinojosa
Copy link
Author

I unpack a Java JDK onto /usr/lib/jvm from there I invoke:

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.0_65/bin/java 1
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.8.0_65/bin/javac 1
sudo update-alternatives --install /usr/bin/java javap /usr/lib/jvm/jdk1.8.0_65/bin/javap 1

and so on....

I then configure each one to select the latest if need be...

sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config javap

and so on...

I also point JAVA_HOME to my preferred JDK (e.g.): /usr/lib/jvm/jdk1.8.0_65

@headius
Copy link
Member

headius commented Feb 13, 2016

I believe I saw @dhinojosa managed to fix this locally with -J-Djava.library.path=/usr/lib64, correct? The search logic in jnr-ffi or jffi should be locating the right path...I guess we're still missing something :-(

@headius headius added this to the JRuby 9.1.0.0 milestone Feb 13, 2016
@dhinojosa
Copy link
Author

@headius I am not as familiar of this jnr-ffi, but found it on github. Is there a functional test that I can run on my machine to help determine what logic is missing (cc: @mkristian)

@headius
Copy link
Member

headius commented Apr 20, 2016

@dhinojosa If you can remember exactly what you did to fix this, please update the bug or add something to https://github.com/jruby/jruby/wiki/Native-Libraries.

I'm not sure if there's anything to fix here until we get a clear picture of what the environment looked like and how you were able to fix it. I suspect this is the same as other lib64 issues we've been dealing with for a while, and it may be improved in 9.1.

I'm going to close this.

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

No branches or pull requests

3 participants