Where can I find JNA version 5.1.0?

1,195 views
Skip to first unread message

Mikhail Nikitin

unread,
Oct 4, 2018, 4:23:58 PM10/4/18
to Java Native Access
Hi,

I am trying to install a newer-ish EKL stack on Raspberry Pi 2. There were too many troubles with 6.x, so I'm experimenting with 5.6.2. Apparently, none of the stack programs are distributed via "apt", so there is a lot of manual work.
I managed to install Logstash from the right DEB file and by recompiling JFFI library. It takes 30 minutes (!) to start it up Logstash.
Elastic Search also has a DEB package, but it required even more tweaking, and a part of it was rebuilding the JNA library. Now during start-up Elasticsearch complains, that it expects version 5.1.0 of JNA. I got 4.1.0 with, I guess, OpenJDK-8, and I have 6.0.0 and 5.2.1 from this GitHub, but no 5.1.0. I tried to manually change it in Version.java file, but somehow ANT retrieved the right version and put it back.
So my question is - how to (best) get, or (alternatively) simulate version 5.1.0?

Thanks,
Mikhail

Matthias Bläsing

unread,
Oct 5, 2018, 11:59:07 AM10/5/18
to jna-...@googlegroups.com
Hi Mikhail,

Am Donnerstag, den 04.10.2018, 13:23 -0700 schrieb Mikhail Nikitin:
> Elastic Search also has a DEB package, but it required even more
> tweaking, and a part of it was rebuilding the JNA library. Now during
> start-up Elasticsearch complains, that it expects version 5.1.0 of
> JNA. I got 4.1.0 with, I guess, OpenJDK-8, and I have 6.0.0 and 5.2.1
> from this GitHub, but no 5.1.0. I tried to manually change it in
> Version.java file, but somehow ANT retrieved the right version and
> put it back.
> So my question is - how to (best) get, or (alternatively) simulate
> version 5.1.0?

you are freely mixing version numbers with different context. Lets just
stay with JNA. JNA will be released as version 5.0.0 sometime around
the week end / next week. What you are probably seeing is a mismatch of
the version of the native library.

JNA has two parts:
- the java part - this is the interface bindings use
- the native part - this library does the heavy lifting of native calls

The two parts are independently versioned. The java part is the
important one from the perspective of the programmer. The native
library must be compatible with the java parts and they are considered
tightly coupled. You can't mix and mash the two.

Until 5.0.0 JNA was/will load the native part preferred from the system
directory. That made it easy to cause mismatches. If you managed to
build JNA, try running with the system property jna.nosys set to true.

You can smoke test the build JNA version by running:

java -jar <PathToJNAJar>

That command outputs the JNA version of the jar. If that fails, test:

java -Djna.nosys=true -jar <PathToJNAJar>

HTH

Matthias

Mikhail Nikitin

unread,
Oct 5, 2018, 12:50:32 PM10/5/18
to jna-...@googlegroups.com

Hi Matthias,

 

Thanks for the explanation. I’m afraid, though, the issue is more complicated. I apologize for the long post – it’s many lines, but not so much readable text, mainly commands and messages.

 

I installed Elasticsearch from this package:

https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.12.deb

 

It looks like it came with this file:

/usr/share/elasticsearch/lib/jna-4.4.0-1.jar

 

I set up the Java to (among the rest) with

-Djava.class.path=.:/usr/lib/arm-linux-gnueabihf/jni

-Djna.nosys=true

 

You can see the script on https://github.com/mc0re/raspberry-pi (take it with care and, if you want to follow it, with a lot of patience!).

 

When I managed to run the elasticsearch binary on the command line, I got the message I told you about:

 

--= cut =--

java.lang.Error:

 

There is an incompatible JNA native library installed on this system

Expected: 5.1.0

Found:    4.0.0

(at /var/lib/elasticsearch/tmp/jna3030289347622179073.tmp).

--= cut =--

 

Then I got the latest version from https://github.com/java-native-access/jna, and after a really long building process I did this:

 

$ cp dist/*.jar /usr/share/elasticsearch/lib/

 

And hid the original “4.4.0-1” JAR to avoid a “jar hell” message.

 

The error message changed the version:

 

--= cut =--

java.lang.Error:

 

There is an incompatible JNA native library installed on this system

Expected: 5.1.0

Found:    6.0.0

(at /var/lib/elasticsearch/tmp/jna3030289347622179073.tmp).

--= cut =--

 

My next step was to find, where the version is specified, and change it. That didn’t help a bit, the version in the Java file was reverted back.

So I checked the repository and found, when it was changed. And “5.1.0” was not among the changes. So I picked “5.2.1”.

With this setup the error message apparently changed:

 

--= cut =--

[2018-10-05T18:41:23,101][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [netserver-pi] fatal error in thread [main], exiting

java.lang.NoSuchMethodError: com.sun.jna.Native.loadLibrary(Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Object;

        at org.elasticsearch.bootstrap.SystemCallFilter.<clinit>(SystemCallFilter.java:118) ~[elasticsearch-5.6.12.jar:5.6.12]

--= cut =--

 

I wonder where did that “loadLibrary” go, as Native class is still there.

 

 

Interestingly, your hint about “java -jar” produced the same result as the original version check.

 

root@netserver-pi:~# java -jar /usr/share/elasticsearch/lib/jna.jar

Exception in thread "main" java.lang.Error:

 

There is an incompatible JNA native library installed on this system

Expected: 5.2.1

Found:    4.0.0

/usr/java/packages/lib/arm:/usr/lib/arm-linux-gnueabihf/jni:/lib/arm-linux-gnueabihf:/usr/lib/arm-linux-gnueabihf:/usr/lib/jni:/lib:/usr/lib.

 

So, based on your explanation, I guess Elasticsearch comes with own JNA classes hardcoded to expect version 5.1.0 of the native part, but I only have 4.0.0.

 

Now I’m left with two questions:

  • How to get the native part updated to 5.1.0 or 5.2.1?
  • Where did the “loadLibrary” method go in 5.2.1? Can I update to the latest JNA (6.0.0) and get it to work?

 

Does anyone know the answers?

 

Regards,

Mikhail

Matthias Bläsing

unread,
Oct 5, 2018, 12:57:29 PM10/5/18
to jna-...@googlegroups.com
Hi Mikhail,

sorry, bu I won't read all that. You want to get JNA running on a
raspberry pi, then this should do it:

http://repo1.maven.org/maven2/net/java/dev/jna/jna/4.5.2/jna-4.5.2.jar

That is that latest released version of JNA and it should be API
compatible with 4.4.0.

Download that, try to run:

java -jar jna-4.5.2.jar

If that fails - run:

java -Djna.nosys=true -jar jna-4.5.2.jar

Please test

Matthias
> --
> You received this message because you are subscribed to the Google
> Groups "Java Native Access" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to jna-users+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.


Mikhail Nikitin

unread,
Oct 5, 2018, 1:02:59 PM10/5/18
to jna-...@googlegroups.com

Hi Matthias,

 

Thanks, the “nosys” version works.

 

--= cut =--

Java Native Access (JNA) API Version 4

Version: 4.5.2 (b0)

Native: 5.2.2 (74e8f8e397c43487738c5c1f1363498b)

Prefix: linux-arm

--= cut =--

 

But I have “nosys” defined in Elasticsearch’es jvm.options file. Apparently, it does not get propagated. How can I otherwise disable system directory lookup? Or delete some files?

Mikhail Nikitin

unread,
Oct 5, 2018, 1:12:31 PM10/5/18
to jna-...@googlegroups.com

Hi again,

 

One more thing appeared.

I copied the 4.5.2 JAR to the same location as the other JNA JARs, and hid the others. Starting Elasticsearch yielded the following error message. Does it ring a bell?

 

--= cut =--

[2018-10-05T19:08:18,247][WARN ][o.e.b.JNANatives         ] unable to install syscall filter:

java.lang.UnsupportedOperationException: seccomp unavailable: 'arm' architecture unsupported

        at org.elasticsearch.bootstrap.SystemCallFilter.linuxImpl(SystemCallFilter.java:266) ~[elasticsearch-5.6.12.jar:5.6.12]

--= cut =--

 

Thanks,

Mikhail

Matthias Bläsing

unread,
Oct 5, 2018, 2:04:13 PM10/5/18
to jna-...@googlegroups.com
Am Freitag, den 05.10.2018, 19:12 +0200 schrieb Mikhail Nikitin:
> One more thing appeared.
> I copied the 4.5.2 JAR to the same location as the other JNA JARs,
> and hid the others. Starting Elasticsearch yielded the following
> error message. Does it ring a bell?
>
> --= cut =--
> [2018-10-05T19:08:18,247][WARN ][o.e.b.JNANatives ] unable to
> install syscall filter:
> java.lang.UnsupportedOperationException: seccomp unavailable: 'arm'
> architecture unsupported
> at
> org.elasticsearch.bootstrap.SystemCallFilter.linuxImpl(SystemCallFilt
> er.java:266) ~[elasticsearch-5.6.12.jar:5.6.12]
> --= cut =--

If I remember correctly seccomp is a mechanism to limit capabilities of
the process. I guess the seccomp filter is used to limit the
systemcalls can can be done from the process.


> Thanks, the “nosys” version works.
>
> --= cut =--
> Java Native Access (JNA) API Version 4
> Version: 4.5.2 (b0)
> Native: 5.2.2 (74e8f8e397c43487738c5c1f1363498b)
> Prefix: linux-arm
> --= cut =--
>
> But I have “nosys” defined in Elasticsearch’es jvm.options file.
> Apparently, it does not get propagated. How can I otherwise disable
> system directory lookup? Or delete some files?

Beware! You can't just add "jna.nosys=true" to jvm.options. If I see
the syntax correctly, these are arguments to the java launcher, that
would be:

-Djna.nosys=true

see here:

https://www.elastic.co/guide/en/elasticsearch/reference/current/jvm-options.html

Greetings

Matthias

Mikhail Nikitin

unread,
Oct 5, 2018, 2:39:04 PM10/5/18
to jna-...@googlegroups.com

Hi,

 

Do you know where is this “seccomp” defined, so I can try and get the arm version?

 

Yes, I add “-Djna.nosys=true”.

 

Do you have any ides how I can update the native part of JNA?

 

Mikhail

 

From: Matthias Bläsing
Sent: 05 October 2018 20:04
To: jna-...@googlegroups.com
Subject: Re: Where can I find JNA version 5.1.0?

 

Am Freitag, den 05.10.2018, 19:12 +0200 schrieb Mikhail Nikitin:

--

Matthias Bläsing

unread,
Oct 6, 2018, 4:05:04 PM10/6/18
to jna-...@googlegroups.com
Hi Mikhail,

Am Freitag, den 05.10.2018, 20:39 +0200 schrieb Mikhail Nikitin:
>
> Do you know where is this “seccomp” defined, so I can try and get the
> arm version?
>
> Yes, I add “-Djna.nosys=true”.
>
> Do you have any ides how I can update the native part of JNA?
>

this might sound rude, but you need to improve your google-fo. These
questions are not at all tied to JNA.

Out of curiosity, I pulled out my rapsberry pi 1 and setup
elasticsearch.

Before you beginn: 512MB RAM and elasticsearch is not fun.

1. Start with Raspbian Stretch Lite
https://www.raspberrypi.org/downloads/raspbian/

2. Install openjdk-8-jdk:
apt-get update
apt-get install openjdk-8-jdk

3. Grab the current build of elastic search (6.4.2):
https://www.elastic.co/de/downloads/elasticsearch-oss
Choose "MAXOS/LINUX" download

4. Expand the downloaded tar.gz
tar xzvf elasticsearch-oss-6.4.2.tar.gz

5. remove jna-4.5.1.jar from the lib directory and download jna-
4.5.2.jar from maven central (4.5.2 contains fixed native library):

cd elasticsearch-6.4.2/lib
rm jna-4.5.1.jar
wget https://repo1.maven.org/maven2/net/java/dev/jna/jna/4.5.2/jna-4.5.2.jar

6. Adjust jvm.options so that elasticsearch fits into 512MB RAM

-Xms256m
-Xmx256m

7. Adjust elasticsearch.yml for testing:

# Adjust cluster name
cluster.name: test
# Bind to public IP
network.host: 0.0.0.0
# Disable seccomp protection
# (not sure if necessary, but is not supported on arm anyway)
bootstrap.system_call_filter: false
# Prevent bootstrap checks to prevent startup
discovery.type: single-node


8. run elasticsearch:

bin/elasticsearch -v

9. Wait till the console reports the server started

=> Works, I can access the http elasticsearch interface via:
http://raspberrypi:9200/


I don't now what the deb does differently, but the tar.gz works
beautifully.

Greetings

Matthias

Mikhail Nikitin

unread,
Oct 7, 2018, 3:55:20 AM10/7/18
to jna-...@googlegroups.com

Thanks a lot! Now it runs 😊

Now I only need to make it as a service and get Logstash upgraded to 6.4.2, then.

 

The differences are:

  • Dpkg distributes the files into different directories, and that includes Java libraries, so they are harder to track
  • You added two properties that originally were not in “jvm.options” file

 

Thanks again!

 

Mikhail

 

From: Matthias Bläsing
Sent: 06 October 2018 22:05
To: jna-...@googlegroups.com
Subject: Re: Where can I find JNA version 5.1.0?

 

Hi Mikhail,

--

Reply all
Reply to author
Forward
0 new messages