Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2008

Tip: Looking for answers? Try searching our database.

is jni.h platform / VM specific?

Thread view: 
Dzikus - 29 Jan 2008 08:19 GMT
Hello,
During runtime on target device I get following error when loading my
JNI library:

Exception in thread "main" java.lang.UnsatisfiedLinkError: MyLibrary
(Unresolved symbols)

Is it possible that root cause is I compile it with incompatible jni.h
header?
Library name and location (LD_LIBRARY_PATH) are correct.

Than you in advance
  Dominik
Gordon Beaton - 29 Jan 2008 08:18 GMT
> During runtime on target device I get following error when loading my
> JNI library:
[quoted text clipped - 5 lines]
> header?
> Library name and location (LD_LIBRARY_PATH) are correct.

The library itself is dependent on additional libraries that can't be
found at runtime. What makes you suspect jni.h specifically?

Use e.g. ldd libname.so to see the dependencies, and determine which
ones can't be resolved.

/gordon

--
Dzikus - 29 Jan 2008 09:02 GMT
> The library itself is dependent on additional libraries that can't be
> found at runtime. What makes you suspect jni.h specifically?
[quoted text clipped - 5 lines]
>
> --
Unfortunately I don't have ldd available on target :/
On build platform it does not work:

$ ldd libMyLib.so
./libMyLib.so:
ldd: ./libMyLib.so: Exec format error

I suspect jni.h because I worked with VM from another supplier before,
and jni.h (and other headers) was delivered together with VM.
This dedicated version of jni.h differs from standard Sun's jni.h

Full error message:

...
class load: java/util/jar/Attributes$Name
class load: MyLib/Application
class load: MyLib.Application from: file:XXXXX
class load: App
class load: App from: file:XXXXX
unknown relocation type
unknown relocation type
...
unknown relocation type
unknown relocation type
class load: java/lang/LinkageError
class load: java/lang/UnsatisfiedLinkError
Exception in thread "main" java.lang.UnsatisfiedLinkError: MyLib
(Unresolved symbols)
class load: java/lang/StackTraceElement[]
       at java.lang.ClassLoader.loadLibraryWithPath(Unknown Source)
       at java.lang.ClassLoader.loadLibraryWithClassLoader(Unknown
Source)
       at java.lang.System.loadLibrary(Unknown Source)
       at jsal.Application.<clinit>(Unknown Source)
       at java.lang.J9VMInternals.initializeImpl(Native Method)
       at java.lang.J9VMInternals.initialize(Unknown Source)
       at java.lang.J9VMInternals.initialize(Unknown Source)
Gordon Beaton - 29 Jan 2008 09:59 GMT
>> The library itself is dependent on additional libraries that can't be
>> found at runtime. What makes you suspect jni.h specifically?
[quoted text clipped - 7 lines]
> Unfortunately I don't have ldd available on target :/
> On build platform it does not work:

On the build platform you should be able to get this and other
information with e.g. objdump or readelf, which you likely have anyway
as part of your cross compilation environment.

However based on your full error message (in particular "unknown
relocation type"), I think it looks more like you haven't built the
shared library correctly for the target platform.

What is the target platform? What does "file libMyLib.so" say? What
file tell you about the object files that libMyLib.so consists of?

/gordon

--
Dzikus - 29 Jan 2008 09:17 GMT
I have checked library dependencies using objdump.exe
Dependencies are:

NEEDED      libcpp.so.4
NEEDED      libc.so.2

Both libraries are on LDD_LIBRARY_PATH.

> > During runtime on target device I get following error when loading my
> > JNI library:
[quoted text clipped - 15 lines]
>
> --
Hendrik Maryns - 29 Jan 2008 12:24 GMT
Dzikus schreef:
> Hello,
> During runtime on target device I get following error when loading my
[quoted text clipped - 6 lines]
> header?
> Library name and location (LD_LIBRARY_PATH) are correct.

The platform-specific part of jni is in jni_md.h.  md is for ‘machine
dependent’.

H.
Signature

Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html

Dzikus - 29 Jan 2008 14:24 GMT
> The platform-specific part of jni is in jni_md.h.  md is for 'machine
> dependent'.

Do you know how to get this header for
IBM J9 2.3 QNX arm-32 (J2ME Foundation Specification v1.0)

I searched in IBM page without success so far ... :/
Hendrik Maryns - 29 Jan 2008 14:39 GMT
Dzikus schreef:
>> The platform-specific part of jni is in jni_md.h.  md is for 'machine
>> dependent'.
[quoted text clipped - 3 lines]
>
> I searched in IBM page without success so far ... :/

It is supposed to come with your Java sdk.

H.
Signature

Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html

Arne Vajhøj - 30 Jan 2008 01:04 GMT
> During runtime on target device I get following error when loading my
> JNI library:
[quoted text clipped - 4 lines]
> Is it possible that root cause is I compile it with incompatible jni.h
> header?

I don't think so.

A bad jni.h could result in some data corruption when
type size is different between expected and actual.

UnsatisfiedLinkError is a problem finding or loading
the native lib.

Arne
Dzikus - 30 Jan 2008 22:47 GMT
I have found the root cause:
1. First of set of headers specific for platform / JVM is needed
2. unknown relocation type - this error is related to JNI *.so
library. In QXN *.so libraries doesn't work linked against libXXX.a.
One have to link it against *.so or libXXXS.a

Thank you for your answers - they were very helpfull in finding the
solution
Best regards
  Dominik

> Hello,
> During runtime on target device I get following error when loading my
[quoted text clipped - 9 lines]
> Than you in advance
>    Dominik


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.