Mike Clark <mike@...> wrote:
hellovidyasagar wrote:
> Hi,
> we are working on JNI and Junit perf tool while accesing native
> methods very first time the test passes successfully for next
> iteration we are getting
> java.lang.UnsatisfiedLinkError: InitializeTCCommDLL
> at TCImpl.InitializeTCCommDLL(Native Method)
> at TCImpl.testMain(TCImpl.java:69)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke
> (NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke
> (DelegatingMethodAccessorImpl.java:25)
> java.lang.UnsatisfiedLinkError: Native Library C:\Public\08012003
> \perf-tool 11-11 AM\TCImpl.dl
> l already loaded in another classloader
>
> In Some help docs we found JNI inforces an additional restriction
> that only one classLoader in a JVM may possess a particular native
> library. That's the gist of the problem with the ReloadingTestRunners.
> Is it true? if so how can we test native calls using JNI and
> Junitperf?
>
Please you tell us more about the test runner you're using, or if you're
using the <junit> task in Ant.
Mike
--
Mike Clark
http://clarkware.com
(303) 589-3812Dear Mike,
We are using JUnit test runner and we are not using Ant. We are running it on Win 2000 platform. We are loading cpp dll through wrapper dll(JNI). Unable to access methods in the dll file. The test case written using JUnit [which is calling native methods(JNI)] is working fine. But when we try to load test this class(LoadTest etc) in junitperf it is giving following error.
java.lang.UnsatisfiedLinkError: InitializeTCCommDLL
at TCImpl.InitializeTCCommDLL(Native Method)one more peculiar behaviour we observed is that a junit test case(which calls Native methods) which works fine when run from console(Ex: c:\> java junit.swingui.TestRunner MyTestCase), is giving the above error when called from some other program.
example:
//callsTestCase.java
public class callsTestCase
{
public static void main(String a[])
{
junit.swingui.TestRunner.run
(MyTestCase.class);
}
}
// MyTestCase.java
import junit.framework.Test ;
import junit.framework.TestCase ;
import junit.framework.TestSuite ;public class MyTestCase extends TestCase
{
public MyTestCase(String name)
{
super(name) ;
}
// Loading TCImpl.dll
try
{
System.loadLibrary("TCImpl");
}
catch(UnsatisfiedLinkError ule)
{
System.out.println(ule);
}
// Declaring native method for Intializing the TC COM dll.
public static native void InitializeTCCommDLL ();public static void testMain()
{
// calling Native method here
InitializeTCCommDLL ();
}
}