Pi w/Jessie and running Java apps

3 posts / 0 new
Last post
rip
rip's picture
Offline
Last seen: 2 months 1 week ago
Joined: 04/06/2012
Posts: 324
Pi w/Jessie and running Java apps

Anyone with experience running DDS with Java on Jessie on Raspberry Pi?

I can't tell if this is a unix problem, Java problem, config problem, or a DDS problem.

uname -a reports:  Linux ... 4.1.13+ ... armv6l GNU/Linux.  Is Jessie the correct kernel for the 5.2.0 Raspberry Pi build available in the Downloads?  Should I downgrade to the older Wheezy install?  The tools (spy, ping) work without issue, however they are prelinked.

Java version on the Pi is 1.8.0-b132

Env variables set by the rti-supplied configuration (.bash) script.

Trying to run a java application (built under Windows) Java attempt returns:

pi@frog:~ java -classpath "." -jar PiOtaDemo.jar PiOtaEngine
java -classpath "." -jar PiOtaDemo.jar PiOtaEngine
The library libnddsjava.so could not be loaded by Linux.
Make sure that the library is in your LD_LIBRARY_PATH environment variable.
Exception in thread "main" java.lang.UnsatisfiedLinkError: no nddsjava in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857)
        at java.lang.Runtime.loadLibrary0(Runtime.java:870)
        at java.lang.System.loadLibrary(System.java:1119)
        at com.rti.dds.util.NativeInterface.loadNativeLibrary(Unknown Source)
        at com.rti.dds.util.NativeInterface.loadNativeLibraries(Unknown Source)
        at com.rti.dds.domain.DomainParticipantFactory.<clinit>(Unknown Source)
        at demo.rip.utils.DDSDomain.<init>(DDSDomain.java:82)
        at PiOtaEngine.main(PiOtaEngine.java:15)
pi@frog:~ $
pi@frog:~ $ echo $LD_LIBRARY_PATH
/home/pi/omgdds/rti_connext_dds-5.2.0/lib/armv6vfphLinux3.xgcc4.7.2:
pi@frog:~ $ ls /home/pi/omgdds/rti_connext_dds-5.2.0/lib/armv6vfphLinux3.xgcc4.7.2/libnddsjava.so
/home/pi/omgdds/rti_connext_dds-5.2.0/lib/armv6vfphLinux3.xgcc4.7.2/libnddsjava.so
pi@frog:~ $ 

Going down the rat's hole of OBJDUMP NEEDED, I find these are sourced:

pi@frog:~ $ ./depwalk -sticky /home/pi/omgdds/rti_connext_dds-5.2.0/lib/armv6vfphLinux3.xgcc4.7.2/libnddsjava.so
/home/pi/omgdds/rti_connext_dds-5.2.0/lib/armv6vfphLinux3.xgcc4.7.2/libnddsjava.so
  NEEDED               libpthread.so.0 (nofollow)
  NEEDED               libc.so.6 (nofollow)
  NEEDED               librt.so.1 (nofollow)
  NEEDED               libnddsc.so
/home/pi/omgdds/rti_connext_dds-5.2.0/lib/armv6vfphLinux3.xgcc4.7.2/libnddsc.so
  NEEDED               libnddscore.so
/home/pi/omgdds/rti_connext_dds-5.2.0/lib/armv6vfphLinux3.xgcc4.7.2/libnddscore.so
  NEEDED               libgcc_s.so.1 (nofollow)

(./depwalk is just a perl script that walks the dependency tree, reports any dependency only once, and -sticky means (nofollow)).

I welcome suggestions on where to look next.

 

 

Organization:
Keywords:
Fernando Garcia's picture
Offline
Last seen: 1 month 2 weeks ago
Joined: 05/18/2011
Posts: 200

Hi Rip,

I know that at least on Ubuntu (since Ubuntu 9.04) you can no longer set the LD_LIBRARY_PATH inside an interactive shell. You may be running into the same problem on Debian, but I do not have a way to reproduce it. Can you check this solution?

Thanks,
Fernando.

rip
rip's picture
Offline
Last seen: 2 months 1 week ago
Joined: 04/06/2012
Posts: 324

Hi Fernando,

The files and commands could be created/executed, but the result is the same. 

While testing, I noticed that if I run the code this way:

pi@frog:~ $ java -classpath ".:PiOtaDemo.jar" PiOtaEngine
DDSDomain:  Ignore Self set.
wiringPiSetup: Must be root. (Did you forget sudo?)
pi@frog:~ $

But if I try to run it under sudo:

pi@frog:~ $ sudo !!
sudo java -classpath ".:PiOtaDemo.jar" PiOtaEngine
The library libnddsjava.so could not be loaded by Linux.
Make sure that the library is in your LD_LIBRARY_PATH environment variable.
Exception in thread "main" java.lang.UnsatisfiedLinkError: no nddsjava in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857)
        at java.lang.Runtime.loadLibrary0(Runtime.java:870)
        at java.lang.System.loadLibrary(System.java:1119)
        at com.rti.dds.util.NativeInterface.loadNativeLibrary(Unknown Source)
        at com.rti.dds.util.NativeInterface.loadNativeLibraries(Unknown Source)
        at com.rti.dds.domain.DomainParticipantFactory.<clinit>(Unknown Source)
        at demo.rip.utils.DDSDomain.<init>(DDSDomain.java:82)
        at PiOtaEngine.main(PiOtaEngine.java:15)

What's interesting is that the DDSDomain:  Ignore Self set log message happens after the participant is created -- when does the libnddsjava.so file need to be pulled in?   I would expect that it was before participant = DomainParticipantFactory.TheParticipantFactory.create_participant(...) certainly.

I'm also trying to use Pi4J to get access to the GPIO pins etc.  It requires (pseudo-) root privileges, but (it looks like) elevation changes something and then the DDS stuff can't be found.  Setting the library path in ld.so.conf.d .conf should work around that (in my mind), but it doesn't appear to.

As a test, I did this:

pi@US-LG-PI-US1:~ $ sudo  LD_LIBRARY_PATH=$LD_LIBRARY_PATH java -classpath ".:PiOtaDemo.jar" PiOtaEngine
DDSDomain:  Ignore Self set.
Exception in thread "main" java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Byte
        at com.rti.dds.infrastructure.ByteSeq.add(Unknown Source)
        at java.util.AbstractList.add(AbstractList.java:108)
        at com.rti.dds.util.AbstractSequence.add(Unknown Source)
        at com.utimaco.iot.ota.Thing.<init>(Thing.java:45)
        at PiOtaEngine.main(PiOtaEngine.java:22)

Hey presto, a bug in my code.

"Linux is very user friendly.  Sadly, it picks its own friends."

Any Deep Linux thinkers reading this, that can explain this oddity?

Thanks for your help, Fernando!

rip