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

Error: A JNI error has occurred, please check your installation and try again #3226

Closed
ajatkj opened this issue Jul 30, 2024 · 2 comments
Closed

Comments

@ajatkj
Copy link

ajatkj commented Jul 30, 2024

Hi,

I am trying to start up the server but getting below error.

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsatisfiedLinkError: 'void java.util.zip.Inflater.initIDs()'
	at java.base/java.util.zip.Inflater.initIDs(Native Method)
	at java.base/java.util.zip.Inflater.<clinit>(Inflater.java:116)
	at java.base/java.util.zip.ZipFile$CleanableResource.getInflater(ZipFile.java:735)
	at java.base/java.util.zip.ZipFile$ZipFileInflaterInputStream.<init>(ZipFile.java:427)
	at java.base/java.util.zip.ZipFile.getInputStream(ZipFile.java:394)
	at java.base/java.util.jar.JarFile.getBytes(JarFile.java:800)
	at java.base/java.util.jar.JarFile.getManifestFromReference(JarFile.java:419)
	at java.base/java.util.jar.JarFile.getManifest(JarFile.java:406)
	at java.base/sun.launcher.LauncherHelper.getMainClassFromJar(LauncherHelper.java:562)
	at java.base/sun.launcher.LauncherHelper.loadMainClass(LauncherHelper.java:787)
	at java.base/sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:695)

I am running:

/bin/jdtls -configuration ~/.cache/jdtls -data ./output

jdtls version jdt-language-server-1.37.0-202406271335

Output of java -version

java -version                                                                                                                                                                                    
openjdk version "17.0.12" 2024-07-16
OpenJDK Runtime Environment Homebrew (build 17.0.12+0)
OpenJDK 64-Bit Server VM Homebrew (build 17.0.12+0, mixed mode, sharing)

JAVA_HOME is correctly set as:

echo $JAVA_HOME               
/Library/Java/JavaVirtualMachines/openjdk-17.jdk/Contents/Home

ls -1 --icons=never $JAVA_HOME
lib
demo
man
bin
include
release
legal
conf
jmods

Running on MacOS Sonoma 14.5 on MacBook Apple Pro M1

uname   
Darwin

I haven't found anything in existing issues regarding this.

Let me know if any more details required.

Any help will be highly appreciated as I have already spent too much time to figure this out.

@rgrunber
Copy link
Contributor

rgrunber commented Aug 2, 2024

Do you have a file called /Library/Java/JavaVirtualMachines/openjdk-17.jdk/Contents/Home/lib/libzip.so or any filed called libzip.so within that java home directory ? That shared library should contain the initIDs function : https://github.com/openjdk/jdk17/blob/4afbcaf55383ec2f5da53282a1547bac3d099e9d/src/java.base/share/native/libzip/Inflater.c#L48-L55 .

This is basically where it fails :

https://github.com/openjdk/jdk17/blob/4afbcaf55383ec2f5da53282a1547bac3d099e9d/src/java.base/share/classes/java/util/zip/Inflater.java#L114-L117

@ajatkj
Copy link
Author

ajatkj commented Aug 3, 2024

@rgrunber Thanks. That was it. I had libzip.dylib (MacOS) already installed as dependency of other software (installed using homebrew) so openjdk17 (also installed using homebrew) was symlinking to that lib. I removed said software and reinstalled openjdk17 which downloaded the correct libzip.dylib which has this method.

For anyone else facing the same issue, you can run below command to see if the method is present in a lib (on macOS):

objdump -t libzip.dylib | grep -i init

000000000000c1a8 l     O __DATA,__bss _InitializeZip.inited
000000000000437c g     F __TEXT,__text _Java_java_util_zip_Deflater_init
0000000000004bac g     F __TEXT,__text _Java_java_util_zip_Inflater_init
0000000000004b34 g     F __TEXT,__text _Java_java_util_zip_Inflater_initIDs
0000000000006fb4 g     F __TEXT,__text _ZIP_GZip_InitParams
0000000000000000         *UND* _deflateInit2_
0000000000000000         *UND* _inflateInit2_

Closing this issue!.

@ajatkj ajatkj closed this as completed Aug 3, 2024
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

2 participants