1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Using Linux command line commands through PL/SQL

Discussion in 'SQL PL/SQL' started by ac.arijit, Nov 14, 2012.

  1. ac.arijit

    ac.arijit Forum Advisor

    Messages:
    217
    Likes Received:
    22
    Trophy Points:
    280
    Location:
    Kolkata, India
    Hi Guyz,
    I need to use linux command 'rwrun report=xyz.rdf userid=apps/apps' to run a report locally but through a PL/SQL Procedure.

    Is this concept feasible? If Yes, then how?

    Plz Reply
    Regards
     
  2. dariyoosh

    dariyoosh Forum Advisor

    Messages:
    118
    Likes Received:
    19
    Trophy Points:
    260
  3. rajavu

    rajavu Forum Guru

    Messages:
    815
    Likes Received:
    52
    Trophy Points:
    610
    Location:
    @ Bangalore , India
    Btw,


    Why do yopu want to run the report from PL/SQL?
    I think , it will better if you schedule the job in Unix directly or using some thirt party application like Autosys.
     
  4. ac.arijit

    ac.arijit Forum Advisor

    Messages:
    217
    Likes Received:
    22
    Trophy Points:
    280
    Location:
    Kolkata, India
    Hi Rajavu,
    Thanks for the reply. Well actually i don't have any access to third party applications over here, and the motive is not to schedule the job but to programmatically run it through other logical operations. Thats why i want to run the report from PL/SQL and derive the output file in the desired format.

    Hi Dariyoosh,
    Thanks for the reply, i went through the links,
    1. The Java method was created successfully, but with "warning: finally clause cannot complete normally"
    2. The publishing of the java call was also successful.
    3. But when i execute the java method passing the command as i mentioned above it completes the pl/sql block with return value -1 and the .pdf file also is not generated where i want it to be.

    Here's the pl/sql block:
    Code (SQL):

    SET ServerOutput    ON;
    DECLARE
        p_command   Varchar2(32767)   :=  'rwrun report=/d02/clone-appl/apps/apps_st/appl/gl/12.0.0/reports/US/AMRIT_BS_TFRM.rdf userid=apps/apps desformat=pdf destype=file desname=/d02/clone-appl/apps/apps_st/appl/gl/12.0.0/reports/US/AMRIT_BS_TFRM.pdf PERIOD_NAME=''APR-11-12'' P_ACCESS_SET_ID=1000 P_ORG_ID=82 P_UNIT=11';
    BEGIN
        dbms_output.put_line(Amrit_Developers_Toolkit.ExecuteCmd(p_command));
    END;
     
     
  5. dariyoosh

    dariyoosh Forum Advisor

    Messages:
    118
    Likes Received:
    19
    Trophy Points:
    260
    Hi,

    As I don't have your Java code here, I'm not able to tell you what went wrong exactly. Also, you said
    So before continuing the next steps, you should look what is exactly the problem.

    There were several links in that OTN forum's page. The first one (oracle-base) gives a detailed and complete example. Try to look and
    understand what Tim Hall does in his example and based on that try to find how your query ma be expressed (if possible) according to
    the given solution. Here is the link to the page:


    http://www.oracle-base.com/articles/8i/shell-commands-from-plsql.php


    Regards,
    Dariyoosh
     
  6. ac.arijit

    ac.arijit Forum Advisor

    Messages:
    217
    Likes Received:
    22
    Trophy Points:
    280
    Location:
    Kolkata, India
    Hi Dariyoosh,

    I tried this one also, but got compilation errors using Toad 9.5, please find it below:

    Code (SQL):

    CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "Host" AS
    import java.io.*;
    public class Host {
      public static void executeCommand(String command) {
        try {
          String[] finalCommand;
          IF (isWindows()) {
            finalCommand = NEW String[4];
            // USE the appropriate path FOR your windows version.
            finalCommand[0] = "C:\windows\system32\cmd.exe";  // Windows XP/2003
            //finalCommand[0] = "C:\winnt\system32\cmd.exe";  // Windows NT/2000
            finalCommand[1] = "/y";
            finalCommand[2] = "/c";
            finalCommand[3] = command;
          }
          ELSE {
            finalCommand = NEW String[3];
            finalCommand[0] = "/bin/sh";
            finalCommand[1] = "-c";
            finalCommand[2] = command;
          }
     
          final Process pr = Runtime.getRuntime().EXEC(finalCommand);
          pr.waitFor();

          NEW Thread(NEW Runnable(){
            public void run() {
              BufferedReader br_in = NULL;
              try {
                br_in = NEW BufferedReader(NEW InputStreamReader(pr.getInputStream()));
                String buff = NULL;
                while ((buff = br_in.readLine()) != NULL) {
                  System.OUT.println("Process out :" + buff);
                  try {Thread.sleep(100); } catch(Exception e) {}
                }
                br_in.close();
              }
              catch (IOException ioe) {
                System.OUT.println("Exception caught printing process output.");
                ioe.printStackTrace();
              }
              finally {
                try {
                  br_in.close();
                } catch (Exception ex) {}
              }
            }
          }).START();
     
          NEW Thread(NEW Runnable(){
            public void run() {
              BufferedReader br_err = NULL;
              try {
                br_err = NEW BufferedReader(NEW InputStreamReader(pr.getErrorStream()));
                String buff = NULL;
                while ((buff = br_err.readLine()) != NULL) {
                  System.OUT.println("Process err :" + buff);
                  try {Thread.sleep(100); } catch(Exception e) {}
                }
                br_err.close();
              }
              catch (IOException ioe) {
                System.OUT.println("Exception caught printing process error.");
                ioe.printStackTrace();
              }
              finally {
                try {
                  br_err.close();
                } catch (Exception ex) {}
              }
            }
          }).START();
        }
        catch (Exception ex) {
          System.OUT.println(ex.getLocalizedMessage());
        }
      }
     
      public static BOOLEAN isWindows() {
        IF (System.getProperty("os.name").toLowerCase().indexOf("windows") != -1)
          RETURN TRUE;
        ELSE
          RETURN FALSE;
      }

    };

    Error at line 1
    ORA-29536: badly formed SOURCE: oracle.aurora.sqljdecl.TokenMgrError: Lexical error at line 9, COLUMN 31.  Encountered: "w" (119), after : "\"C:\\"
     
    Can you figure out this error?

    And the earlier one which i tested was:

    Code (SQL):

    CREATE OR REPLACE AND COMPILE JAVA SOURCE
    NAMED "AmritOsCommand"
    AS
    import java.io.*;
    import java.lang.*;
    public class AmritOsCommand extends Object
    {
      public static INT RunCmd(String args)
      {
        Runtime rt = Runtime.getRuntime();
        INT        rc = -1;
        try
        {
           // System.OUT.println(args);
           Process p = rt.EXEC(args);

           INT bufSize = 4096;
           BufferedInputStream bis = NEW BufferedInputStream(p.getInputStream(), bufSize);
           INT len;
           byte buffer[] = NEW byte[bufSize];
           // Output OF the program called
           while ((len = bis.READ(buffer, 0, bufSize)) != -1)
                System.OUT.println(NEW String(buffer));
           rc = p.waitFor();
        }
        catch (Exception e)
        {
          e.printStackTrace();
          rc = -1;
        }
        finally
        {
          RETURN rc;
        }
      }
    };
     
    This compiled with the warning i mentioned above. Here is the PL/SQL "Wrapper":
    Code (SQL):

            FUNCTION ExecuteCmd(p_command   IN  Varchar2)
            RETURN  NUMBER
            AS  LANGUAGE JAVA
            NAME 'AmritOsCommand.RunCmd (java.lang.String) return java.lang.int';
     
    And this is the call:
    Code (SQL):

    SET ServerOutput    ON;
    DECLARE
        p_command   Varchar2(32767)   :=  'rwrun report=/d02/clone-appl/apps/apps_st/appl/gl/12.0.0/reports/US/AMRIT_BS_TFRM.rdf userid=apps/apps desformat=pdf destype=file desname=/d02/clone-appl/apps/apps_st/appl/gl/12.0.0/reports/US/AMRIT_BS_TFRM.pdf PERIOD_NAME=''APR-11-12'' P_ACCESS_SET_ID=1000 P_ORG_ID=82 P_UNIT=11';
    BEGIN
        dbms_output.put_line(Amrit_Developers_Toolkit.ExecuteCmd(p_command));
    END;
     
    After all this the Return value i got was -1 and no .pdf file which was desired to was not created in the location passed.

    Please be alongside me pulling off this issue. My project deadline is nearby and i need to finish it fast.
    Thanks for the co-operation so far.
    Regards
    Ari
     
  7. dariyoosh

    dariyoosh Forum Advisor

    Messages:
    118
    Likes Received:
    19
    Trophy Points:
    260
    May seem a trivial question, but the does the oracle user running this, has sufficient OS privileges to create the report on that specific location?

    Also there was an issue at the beginning of the code.

    Instead of
    Code (Text):

    finalCommand[0] = "C:\windows\system32\cmd.exe";
     
    It has to be

    Code (Text):

    finalCommand[0] = "C:\\windows\\system32\\cmd.exe";
     
    To escape '\' special character.

    For this test, don't use Toad, put the code in a simple .sql file and run it directly with SQL*Plus. At least,
    in this way, you can find whether there is bug in the code or a bug in Toad :)

    Anyway, I'm using Linux (Fedora Core 17 X86_64) and based on the example Tim provided in his article
    this is exactly the code that I run and worked for me without any problem. Let's say that I want to run
    the following Linux command

    Code (Text):

    /bin/sh -c 'cat /etc/hosts'
     
    So based on Tim's example, here is how I adapted the code and it works pretty well for me. All you
    need to do is to put the following code in a .sql file (except the GRANT permission part) and run it
    of course you will have to change the OS command based on your need.

    Code (Text):

    HOST clear;
    SET SERVEROUTPUT ON;
    SET PAGESIZE 10000;
    SET LINESIZE 1000;
    SET SQLBLANKLINES ON;
    SET SERVEROUTPUT ON FORMAT WRAPPED;
    --SET TIMING ON;


    CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "Host" AS
    import java.io.*;
    public class Host
    {
        public static void executeCommand(String command)
        {
            try
            {
                String[] finalCommand;
                if (isWindows())
                {
                    finalCommand = new String[4];
                    // Use the appropriate path for your windows version.
                    finalCommand[0] = "C:\\windows\\system32\\cmd.exe";
                    finalCommand[1] = "/y";
                    finalCommand[2] = "/c";
                    finalCommand[3] = command;
                }
                else
                {
                    finalCommand = new String[3];
                    finalCommand[0] = "/bin/sh";
                    finalCommand[1] = "-c";
                    finalCommand[2] = command;
                }

                final Process pr = Runtime.getRuntime().exec(finalCommand);
                pr.waitFor();

                new Thread(new Runnable()
                {
                    public void run()
                    {
                        BufferedReader br_in = null;
                        try
                        {
                            br_in = new BufferedReader
                                (new InputStreamReader(pr.getInputStream()));
                            String buff = null;
                            while ((buff = br_in.readLine()) != null)
                            {
                                System.out.println("Process out :" + buff);
                                try
                                {
                                    Thread.sleep(100);
                                }
                                catch(Exception e)
                                {   }
                            }
                            br_in.close();
                        }
                        catch (IOException ioe)
                        {
                            System.out.println
                                ("Exception caught printing process output.");
                            ioe.printStackTrace();
                        }
                        finally
                        {
                            try
                            {
                                br_in.close();
                            }
                            catch (Exception ex)
                            {   }
                        }
                    }
                }).start();

                new Thread(new Runnable()
                {
                    public void run()
                    {
                        BufferedReader br_err = null;
                        try
                        {
                            br_err = new BufferedReader
                                (new InputStreamReader(pr.getErrorStream()));
                            String buff = null;
                            while ((buff = br_err.readLine()) != null)
                            {
                                System.out.println("Process err :" + buff);
                                try
                                {
                                    Thread.sleep(100);
                                }
                                catch(Exception e)
                                {   }
                            }
                            br_err.close();
                        }
                        catch (IOException ioe)
                        {
                            System.out.println
                                ("Exception caught printing process error.");
                            ioe.printStackTrace();
                        }
                        finally
                        {
                            try
                            {
                                br_err.close();
                            }
                            catch (Exception ex)
                            {   }
                        }
                    }
                }).start();
            }
            catch (Exception ex)
            {
                System.out.println(ex.getLocalizedMessage());
            }
        }

        public static boolean isWindows()
        {
            if (System.getProperty("os.name").
                    toLowerCase().indexOf("windows") != -1)
                return true;
            else
                return false;
        }

    };
    /


    -- Next we publish the call specification using  a PL/SQL "wrapper" PL/SQL procedure.
    CREATE OR REPLACE PROCEDURE host_command
    (
        p_command  IN  VARCHAR2
    )
    AS LANGUAGE JAVA NAME 'Host.executeCommand (java.lang.String)';
    /
     
    The relevant permissions must be granted from SYS for JServer to access the file system and the schema name must be written in Uppercase
    In my example I used a schema named 'train2012'
    Code (Text):

    EXECUTE DBMS_JAVA.grant_permission('TRAIN2012', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
    EXECUTE DBMS_JAVA.grant_permission('TRAIN2012', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
    EXECUTE DBMS_JAVA.grant_permission('TRAIN2012', 'SYS:java.io.FilePermission', '/bin/sh', 'execute');
     


    Finally the following anonymous PL/SQL block can be used to test the program.
    Code (Text):

    DECLARE
        l_output DBMS_OUTPUT.chararr;
        l_lines  INTEGER := 1000;
    BEGIN
        DBMS_OUTPUT.enable(1000000);
        DBMS_JAVA.set_output(1000000);

        host_command(p_command => '/usr/bin/cat /etc/hosts');

        DBMS_OUTPUT.get_lines(l_output, l_lines);

        FOR i IN 1 .. l_lines LOOP
            DBMS_OUTPUT.PUT(l_output(i));
        END LOOP;
       
    END;
    /
     
    Which gave me the desired output.

    Code (Text):

    Process out :127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4Process out :::1     localhost localhost.localdomain localhost6 localhost6.localdomain6Process out :192.168.1.150    mycomputer.mydomain mycomputerProcess out :
    done.

    PL/SQL procedure successfully completed.

    SQL>

     
    So as you can see I provided a complete working code, and all you need to do is change the OS command,
    which might require additional EXECUTE DBMS_JAVA.grant_permission (depending on what you want to do) so I think
    if by any chance there is still a problem it would be either a privilege problem or a command (syntax) problem.

    Also Tim gives a very important remark at the end of his article which you should not forget to take into account otherwise
    your code will not work


    So for the same reason, in the test block I wrote host_command(p_command => '/usr/bin/cat /etc/hosts');
    and not host_command(p_command => cat /etc/hosts');


    Regards,
    Dariyoosh
     
  8. ac.arijit

    ac.arijit Forum Advisor

    Messages:
    217
    Likes Received:
    22
    Trophy Points:
    280
    Location:
    Kolkata, India
    Hi Dariyoosh,
    Thanks for the detailed informative post,

    Yes, all the priviledges are already granted.
    The difference b/w the java source code i used earlier & the one u posted is that its a method which doesn't anything.

    But the code u posted, compiled properly and with no errors or warnings. The publishing of java call also was successful.
    But when i call it by the following pl/sql it gives an error:
    Code (SQL):

    SET ServerOutput    ON;
    DECLARE
        POutput    Dbms_Output.Chararr;
        PLines     INTEGER := 1000;
    BEGIN
        Dbms_Output.Enable(1000000);
        Dbms_Java.Set_Output(1000000);
        Amrit_Developers_Toolkit.ExecuteCmd(p_command => '/usr/bin/rwrun report=/d02/clone-appl/apps/apps_st/appl/gl/12.0.0/reports/US/AMRIT_BS_TFRM.rdf userid=apps/apps desformat=pdf destype=file desname=/d02/clone-appl/apps/apps_st/appl/gl/12.0.0/reports/US/AMRIT_BS_TFRM.pdf PERIOD_NAME=''APR-11-12'' P_ACCESS_SET_ID=1000 P_ORG_ID=82 P_UNIT=11');
        Dbms_Output.Get_Lines(POutput,PLines);
        FOR i IN    1 .. PLines
        Loop
            Dbms_Output.Put_Line(POutput(i));
        END Loop;
    END;
     
    This gives an output message: "Process err :/bin/sh: /usr/bin/rwrun: No such file or directory".

    Plz reply ASAP
    Regards
     
  9. dariyoosh

    dariyoosh Forum Advisor

    Messages:
    118
    Likes Received:
    19
    Trophy Points:
    260
    What do you get when in Linux terminal you type

    Code (Text):

    $ which rwrun
     
    Does it return the path to the executable?
     
  10. ac.arijit

    ac.arijit Forum Advisor

    Messages:
    217
    Likes Received:
    22
    Trophy Points:
    280
    Location:
    Kolkata, India
    Hi dariyoosh,

    When i run this command from Toad Network Utilities this executes and creates a .pdf file(the output of the report) in the location provided.

    Regards
     
  11. dariyoosh

    dariyoosh Forum Advisor

    Messages:
    118
    Likes Received:
    19
    Trophy Points:
    260
    So what was the issue if your problem is solved? Because according to your precedent post, you got errors.
    Writing down hear, will allow those who may encounter the same problem to learn.


    Regards,
    Dariyoosh
     
  12. ac.arijit

    ac.arijit Forum Advisor

    Messages:
    217
    Likes Received:
    22
    Trophy Points:
    280
    Location:
    Kolkata, India
    Hi dariyoosh,

    I didn't properly got your last post. I believe u missed the scenario somewhere, the problem is ...
    Code (SQL):

    rwrun report=/d02/clone-appl/apps/apps_st/appl/gl/12.0.0/reports/US/AMRIT_BS_TFRM.rdf userid=apps/apps desformat=pdf destype=file desname=/d02/clone-appl/apps/apps_st/appl/gl/12.0.0/reports/US/AMRIT_BS_TFRM.pdf PERIOD_NAME="APR-11-12" P_ACCESS_SET_ID=1000 P_ORG_ID=82 P_UNIT=11
     
    when i run this command from toad network utilities manually it works, but when the same command is passed within (') quotes into the java call from pl/sql block programmatically it executes error free but doesn't creates the desired .pdf output in the location.

    I hope i made it clear.
    Regards
    Ari
     
  13. dariyoosh

    dariyoosh Forum Advisor

    Messages:
    118
    Likes Received:
    19
    Trophy Points:
    260
    Strange!

    So the destination directory where you would like to store the output PDF, as I understand is:

    Code (Text):

    /d02/clone-appl/apps/apps_st/appl/gl/12.0.0/reports/US/
     
    As I showed in my example, the code works, so there is no problem (in my opinion) with the code, again that would rather be a lack of privilege,
    particularly because you say it works with Toad. While using with Java, I imagine you use the very same schema, non?

    Assuming that your schema name running the Java program is : 'testschema' (just an example), are you sure you granted properly the following permission by user SYS:

    Code (Text):

    EXECUTE DBMS_JAVA.grant_permission('TESTSCHEMA', 'java.io.FilePermission', '/d02/clone-appl/apps/apps_st/appl/gl/12.0.0/reports/US/', 'read ,write, execute, delete');
    EXECUTE DBMS_JAVA.grant_permission('TESTSCHEMA', 'SYS:java.io.FilePermission', '/usr/bin/rwrun', 'execute');
     
    Again, make sure that you use absolute path of the executable, that is: /usr/bin/rwrun instead of rwrun.


    Regards,
    Dariyoosh
     
  14. ac.arijit

    ac.arijit Forum Advisor

    Messages:
    217
    Likes Received:
    22
    Trophy Points:
    280
    Location:
    Kolkata, India
    Hi dariyoosh,

    Yes, i already granted the above mentioned priviledges. Also i have re-executed the command for the sake of your insistence.

    Still when i execute the following:
    Code (SQL):

    SET ServerOutput    ON;
    DECLARE
        POutput    Dbms_Output.Chararr;
        PLines     INTEGER := 1000;
    BEGIN
        Dbms_Output.Enable(1000000);
        Dbms_Java.Set_Output(1000000);
        Amrit_Developers_Toolkit.ExecuteCmd(p_command => '/usr/bin/rwrun report=/d02/clone-appl/apps/apps_st/appl/gl/12.0.0/reports/US/AMRIT_BS_TFRM.rdf userid=apps/apps desformat=pdf destype=file desname=/d02/clone-appl/apps/apps_st/appl/gl/12.0.0/reports/US/AMRIT_BS_TFRM.pdf PERIOD_NAME=''APR-11-12'' P_ACCESS_SET_ID=1000 P_ORG_ID=82 P_UNIT=11');
        Dbms_Output.Get_Lines(POutput,PLines);
        FOR i IN 1 .. PLines
        Loop
            Dbms_Output.Put_Line(POutput(i));
        END Loop;
    END;
     
    And after compilation i get an dbms output as "Process err :/bin/sh: /usr/bin/rwrun: No such file or directory" and the .pdf isn't generated. I doubt that the command "rwrun" is not identifiable or such kind of an issue is probably occurring. Although i'm perplexed that if this command is working from network utilities then why not from java call? .. Shall i try some another command, because this is clear that the java call is working properly(error-free) and the output relates to the command rwrun. So, would u suggest me to try some dummy command in this java call. But the objective for me is to execute this command .. plz keep this in mind. :D

    Regards
    Ari
     
  15. dariyoosh

    dariyoosh Forum Advisor

    Messages:
    118
    Likes Received:
    19
    Trophy Points:
    260
    What I tried to say, was that the code that I provided works and I gave you even the output (I don't know whether you tried it) so if it doesn't work
    for your command, there could be two reason:

    - Lack of privilege, which according to what you say is not the issue as you have already granted all required privileges.

    - The command's executable path is not /usr/bin/rwrun, maybe somewhere else, that's why yesterday I asked you in the case where the environment variables are properly defined for your oracle Linux user, what do you get as output when you run the following command in a Linux sell:
    Code (Text):

    $ which rwrun
     
    Because you say that you get the following error message
    Code (Text):

    Process err :/bin/sh: /usr/bin/rwrun: No such file or directory
     
    Maybe it means that rwrun is not in /usr/bin, no? Did you verify that it is in that directory? Something like this
    Code (Text):

    ls /usr/bin | grep rwrun
     
    What is the Linux distribution that you're using?

    Regards,
    Dariyoosh
     
  16. ac.arijit

    ac.arijit Forum Advisor

    Messages:
    217
    Likes Received:
    22
    Trophy Points:
    280
    Location:
    Kolkata, India
    Hi dariyoosh,

    I'm sorry, i was careless in confirming the path of the rwrun.sh .. now i corrected it and the program identified the rwrun command.

    But now i got some other error output from the pl/sql call, find it below:
    Code (SQL):

    SET ServerOutput    ON;
    DECLARE
        POutput    Dbms_Output.Chararr;
        PLines     INTEGER := 1000;
    BEGIN
        Dbms_Output.Enable(1000000);
        Dbms_Java.Set_Output(1000000);
        Amrit_Developers_Toolkit.ExecuteCmd(p_command => '/d02/clone-appl/apps/tech_st/10.1.2/bin/rwrun report=/d02/clone-appl/apps/apps_st/appl/gl/12.0.0/reports/US/AMRIT_BS_TFRM.rdf userid=apps/apps desformat=pdf destype=file desname=/d02/clone-appl/apps/apps_st/appl/gl/12.0.0/reports/US/AMRIT_BS_TFRM.pdf PERIOD_NAME=''APR-11-12'' P_ACCESS_SET_ID=1000 P_ORG_ID=82 P_UNIT=11');
        Dbms_Output.Get_Lines(POutput,PLines);
        FOR i IN 1 .. PLines
        Loop
            Dbms_Output.Put_Line(POutput(i));
        END Loop;
    END;
    //
    Output:
    Process err :/d02/clone-appl/apps/tech_st/10.1.2/bin/rwrun: error while loading shared libraries: libjvm.so: cannot OPEN shared object file: No such file OR directory
    PL/SQL PROCEDURE successfully completed.
     
    rwrun path: /d02/clone-appl/apps/tech_st/10.1.2/bin/
    I cannot relate this file libjvm.so .. Any idea ??

    Regards
    Ari
     
  17. dariyoosh

    dariyoosh Forum Advisor

    Messages:
    118
    Likes Received:
    19
    Trophy Points:
    260
    Well, at least the code is now good :)

    As far as I know, oracle uses its own JVM. Is by any chance several (different version) JVM installed on the same machine? if it is the case you will need to verify whether the good JVM is referenced by oracle. Normally this can be done by defining JAVA_HOME environment variable in ~/.bash_profile for the user oracle (if this is the Linux user defined as the owner of the instance and the one who is supposed to run this program). Or according to what Tim Hall suggests add the following lines to ~/.bash_profile (if it is not already there)

    Code (Text):

    LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
    CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
     
    Regards,
    Dariyoosh
     
  18. ac.arijit

    ac.arijit Forum Advisor

    Messages:
    217
    Likes Received:
    22
    Trophy Points:
    280
    Location:
    Kolkata, India
    Hi dariyoosh,

    It really feels good when u say, the code is good !! :D

    Although, its not done completely yet. Yes the .bash_profile was missing the lines mentioned in your last post. So, i added the lines and re-executed the pl/sql script but still the error remains.

    So i actually checked the paths which were defined as LD_LIBRARY_PATH .. and found out that the file libjvm.so wasn't existing in any of the locations.

    So, what now?? ..
    Regards
    Ari
     
  19. dariyoosh

    dariyoosh Forum Advisor

    Messages:
    118
    Likes Received:
    19
    Trophy Points:
    260
    Hi,


    The error message says:
    Code (Text):

    ... libjvm.so: cannot OPEN shared object file: No such file OR directory ...
     
    So probably the library is missing on the system. Ask your Linux system administrator in order to know:

    - Whether he has already installed this specific library, if yes, why is not visible
    - What will be the impact on both system and oracle if the missing library is installed? And what would be
    the appropriate version to install (Both Linux OS administrator and also your oracle DBA should confirm these)

    The problem with shared libraries is that as their name shows they are shared and used by many
    programs, so you cannot just find for example a RPM package for a given library and say, Ah cool! finally
    I found it and I'm going to install it, because there could be conflicts in terms of version and dependencies.


    What Linux distribution you use? Redhat Enterprise, Ubuntu, Suse, oracle, ... ?

    Regards,
    Dariyoosh
     
  20. ac.arijit

    ac.arijit Forum Advisor

    Messages:
    217
    Likes Received:
    22
    Trophy Points:
    280
    Location:
    Kolkata, India
    Hi,

    Its Redhat Enterprise. Ok, i know that shared libraries and OS system files are something a developer should keep distance to but if u got anything about this library to offer then please share. I'll be thankful.

    Regards
    Ari