0 Replies Latest reply: Aug 27, 2013 11:06 AM by 1036108 RSS

    Problem loading a dll library from Java stored procedure

    1036108

      Hello,

      I need to use a dll library from a Java stored procedure, which is called from PL/SQL.

      The Java stored procedure is defined like this:

       

      create or replace and compile java source named librarytest as

        public class librarytest

        {

          public static String TestLoad()

          {

            try {

              System.loadLibrary("aal2sdk");

              // some useful stuff here...

            } catch (UnsatisfiedLinkError e) {

              return e.getMessage() + "; " + System.getProperty("java.library.path");

            }

       

            return "OK";

          }

        }

      /

       

      Then this function is available to be called from PL/SQL like this:

       

      create or replace package librarytest_pkg

      is

        FUNCTION TestLoad RETURN VARCHAR2 AS LANGUAGE JAVA NAME 'librarytest.TestLoad() return java.lang.String';

      end;

      /

       

      The aal2sdk.dll is located in c:\oracle\ora11202_2\bin.

       

      And now, when I try to execute:

      select librarytest_pkg.TestLoad() from dual;

       

      the result is:

      no aal2sdk in java.library.path; c:\oracle\ora11202\bin;.;C:\Windows\system32;C:\Windows;c:\msys\1.0\bin;c:\oracle\ora11202_2\bin;.......

       

      So:

      1) I already have a permission to call System.loadLibrary - otherwise it would end up with an exception "the Permission (java.lang.RuntimePermission loadLibrary.aal2sdk) has not been granted to ......."

      So I am eligible to load this library and it really tries to load it.

      2) It ends up with an UnsatisfiedLinkError exception saying that it cannot find aal2sdk library in java.library.path, but the dll is placed in c:\oracle\ora11202_2\bin and as you can see from the output, this directory is present in java.library.path.

       

      So what I am missing here? Is System.getProperty("java.library.path") telling me the truth? Why Java cannot find the dll when it is present in one of the directories listed in java.library.path?

       

      Thank you in advance for help.