user1805280
user1805280

Reputation: 261

RFT throws unsatisfiedLinkError when making JNI call

I have a two line code in Rational Functional Tester script which is calling a method defined in a dll (created for jni call). But I am getting error: [java.lang.UnsatisfiedLinkError] - com/JniSleep.jniWait()V.].

import resources.Script1Helper;

import com.JniClass;

public class Script1 extends Script1Helper {

static {
    System.load("C:/VisualStudioProject/JniClass/Debug/JniClass.dll");

}
public void testMain(Object[] args) 

{

        JniClass jniClass = new JniClass();
        jniClass.jniWait(); //error thrown here

}

}

If I run the same piece of code in a normal java class (not RFT script), in the same RFT project, it works like a charm (code below).

import com.JniClass;

public class testTimer {

/**
 * @param args
 */

    // TODO Auto-generated method stub
    static {
        System.load("C:/VisualStudioProject/JniClass/Debug/JniClass.dll");
    }
    public static void main(String[] args) {


            JniClass jniClass = new JniClass();
            jniClass.jniWait();

    }

}

Why is the code not working in RFT script ? I have tried setting the ddl in Native library setting too but that did not help. Can anyone please help.

Upvotes: 2

Views: 195

Answers (3)

user1805280
user1805280

Reputation: 261

In RFT System.load is not working. You need to explicitly call System.load in the jar file that you would be including to access the native method. Once you include this jar file, and put the DLL in one of the System 'PATH' directories, the dll loads good in RFT.

Upvotes: 0

Prakash
Prakash

Reputation: 752

if the same thing is working fine outside RFT then, could you try to have(copy) the DLL containing the native implementation to the customization folder of RFT ? The following registry would tell you what is e location of the Customization folder on your machine [HKEY_LOCAL_MACHINE\SOFTWARE\Rational Software\Rational Test\8\Rational FT Customization Directory]

Close /Reopen RFT before/after making these changes.

Upvotes: 0

Pavel Zdenek
Pavel Zdenek

Reputation: 7293

Your code says

import com.JniClass;

while your error says

com/JniSleep

These two packages must be equal. I smell a discrepancy between Java native definition and the generated C header. Are you using absolutely the same DLL in both cases? Which headers does it have? Java_com_JniClass or Java_com_JniSleep ?

Upvotes: 0

Related Questions