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

    UnsatisfiedLinkError while invoking the native method

    Ashwath Akirekadu Newbie

      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;
      }
      }
      }