You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Daniel Wildschut <wi...@teco.edu> on 2006/11/18 22:12:35 UTC

UnsatisfiedLinkError while using JNI

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,
I am using JNI to load a library which
I use for a Web Service running on a Tomcat5.5-Server
using Axis. My problem is that when I call a native function
it immediatly fails with java.lang.UnsatisfiedLinkError:
new_ParticleSocket__SWIG_0 ( new_ParticleSocket__SWIG_0 being the
function called ). No further information is provided by the exception.
After checking the obvious ( classpath and
java.library.path/LD_LIBRARY_PATH, also checked if the library was
loaded twice ) I checked the library itself ( which is generated by SWIG
1.3.29 ) using nm to see if all symbols were generated correctly ( which
they were, the symbols are all in the form
Java_edu_teco_particles_libParticle_libparticleJNI_* and in a standalone
form without the prefix).
I then used LD_DEBUG=all to check if the library was indeed loaded.
There I found that the library was loaded however when JNI searches for
the necessary function it does not search the newly loaded library.
( A lookup is performed on all libraries loaded before but not on the
new library )
I am using Debian GNU/Linux with Sun JDK 1.5.08

Any help would be appreciated

 - Daniel Wildschut
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQFFX3dDUS3Mvw9vkgURArBYAJ9HFskU8O8jSXvBibCA0X+mqv4FPwCbBIDk
jRUTnbGR1+t+ejlH9OLCoTk=
=VkIX
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: UnsatisfiedLinkError while using JNI

Posted by Daniel Wildschut <wi...@teco.edu>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,
the library itself is found and loaded ( at least according to
LD_DEBUG=all ), also if the library is not in the LD_LIBRARY_PATH I get
a different error ( the runtime telling me the library could not be loaded).

- - Daniel Wildschut

Martin Gainty wrote:
> the entries in the LD_LIBRARY_PATH must be colon separated
> if your setting thru bash make sure you export LD_LIBRARY_PATH
> If none that works take a look at these LD_LIBRARY_PATH diagnostics
> http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html
> 
> M-
> This e-mail communication and any attachments may contain confidential and privileged information for the use of the 
> designated recipients named above. If you are not the intended recipient, you are hereby notified that you have received
> this communication in error and that any review, disclosure, dissemination, distribution or copying of it or its 
> contents
> ----- Original Message ----- 
> From: "Daniel Wildschut" <wi...@teco.edu>
> To: <us...@tomcat.apache.org>
> Sent: Saturday, November 18, 2006 4:12 PM
> Subject: UnsatisfiedLinkError while using JNI
> 
> 
> Hello,
> I am using JNI to load a library which
> I use for a Web Service running on a Tomcat5.5-Server
> using Axis. My problem is that when I call a native function
> it immediatly fails with java.lang.UnsatisfiedLinkError:
> new_ParticleSocket__SWIG_0 ( new_ParticleSocket__SWIG_0 being the
> function called ). No further information is provided by the exception.
> After checking the obvious ( classpath and
> java.library.path/LD_LIBRARY_PATH, also checked if the library was
> loaded twice ) I checked the library itself ( which is generated by SWIG
> 1.3.29 ) using nm to see if all symbols were generated correctly ( which
> they were, the symbols are all in the form
> Java_edu_teco_particles_libParticle_libparticleJNI_* and in a standalone
> form without the prefix).
> I then used LD_DEBUG=all to check if the library was indeed loaded.
> There I found that the library was loaded however when JNI searches for
> the necessary function it does not search the newly loaded library.
> ( A lookup is performed on all libraries loaded before but not on the
> new library )
> I am using Debian GNU/Linux with Sun JDK 1.5.08
> 
> Any help would be appreciated
> 
> - Daniel Wildschut
>>
- ---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQFFX39wUS3Mvw9vkgURAixpAKCh2kMLolGaGQjSbNhSHmSVYSLNbQCgzDsk
2WUnnKZboeY2/o+mTiXHudc=
=K55o
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: UnsatisfiedLinkError while using JNI

Posted by Martin Gainty <mg...@hotmail.com>.
the entries in the LD_LIBRARY_PATH must be colon separated
if your setting thru bash make sure you export LD_LIBRARY_PATH
If none that works take a look at these LD_LIBRARY_PATH diagnostics
http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html

M-
This e-mail communication and any attachments may contain confidential and privileged information for the use of the 
designated recipients named above. If you are not the intended recipient, you are hereby notified that you have received
this communication in error and that any review, disclosure, dissemination, distribution or copying of it or its 
contents
----- Original Message ----- 
From: "Daniel Wildschut" <wi...@teco.edu>
To: <us...@tomcat.apache.org>
Sent: Saturday, November 18, 2006 4:12 PM
Subject: UnsatisfiedLinkError while using JNI


> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hello,
> I am using JNI to load a library which
> I use for a Web Service running on a Tomcat5.5-Server
> using Axis. My problem is that when I call a native function
> it immediatly fails with java.lang.UnsatisfiedLinkError:
> new_ParticleSocket__SWIG_0 ( new_ParticleSocket__SWIG_0 being the
> function called ). No further information is provided by the exception.
> After checking the obvious ( classpath and
> java.library.path/LD_LIBRARY_PATH, also checked if the library was
> loaded twice ) I checked the library itself ( which is generated by SWIG
> 1.3.29 ) using nm to see if all symbols were generated correctly ( which
> they were, the symbols are all in the form
> Java_edu_teco_particles_libParticle_libparticleJNI_* and in a standalone
> form without the prefix).
> I then used LD_DEBUG=all to check if the library was indeed loaded.
> There I found that the library was loaded however when JNI searches for
> the necessary function it does not search the newly loaded library.
> ( A lookup is performed on all libraries loaded before but not on the
> new library )
> I am using Debian GNU/Linux with Sun JDK 1.5.08
> 
> Any help would be appreciated
> 
> - Daniel Wildschut
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.5 (GNU/Linux)
> 
> iD8DBQFFX3dDUS3Mvw9vkgURArBYAJ9HFskU8O8jSXvBibCA0X+mqv4FPwCbBIDk
> jRUTnbGR1+t+ejlH9OLCoTk=
> =VkIX
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
>

Re: UnsatisfiedLinkError while using JNI

Posted by Daniel Wildschut <wi...@teco.edu>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,
I checked the classloader and indeed the problem was
a classloader conflict ( the imported classes used the System-default
ClassLoader, which lead to the problem ).
I was able to place the call to LoadLibrary into a separate class
which I put into the classpath. This solved the problem.

Thank you for your time & advice

- - Daniel Wildschut

Caldarale, Charles R wrote:
>> From: Daniel Wildschut [mailto:wildschu@teco.edu] 
>> Subject: UnsatisfiedLinkError while using JNI
>>
>> I then used LD_DEBUG=all to check if the library was indeed loaded.
>> There I found that the library was loaded however when JNI searches
>> for the necessary function it does not search the newly loaded
> library.
> 
> This may be a classloader conflict.  What triggers the loading of the
> native library?  If this is done under a classloader that's not in the
> same branch of the tree that's now making the reference to the native
> method, it may not be able to find it.  Look at:
>     http://tomcat.apache.org/tomcat-5.5-doc/class-loader-howto.html
> for Tomcat classloading info.
> 
>  - Chuck
> 
> 
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you
> received this in error, please contact the sender and delete the e-mail
> and its attachments from all computers.
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQFFX5auUS3Mvw9vkgURAolnAJ9g/TckEBJCaiSz7s4nS0lfDMBvZgCfdUUB
aSL3e87jRRe9Av8L7WmFCKw=
=Dt97
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: UnsatisfiedLinkError while using JNI

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Daniel Wildschut [mailto:wildschu@teco.edu] 
> Subject: UnsatisfiedLinkError while using JNI
>
> I then used LD_DEBUG=all to check if the library was indeed loaded.
> There I found that the library was loaded however when JNI searches
> for the necessary function it does not search the newly loaded
library.

This may be a classloader conflict.  What triggers the loading of the
native library?  If this is done under a classloader that's not in the
same branch of the tree that's now making the reference to the native
method, it may not be able to find it.  Look at:
    http://tomcat.apache.org/tomcat-5.5-doc/class-loader-howto.html
for Tomcat classloading info.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org