2 Replies Latest reply on Mar 22, 2005 2:07 PM by ramses

    UnsatisfiedLinkError while invoking the native method

    akirekadu

      Hi All,

      I am attempting to invoke a native method (from a DLL) in my adapter.
      I have placed the DLL inside RAR file. I notice that DLL gets loaded during JBoss startup. But attempt to invoke the native method results in UnsatisfiedLinkError. I am unable to understand why the method invokation should fail while the DLL is successfull loaded. Similar code works perfectly fine outside of JBoss.

      Below is the code that does the JNI.

      Thanks much,

      Ash Akirekadu
      Panacya Inc



      import org.apache.log4j.Category;

      public class ProtoConnectionImpl implements ProtoConnection {

      private static final Category _Log = Category.getInstance(ProtoConnectionImpl.class);
      private synchronized native String nativeEcho(String arg) throws UnsatisfiedLinkError;
      private final static String ECHO_API = "C:/jboss-3.2.1/server/default/tmp/native/Echo.dll";
      public String getHello(String arg) throws UnsatisfiedLinkError{
      _Log.info("Enter - arg= "+arg);
      _Log.info("System.mapLibraryName(Echo): "+System.mapLibraryName("Ech"));
      try {
      String res = nativeEcho(arg);
      _Log.info("Return value from the native method: "+res);
      return res;
      } catch(UnsatisfiedLinkError x) {
      _Log.error("UnsatisfiedLinkError.getMessage(): "+x.getMessage());
      _Log.error("Could not invoke native method.", x);
      throw x;
      }
      }
      }

        • 1. Re: UnsatisfiedLinkError while invoking the native method
          akirekadu

          Noticed that org.jboss.deployment.SubDeployerSupport, which loads the native library belongs to a class loader called org.jboss.system.server.NoAnnotationURLClassLoader, but my connector classes are loaded by org.jboss.mx.loading.UnifiedClassLoader3.

          So I guess UnifiedClassLoader3 cannot see the native library, hence the UnsatisfiedLinkError.

          Given this bit of information, can anybody give me a clue how to access the native library from my connector?

          Thanks in advance,

          Ash Akirekadu
          Panacya Inc

          • 2. Re: UnsatisfiedLinkError while invoking the native method
            ramses

            Hi

            Has anyone a answer/solution, I have unfortunately the same problem?

            Thank you for your assistance
            br
            Ramses