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

libjvm.so is looked for in the wrong place #428

Closed
maxnoe opened this issue Jun 27, 2019 · 12 comments
Closed

libjvm.so is looked for in the wrong place #428

maxnoe opened this issue Jun 27, 2019 · 12 comments

Comments

@maxnoe
Copy link

maxnoe commented Jun 27, 2019

On travis, even with JAVA_HOME set, the library is not found.

It is actually in:

/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/libjvm.so

But pyjnius looks in:

/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/server/libjvm.so
@maxnoe maxnoe changed the title libjvm.so is search in the wrong place libjvm.so is lloked for in the wrong place Jun 27, 2019
@maxnoe maxnoe changed the title libjvm.so is lloked for in the wrong place libjvm.so is oloked for in the wrong place Jun 27, 2019
@maxnoe maxnoe changed the title libjvm.so is oloked for in the wrong place libjvm.so is looked for in the wrong place Jun 27, 2019
@julianhess
Copy link

You need to set JDK_HOME to /usr/lib/jvm/java-8-openjdk-amd64/; setup.py does not check JAVA_HOME. See:

JDK_HOME = getenv('JDK_HOME')

@maxnoe
Copy link
Author

maxnoe commented Jul 12, 2019

Why do I need to set it at all? Why not take the java(c) that's in the PATH my default?

@maxnoe
Copy link
Author

maxnoe commented Jul 12, 2019

Oh wait. It does. Neither is the problem here!

The problem is the additional amd64 in the path.

@julianhess
Copy link

julianhess commented Jul 12, 2019

You need to rebuild the package with JDK_HOME already set as above; merely setting it after building will do nothing.

I kept running into this issue too until I dug through the source and found that the path to libjvm.so gets baked in during compilation (try running strings jnius.cpython-37m-x86_64-linux-gnu.so | grep libjvm)

See here:

IF JNIUS_PYTHON3:
try:
jnius_lib_suffix = JNIUS_LIB_SUFFIX.decode("utf-8")
except AttributeError:
jnius_lib_suffix = JNIUS_LIB_SUFFIX
lib_path = str_for_c(os.path.join(JAVA_HOME, jnius_lib_suffix))

JNIUS_LIB_SUFFIX is defined in config.pxi, which is dynamically generated by setup.py.

@tshirtman
Copy link
Member

tshirtman commented Nov 30, 2019

hopefully this should be solved by the changes i did in the #443 #444 PR, which will provide wheels able to do this check at runtime, and try to be smarter about the lookup.

@tshirtman
Copy link
Member

Closing as i believe this to be fixed, let us know if you still have issues.

@maxnoe
Copy link
Author

maxnoe commented Dec 5, 2019

Just commenting: the PR you linked only changes a single line of whitespace. Wrong PR?

@tshirtman
Copy link
Member

indeed that was #444 thanks for pointing out.

@mashabelyi
Copy link

I am having the same issue with the most recent version, even after setting both JAVA_HOME and JDK_HOME to my java path: /usr/lib/jvm/java-8-oracle.

In my case pyjnius is looking in

/usr/lib/jvm/java-8-oracle/lib/server/libjvm.so

but the actual path is

/usr/lib/jvm/java-8-oracle/jre/lib/amd64/server/libjvm.so

I tried adding /usr/lib/jvm/java-8-oracle/jre/lib/amd64/server to the PATH env variable too. But still get the same error on import:

SystemError: Error calling dlopen(b'/usr/lib/jvm/java-8-oracle/lib/server/libjvm.so': b'/usr/lib/jvm/java-8-oracle/lib/server/libjvm.so: cannot open shared object file: No such file or directory'

@chemu-patent-ie
Copy link

I am also having an issue. This is a dependency for something else I'm trying to install.

My $JAVA_HOME and $JDK_HOME are correctly set. When I go to the path they point to and look for libjvm I see:

$ find . -name "libjvm*"
./jre/bin/classic/libjvm.so
./jre/bin/j9vm/libjvm.so
./jre/lib/amd64/classic/libjvm.so
./jre/lib/amd64/compressedrefs/libjvm.so
./jre/lib/amd64/default/libjvm.so
./jre/lib/amd64/j9vm/libjvm.so

No "server" directory at all.

SystemError: Error calling dlopen(b'/usr/lib/jvm/java-1.8.0-ibm-1.8.0.6.5-1jpp.1.el7.x86_64/lib/server/libjvm.so': b'/usr/lib/jvm/java-1.8.0-ibm-1.8.0.6.5-1jpp.1.el7.x86_64/lib/server/libjvm.so: cannot open shared object file: No such file or directory'

Is the problem my Java version or something else?

@tshirtman tshirtman reopened this Apr 13, 2020
@tshirtman
Copy link
Member

tshirtman commented Apr 24, 2020

#520 for a tentative fix + workaround
if things go well, https://github.com/kivy/pyjnius/actions/runs/87203882 should produce wheel packages that you can test on your systems to confirm if this helps.

I added the paths you both reported, and added a system to override the value through a non standard JVM_PATH en var if that doesn't work, with a message encouraging people to report working values, hopefuly it'll allow us to understand what paths are actually used in the wild.

edit: test wheels can be found here https://github.com/kivy/pyjnius/releases/tag/issue_428-test

tshirtman added a commit that referenced this issue May 2, 2020
@tshirtman
Copy link
Member

closing as i hope this to be fixed, if the error happens again, please open a new issue refering to this one.

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

5 participants