- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: error: java.lang.UnsatisfiedLinkError: Can't l...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2009 02:23 AM
01-07-2009 02:23 AM
error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/cImpl
In the below u can find a sample Java™ program that calls a native method, which has a C implementation:
OS : HP-UX IA64
java : 1.6
Here is the sample program.
####################################
//
// File TestJava2CallingNative.java
//
class TestJava2CallingNative {
native static void sayHelloWorld();
public static void main(String args[])
{
String libname = args[0];
try {
System.loadLibrary(libname);
System.out.println("Library " +
libname + " successfully loaded");
}
catch (UnsatisfiedLinkError Err) {
System.out.println("error: " + Err);
return;
}
System.out.println("Calling sayHelloWorld");
sayHelloWorld();
System.out.println("All done");
}
}
Compile this class:
$
Output:
TestJava2CallingNative.class
Generate the JNI header file for this class. You must have the current directory in your CLASSPATH for the javah command to find your newly compiled class file.
$
Output:
TestJava2CallingNative.h
#########################################
Here is the sample c code
Here is the sample C native method implementation for sayHelloWorld:
/*
* File cImpl.c
*/
#include "TestJava2CallingNative.h"
#include
JNIEXPORT void JNICALL
Java_TestJava2CallingNative_sayHelloWorld(JNIEnv *env, jclass class)
{
printf("C says HelloWorld via stdio\n");
}
To compile this C source file:
$ cc -Ae +u4 +z -c -mt -I
-I
Output:
cImpl.o
Create the shared library containing the native method implementation:
ld -b -o libcImpl.so cImpl.o ( Is this creation correct for HP-UX IA64 )
Output:
libcImpl.so
Have set the path as :
To execute the Java™ program, you must set the SHLIB_PATH environment variable to contain the location of the directory that contains libcImpl.so
Once i set the PATH i did the following steps
$ export SHLIB_PATH=.:$SHLIB_PATH
$
This is what i have done...
While extecuting the
$
above line i got the error message as
# java TestJava2CallingNative cImpl
error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/cImpl
what is the solution for this. Does i need to set any other options while compiling or linking.
Make sure i am using HP-UX IA64.
Any help is apreceated
Thanks in advance
Gopi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2009 05:27 AM
01-07-2009 05:27 AM
Re: error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/cImpl
Should'nt /home/nalgo01 (absolute path) be in your SHLIB_PATH when thats where clmpl is located?
export SHLIB_PATH=$SHLIB_PATH:/home/nalgo01
Yours
Danny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2009 06:28 AM
01-07-2009 06:28 AM
Re: error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/cImpl
Have tried setting the SHLIB_PATH to /home/nalgo01 (absolute path)
But no result. Same error is being produced
Any help is appreceated
Thanks in advance
Gopi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2009 08:22 PM
01-08-2009 08:22 PM
Re: error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/cImpl
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1300275
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1299685
>what is the solution for this? Do I need to set any other options while compiling or linking?
I have no problems compiling, linking and running this test case using cc(1) and java 1.5. Both in 32 and 64 bit.
And no problems with gcc 4.2.1.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2009 10:23 PM
01-11-2009 10:23 PM
Re: error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/cImpl
I Compiled the above test case using
# cc +z -c -dynamic +DD64 -Ae +u4 -mt \
-I
-I
It compiled properly, and linked using ld
# ld -b +k +s +std -o libcImpl.so cImpl.o \
-lstd_v2 -lCsup -lunwind -lm
The test application ran successfully
> I have no problems compiling, linking and running this test case using cc(1) and java 1.5. Both in 32 and 64 bit.
Can u post what are the options u have used for compileing and linking using cc.
> And no problems with gcc 4.2.1.
Can u post the options for compiling and linking using gcc.
Dennis one more info needed.
1.) My c application retreives the system related info such as
- pid, No of CPU's, Process CPU
utilization, Aggregate CPU utilization
I retreive these info using getrusage system call.
Q : i have compiled this appication using
the the above cc options. it compiled sucessfully. I linked this appication using the same linking options as above.
When i tried to use the executable it is giving the error as
error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/libIA64.so
My question is does these system calls have any other dependencies other than what i used while linking ie ( -lstd_v2 -lCsup -lunwind -lm )
What are the libraries which depend on native system calls such as getrusage.
Any help is apreceated
Thanx in advance
Gopi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2009 02:24 AM
01-12-2009 02:24 AM
Re: error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/cImpl
Can u look into this once.
Regards,
Gopi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2009 02:29 AM
01-12-2009 02:29 AM
Re: error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/cImpl
> cc +z -c -dynamic +DD64 -Ae +u4 -mt \
-I
-I
I left out -dynamic since it is the default.
>linked using ld
>ld -b +k +s +std -o libcImpl.so cImpl.o \
-lstd_v2 -lCsup -lunwind -lm
You must NOT use ld to link aC++ shlibs. You must use aCC -b.
I just used what was documented: ld -b -o libcImpl.so cImpl.o
>Can you post what are the options you have used for compiling and linking using cc.
What you had before.
>Can you post the options for compiling and linking using gcc.
What you had previously.
>Q: I linked this application using the same linking options as above.
Use the cut down ld command.
>When i tried to use the executable it is giving the error as
>error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/libIA64.so
This java error is garbage, it doesn't tell you anything.
>does these system calls have any other dependencies other than what i used while linking ie (-lstd_v2 -lCsup -lunwind -lm)
Do not use these aC++ shlibs.
>What are the libraries which depend on native system calls such as getrusage.
They are all in libc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2009 02:31 AM
01-12-2009 02:31 AM
Re: error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/cImpl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2009 04:53 AM
01-12-2009 04:53 AM
Re: error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/cImpl
thanx a lot for u reply :-)
>> >What are the libraries which depend on native system calls such as getrusage.
>They are all in libc.
i have tried that native appication ie which retrives pid, No of CPU's, so on...
I compiled & linked as u have have mentioned.
Linking options :
ld -b -o libIntroscopeHpuxItanium64Stats.so java_interface.o -lc (as u have mentioned all system call libraries are stored in libc )
It got linked properly.
I used this executable in my appication but got an error :
#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
# SIGSEGV (11) at pc=c00000000774e1c1, pid=20716, tid=19
#
# Java VM: Java HotSpot(TM) 64-Bit Server VM (1.5.0.11 jinteg:11.07.07-18:21 IA64W mixed mode)
# Problematic frame:
# C [libIntroscopeHpuxItanium64Stats.so+0x21c1] Java_com_wily_introscope_agent_platform_hpux_HPUXPlatformStatisticsBackEnd_getCPUIndexMap+0x191
#
detailed log is atached for clear understanding.
Thanks in Advance Dennis,
Gopi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2009 03:47 PM
01-12-2009 03:47 PM
Re: error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/cImpl
You shouldn't need to add -lc here.
>I used this executable in my application but got an error:
# Problematic frame: C
[libIntroscopeHpuxItanium64Stats.so+0x21c1] Java_com_wily_introscope_agent_platform_hpux_HPUXPlatformStatisticsBackEnd_g
etCPUIndexMap+0x191
Notice how java cleverly blames your JNI function. :-)
You need to debug your code. Compile with -g and you can use gdb to print out variables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2009 04:46 AM
01-13-2009 04:46 AM
Re: error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/cImpl
> Notice how java cleverly blames your JNI function.
As u said to first check the JNI function, I tried doing that.
I just tried to work on each JNI fuction & calling them using the above java code makking nessasary changes.
Out of the 11 JNI functions 3 are problematic..
I ran all the jni functions individually.
This is the jni function which is causing the problem..
JNIEXPORT jintArray JNICALL
Java_HPUXPlatformStatistics_getCPUIndexMap(JNIEnv *env, jobject obj)
{
int count = 0,numOfProc = 0, *arrIndex = NULL,rc = 0;
struct pst_dynamic pstat_dyn;
rc=pstat_getdynamic(&pstat_dyn, sizeof(struct pst_dynamic),
1,0);
if ( rc == -1 ){
JNU_ThrowByName(env,"java/langUnsatisfiedLinkError",0);
return (jstring)NULL;
}
numOfProc = pstat_dyn.psd_proc_cnt;
arrIndex= (int*)malloc(sizeof(int)*numOfProc);
for(count=0;count
jintArray iarr = (*env)->NewIntArray(env, numOfProc);
if((*env)->ExceptionOccurred(env) != NULL) {
free(arrIndex);
return (jintArray)NULL;
}
(*env)->SetIntArrayRegion(env, iarr, 0, numOfProc, arrIndex);
if((*env)->ExceptionOccurred(env) != NULL) {
free(arrIndex);
return (jintArray)NULL;
}
free(arrIndex);
return iarr;
}
ERROR MESSAGE :
(0) 0xc0000000091d6b00 VMError::report_and_die{_ZN7VMError14report_and_dieEv} + 0x110 [/opt/java6/jre/lib/IA64W/server/libjvm.so]
(1) 0xc0000000097d2150 os::Hpux::JVM_handle_hpux_signal{_ZN2os4Hpux22JVM_handle_hpux_signalEiP9__siginfoPvi} + 0x6d0 at /CLO/Components/JAVA_HOTSPOT/Src/src/os_cpu/hp-ux_ia64/vm/os_hp-ux_ia64.cpp:1359 [/opt/java6/jre/lib/IA64W/server/libjvm.so]
(2) 0xc0000000097d1a40 os::Hpux::signalHandler{_ZN2os4Hpux13signalHandlerEiP9__siginfoPv} + 0x80 at /CLO/Components/JAVA_HOTSPOT/Src/src/os/hp-ux/vm/os_hp-ux.cpp:5733 [/opt/java6/jre/lib/IA64W/server/libjvm.so]
(3) 0xe0000001120028e0 ---- Signal 11 (SIGSEGV) delivered ----
(4) 0xc0000000083e5d71 Java_TestJava2CallingNative_getCPUIndexMap + 0x191 at cImpl.c:63 [/home/nalgo01/Test/libcImpl.so]
(5) 0x9fffffffeb400e70
*** Internal error (-3) while unwinding stack [/CLO/Components/JAVA_HOTSPOT/Src/src/os_cpu/hp-ux_ia64/vm/thread_hp-ux_ia64.cpp:142] ***
#
# An unexpected error has been detected by Java Runtime Environment:
#
# SIGSEGV (11) at pc=c0000000083e5d71, pid=15643, tid=1
#
# Java VM: Java HotSpot(TM) 64-Bit Server VM (1.6.0.02 jinteg:09.27.08-08:51 IA64W mixed mode)
# Problematic frame:
# C [libcImpl.so+0xd71]
[error occurred during error reporting, step 60, id 0xb]
Unable to understand this message...
I am attaching the java code & the JNI function..
This is a showstopper issue for me....
Hope to find help from u..
Thanks in advance,
Gopi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2009 04:05 PM
01-13-2009 04:05 PM
Re: error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/cImpl
It says you got a signal 11 in frame 4:
(4) 0xc0000000083e5d71 Java_TestJava2CallingNative_getCPUIndexMap + 0x191 at cImpl.c:63 [/home/nalgo01/Test/libcImpl.so]
If you have debug info, you can print the variables.
>I am attaching the java code & the JNI function.
Your code is illegal and will NOT compile in 64 bit mode:
"cImpl.c", line 61: error #4313-D: no prototype or definition in scope for call to memory allocation routine "malloc"
arrIndex= (int*)malloc(sizeof(int)*numOfProc);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2009 08:25 PM
01-13-2009 08:25 PM
Re: error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/cImpl
Thanx for letting some time for me. The information which u provide was a knowlegable one.
Have some more queries. Hope u answer these queries also.
> Your code is illegal and will NOT compile in 64 bit mode:
"cImpl.c", line 61: error #4313-D: no prototype or definition in scope for call to memory allocation routine "malloc"
arrIndex= (int*)malloc(sizeof(int)*numOfProc);
1.)What are the nessasary changes i need to make for it to compile in 64 bit mode.( if possible do send me the modified c file )
2.) what is the alternate solution for
arrIndex= (int*)malloc(sizeof(int)*numOfProc);
Hope to find help for u.
Thanks in Advance.
Gopi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2009 10:35 PM
01-13-2009 10:35 PM
Re: error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/cImpl
>1) What are the necessary changes I need to make for it to compile in 64 bit mode.
As Don and the error message say, you need to include the appropriate header,
>2) what is the alternate solution for
That malloc statement is fine, you need that prototype.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2009 11:06 PM
01-13-2009 11:06 PM
Re: error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/cImpl
Thanks a lot for u r reply.
Making the nessasary changes, I compiled & linked the code. It worked fine.
The same i did for my project. But it is not working for that code. ( All Paths Lead To Rome :::: Similarly all changes lead to the same error : java.lang.UnsatisfiedLinkError: Can't load library:/home/nalgo01/Probeing/libHPUXItanium64Stats.so )
This c file is for getting system related info ( i use getrusage() system call )
Compiling options:
cc +z -c +DD64 -Ae +u4 -mt -I/opt/java6/include -I/opt/java6/include/hp-ux java_interface.c
Compiled sucessfully
Linking Options:
ld -b -o libHPUXItanium64Stats.so
setted the following paths:
export LPATH=/usr/lib/hpux64/dld.so
export SHLIB_PATH=/usr/lib/hpux64:/home/nalgo01/Probeing
export LD_LIBRARY_PATH=/usr/lib/hpux64
Can u plz look into this once.
I request u r help on this
Thanks in advance,
Gopi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2009 11:41 PM
01-13-2009 11:41 PM
Re: error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/cImpl
Again a useless message with no details, errno.
I assume you are passing -d64 to java. You have exported CLASSPATH? And libHPUXItanium64Stats.so is executable?
You are going to have to use a debugger to get the real error info. Possibly by using "catch load" and set a breakpoint in dlopen.
Also in your test .c you did this: JNU_ThrowByName(env,"java/lang/UnsatisfiedLinkError",0);
How do you know what is producing that error? It is better if you invent a completely new message so there can't be any confusion.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2009 12:09 AM
01-14-2009 12:09 AM
Re: error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/cImpl
> Again a useless message with no details, errno
java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/Probeing/libIntroscopeHpuxItanium64Stats.so
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1650)
at java.lang.Runtime.load0(Runtime.java:770)
at java.lang.System.load(System.java:1005)
> I assume you are passing -d64 to java.
Yes i am using 64 bit jvm (-d64)
> You have exported CLASSPATH?
No i have set the classpath. if i have to set to which env variable i need to set
> Possibly by using "catch load" and set a breakpoint in dlopen.
who to use "catch load" & dlopen
>Also in your test .c you did this: JNU_ThrowByName(env,"java/lang/UnsatisfiedLinkError",0);
Yes it did in test.c also
Thanks in advance,
Gopi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2009 12:23 AM
01-14-2009 12:23 AM
Re: error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/cImpl
I mean the message doesn't say why it can't load.
>if I have to set to which env variable I need to set
I guess you don't have that problem because java would say it couldn't find the java class.
>who to use "catch load" & dlopen
You need to use these commands in gdb when debugging. See your other thread:
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1304147
>>JNU_ThrowByName(env,"java/lang/UnsatisfiedLinkError",0);
>Yes it did in test.c also
Don't use that string. Make up something completely different so you know that you have a different error in your JNI.
Is there any way you can attach something small that fails?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2009 03:48 AM
01-14-2009 03:48 AM
Re: error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/cImpl
Plz do have a look at the below link
http://forums11.itrc.hp.com/service/forums/questionanswer.do?admit=109447626+1231904747519+28353475&threadId=1302344
The problem is with System.load( ).
It is being loaded for the test application and for the main appication it is not being loaded.
What may be the problem.?
Thanking you,
Gopi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2009 09:13 PM
01-14-2009 09:13 PM
Re: error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/cImpl
I assume you mean:
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1304461
>The problem is with System.load().
Unless I can get my hands on something or you can duplicate it with C/C++ or at the assembly level, I can't help much. The java messages are next to useless, if you have already know your problems are due to zebras. :-)
>>>JNU_ThrowByName(env,"java/lang/UnsatisfiedLinkError",0);
If you don't want to change these, please add a "fprintf(stderr," before each one that prints out useful diagnostics.
- Tags:
- zebras
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2009 03:06 AM
01-15-2009 03:06 AM
Re: error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/cImpl
Finally it got solved.
Thanks for all your time spending on this. I an sure, the help u have provided has helped me a lot.
The problem in System.lod() was very silly one. I used some uppercase letters while loading and stored the same lib with different cases in dir.
Once again i thank for the help.
Regards,
Gopi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2009 02:31 AM
01-16-2009 02:31 AM
Re: error: java.lang.UnsatisfiedLinkError: Can't load library: /home/nalgo01/cImpl
>I used some uppercase letters while loading and stored the same lib with different cases in dir.
Glad you figured it out.
Please read the following about assigning points:
http://forums.itrc.hp.com/service/forums/helptips.do?#33