2 Replies Latest reply on Apr 26, 2006 10:22 AM by rogeduardo

    How to invoke a native method?

    bmateus

      Hi all,

      I have found many topics about this issue but none of the presented solutions solved my problem.

      My system: JBoss 3.2.6, Java 1.4.2_09 and Fedora Core 4

      I?m trying to use some native methods available on a .so file. I?m able to load the library but the first time I use a native method I get a java.lang.UnsatisfiedLinkError. The code I?m using to load the lib is the following:

      try {
      System.loadLibrary("example");
      } catch (UnsatisfiedLinkError e) {
      log.info("Native code library failed to load." + e);
      }

      If I change the lib name the presented exception is thrown. If the lib name is correct no errors occur, that?s why I said that the lib is correctly loaded. The lib file is not included in any jar file. I already updated all the system path variables, -Djava.library.path options, etc, pointing to the directory containing the lib file. I already moved the lib to all the directories suggested in this forum with no luck. I already placed the presented code in the Class with the native method that is first called with no luck.

      I?m really with no more solutions to test. The strange thing is that the lib is loaded but I can't to use it. I read that EJB specification doesn?t advise (prohibits???) the use of native libs but I think JBoss allows it, that?s true? I implemented a standalone application that doesn?t use JBoss and everything works fine.

      Have anyone an idea that could help me? I?m without solutions?

      Best Regards,

      Bruno Mateus

        • 1. Re: How to invoke a native method?
          rogeduardo

          Cerificate if the signature of method into .so is correct. Try this:

          javah -jni class_name

          It will generate one .h, check inside this file if this name is equal of the signature of file it will generate or .so. Try too export de variable LD_LIBRARY_PATH in your enviroment. But you have export before the bring up JBOSS.

          • 2. Re: How to invoke a native method?
            rogeduardo

             

            "rogeduardo" wrote:
            Cerificate if the signature of method into .so is correct. Try this:

            javah -jni class_name

            It will generate one .h, check inside this file if this name is equal of the signature of file it will generate your .so. Try too export de variable LD_LIBRARY_PATH in your enviroment. But you have export before the bring up JBOSS.