2

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.

user1805280
  • 251
  • 1
  • 5
  • 14

3 Answers3

0

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 ?

Pavel Zdenek
  • 7,146
  • 1
  • 23
  • 38
0

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.

Prakash
  • 742
  • 7
  • 19
  • Tried this. On my machine the folder is C:\ProgramData\IBM\RFT\customization. But the script is still throwing the same error. Is there a different way in RFT to load an external dll ? I have also tried putting the dll name in NativeLibrary setting - no luck there too. – user1805280 Nov 16 '12 at 16:39
0

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.

user1805280
  • 251
  • 1
  • 5
  • 14