Running Unix Command from WEB-APPLICATION

Hi all,
I want to run unix command from a java-based web application. the basic code part is this ---
public class RunCommand
      public String runIt()
          String s = null, returnString = "";
          Process p=null;
          try
                   Runtime rt = Runtime.getRuntime();
              p = rt.exec("sh testPOC.ksh");
              p.waitFor();
              BufferedReader stdInput = new BufferedReader(new
                   InputStreamReader(p.getInputStream()));
              BufferedReader stdError = new BufferedReader(new
                   InputStreamReader(p.getErrorStream()));
              // read the output from the command
              returnString += "Here is the standard output of the command:<br>";
              while ((s = stdInput.readLine()) != null) {
                  returnString += s;
              // read any errors from the attempted command
              returnString += "Here is the standard error of the command (if any): <br>";
              while ((s = stdError.readLine()) != null) {
                  returnString += s;
          catch (IOException e)
              returnString += "exception happened - here's what I know: ";
              returnString += "error-> " + e.getMessage();
          catch(Exception e)
            returnString += "exception happened - here's what I know: ";
              returnString += "error-> " + e.getMessage();
          return returnString;
  }this class is kept as an inner class. The control comes to its outer class, from servlet, from which the runit() is called. but the exception is occuring at line of p=rt.exec(.....). it tells "<command name> : not found transaction completed" [got this using getMessage() method].
i am unable to show(and see, too) the stacktrace, because i don't have access to that test environment and its log. i can't run this in local because its windows one.
now can anyone tell me, where is the problem. is there any limitation in web application server/container? this was successful when i used command prompt writing a .java file. Please help me. Thanks in advance...

Friends, i've got, where the problem is.
when we run a class file directly from a command prompt, we get an environment with that shell window. but for a servlet application running these kind of commands from a class creates kind of child processes. each and every command is executed as a child process of jvm and don't get those environment. we have 'PATH' variable in the environment. when a command (say, 'dir' or 'sh' or 'ls', etc.) is executed, the shell first search for that executable file (i.e. dir / sh / ls) in the given paths in the variable 'PATH'. this is not available for the child commands of jvm. hence the basic commands are searched in the current directory of the jvm and they are failed.
i solved the problem giving full path of the commands. like :
p = rt.exec("/bin/sh runningScript.ksh")

Similar Messages

  • How to run unix command from Oracle Foms 10g

    OS: UNIX Solaries, Oracle Application Server 10g
    To run shell script from Oracle Forms, I used the following host('/bin/bash /u01/compile.sh') and it works well
    Now, I need to run unix command something like
    host('mv form1.fmx FORM1.FMX') but it's not working
    I tried to append the command "mv form1.fmx FORM1.FMX" to the compile.sh shell script but also it's not working although the rest lines of the shell script is running well
    Edited by: slamonty on Aug 23, 2012 12:36 AM

    Yes, Thank you so much, it works well as follow
    $ /bin/mv /u01/oracle/runtime/test/form1.fmx  /u01/oracle/runtime/test/FORM1.FMX Edited by: slamonty on Aug 23, 2012 9:59 AM
    Edited by: slamonty on Aug 23, 2012 11:14 AM

  • Using Unix commands from Java Application

    Hi,
    I need to write an Java application such that could run Unix commands in a Unix box.
    For example, my Java app needs to log in the Unix box, change directory (cd), create new folder (mkdir), list the current files in folder (ls), mount a new device (mount), etc.
    Thank you very much.
    Hung

    you can use java.lang.Runtime.exec to invoke OS commands, but if you're going to be completing a sequence that complicated and need to manage error handleing well, it might be best to just invoke a native method or write a shell script that does all of that stuff and then invoke that script via Runtime.exec . The Runtime class has limitations when you start invoking processes that require user input (like 'su'). Search the forums for more extensive examples on how to use Runtime.

  • Running unix commands from within a procedure

    Oracle 11.1, AIX 6.1
    ================
    A developer would like to know what the commands are to execute from within a procedure to run unix commands on the database server and capture those results back to the procedure for parsing & manipulation.
    Thanks.

    Don't take this as the correct way to do it, but this is merely 'a' way to do it:
    have a db procedure thats executes a db function
    create or replace procedure csproc(p_cmd in varchar2)
    as
    x number;
    begin
    x:=csfunc(p_cmd);
    dbms_output.put_line('x is: '||x);
    end;
    /The function calls a piece of java to execute the os command and return the return code of the os command
    create or replace function csfunc( p_cmd  in varchar2) return number
    as language java
    name 'csclass.RunThis(java.lang.String[]) return integer';
    /Here is the java class to run the os command
    create or replace and compile java source
    named "csclass"
    as
    import java.io.*;
    import java.lang.*;
    public class csclass extends Object
    public static int RunThis(String[] args)
       Runtime rt = Runtime.getRuntime();
        int        rc = -1;
        try
           Process p = rt.exec(args[0]);
          int bufSize = 4096;
           BufferedInputStream bis =
           new BufferedInputStream(p.getInputStream(), bufSize);
           int len;
           byte buffer[] = new byte[bufSize];
           // Echo back what the program spit out
           while ((len = bis.read(buffer, 0, bufSize)) != -1)
              System.out.write(buffer, 0, len);
           rc = p.waitFor();
        catch (Exception e)
           e.printStackTrace();
           rc = -1;
        finally
           return rc;
    /and finally the os command - in this case its a very simple shell script
    #!/usr/bin/ksh
    echo "Hi" >> /app/oracle/workdir/cs.logwill have to grant privileges to my user 'CS' to run the various os commands
    exec dbms_java.grant_permission('CS','java.io.FilePermission','/app/oracle/workdir/cs.ksh','read,execute');
    exec dbms_java.grant_permission('CS','java.io.FilePermission','/app/oracle/workdir/cs.log','write');
    exec dbms_java.grant_permission('CS','SYS:java.lang.RuntimePermission','*','readFileDescriptor');
    exec dbms_java.grant_permission('CS','SYS:java.lang.RuntimePermission','*','writeFileDescriptor');and finally can run the procedure from within the db
    set serveroutput on
    exec dbms_java.set_output(1000000);
    exec csproc('/app/oracle/workdir/cs.ksh');
    x is: 0
    PL/SQL procedure successfully completed.to prove it works ok the logfile shows an entry:
    'Hi'

  • Run Unix command from windows

    I would like to run a unix command and capture the output by running a java program on a windows 98 machine, this will be ran on a secure intranet. What is the best way to do that. If anyone knows of an example source code that would be great.
    thanks,
    Dean

    Try this. It always works for me.
    import java.io.*;
    public class Exec {
        private BufferedReader out;
        private Process p;
        public Exec(String cmd) throws IOException {
            p = Runtime.getRuntime().exec(cmd);
            out = new BufferedReader(new InputStreamReader(p.getInputStream()));
        public BufferedReader getBufferedReader() {
            return out;
        public void waitFor() throws InterruptedException {
            p.waitFor();
        public static void main(String [] args) throws IOException,
                InterruptedException {
            final Exec p = new Exec("your command goes here.");
            new Thread(new Runnable() {
                public void run() {
                    try {
                        String s = null;
                        while((s = p.getBufferedReader().readLine()) != null) {
                            System.out.println(s);
                    catch(IOException io){}
            }).start();
            p.waitFor();
    }

  • Run Unix command from PLSQL

    I am trying to execute simple Unix command such as (/UItools/touch test.txt or /UItools/cp t1.txt t2.txt ) from PL/SQL. Could somebody pls help?

    Hi,
    you can use DBMS_PIPE to achieve this
    CREATE OR REPLACE FUNCTION exec_host_command( lc_cmd IN VARCHAR2 )
    RETURN INTEGER IS
    ln_status NUMBER;
    lc_errormsg VARCHAR2(80);
    lc_pipe_name VARCHAR2(30);
    BEGIN
    lc_pipe_name := ‘HOST_PIPE’;
    dbms_pipe.pack_message( lc_cmd );
    ln_status := dbms_pipe.send_message(lc_pipe_name);
    RETURN ln_status;
    END;
    Alternatively you can write a java stored procedure to do the same
    CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "Cmd" AS
    --==========================================================--
    -- Class Cmd
    --==========================================================--
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    public class Cmd {
    *Static method to invoke host system commands
    *input variable String Command
    *Returns int. 0 for success and any other number
    *for failure of the command
    public static int executeCommand(String s_command) {
    try {
    /*Get the runtime shell and execute the system command
    *Wait till the command is executed
    final Process pr = Runtime.getRuntime().exec(s_command);
    pr.waitFor();
    return pr.exitValue();
    catch (Exception ex) {
    System.out.println(ex.getLocalizedMessage());
    return -1;
    }/*End of function executeCommand*/
    SHOW ERRORS
    EXIT;
    Grant the permissions
    --Grant Host File permissions to the APPS schema
    DBMS_JAVA.grant_permission ('<USER>', 'java.io.FilePermission',
    '<<ALL FILES>>', 'read ,write, execute, delete');
    --Grant Runtime Write permissions to the APPS schema
    DBMS_JAVA.grant_permission ('<USER>', 'SYS:java.lang.RuntimePermission',
    'writeFileDescriptor', '');
    --Grant Runtime Read permissions to the APPS schema
    DBMS_JAVA.grant_permission ('<USER>', 'SYS:java.lang.RuntimePermission',
    'readFileDescriptor', '');
    and create a wrapper plsql call
    FUNCTION Cmd (p_command IN VARCHAR2)
    RETURN NUMBER
    AS LANGUAGE JAVA
    NAME 'Cmd.executeCommand (java.lang.String) return int';
    Edited by: navsriva on Apr 13, 2010 3:21 PM

  • Running Unix Commands from SQLJ

    In straight JAVA I can execute a UNIX command like this
    String [] cmd = {"foo"} ;
    Process m ;
    m = Runtime.getRuntime().exec(cmd) ;
    When I do this in SQLJ I gen an exception raised.
    Is there a way around this?

    I assume you are trying to execute this Java code in a server-side stored procedure?
    I do not think that the server-side JavaVM allows you to execute Unix command lines. On the other hand, if you are trying to do this on the client, there should be nothing preventing you.

  • Running UNIX command from Java

    import java.lang.* ;
    import java.io.*   ;
    public class TestRunTime
        public static void main(String args[])
            int rc = -1 ;
            String yard = "psnsy" ;
            String ifwList = "[email protected],[email protected]" ;
            String cmd = "/usr/bin/mailx -r oracle -s \"PMC - Missing Interface Files from " + yard +
                               "\" " + ifwList + " < /interface/nwps/missingfiles.txt" ;
            rc = RunThis(cmd) ;
            System.out.println(rc) ;
        private static int RunThis(String str)
             Runtime rt = Runtime.getRuntime();
             int        rc = -1;
             try
                Process p = rt.exec(str);
                p.waitFor() ;
                BufferedReader buf = new BufferedReader(new InputStreamReader(p.getInputStream()));
                String line = "";
                while ((line = buf.readLine()) != null)
                   System.out.println(line) ;
                rc = 0 ;
                return rc ;
             catch ( Throwable t  )
                  t.printStackTrace();
                  rc = -1 ;
                  throw new RuntimeException() ;
    }When I run java TestRunTime
    all it does is hangs and never completes.
    I can run the string cmd from the UNIX shell and it runs as expected - I receive an email.

    jschell wrote:
    sabre150 wrote:
    Whether the detail is as you say or as I say does not remove the need to process the exec()ed processes stdout and stderr each in their own thread. Since the OP is not writing to stdin he can handle one of stdout or stderr in the Thread that invokes the exec() but the other needs a separate thread.If the streams are stripped from the process then...
    1. They should not be stripped until they are in their own thread.
    2. Each requires their own thread.
    But since the OP isn't stripping either, no other threads are needed. Nor does the OP need to strip them.I have to disagree. The following code is based on the traps article and sends output to stdout and to stderr from the 'sh' program. Run as is it deadlocks. Run by changing the 'false' to 'true' in the 'if' statement it does not deadlock.
    If one changes the code to process only stdout or stderr but not both then it deadlocks.
    Running the same code on Windows XP and Windows 2000 but using 'cmd.exe' instead of 'sh' and using 'dir' instead of 'ls' produces the same result.
    Running similar code that just runs a perl script without any stdin but that writes to both stdout and stderr it deadlocks if one does not process both stdout and stderr in separate threads.
    If one processes the Process stdout and stderr streams then one does not get a deadlock.
    This is entirely consistent with what the 'traps' article says and I hope consistent with what I have written in this thread.
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.OutputStreamWriter;
    import java.io.Writer;
    class StreamGobbler extends Thread
        private int count = 0;
        private final InputStream is;
        private final String type;
        StreamGobbler(InputStream is, String type)
            this.is = is;
            this.type = type;
        public void run()
            try
                final InputStreamReader isr = new InputStreamReader(is);
                final BufferedReader br = new BufferedReader(isr);
                String line = null;
                while ((line = br.readLine()) != null)
                    System.out.println(++count + "\t " + type + "> " + line);
            } catch (IOException ioe)
                ioe.printStackTrace();
    public class Sabre20091015_2
        public static void main(String args[]) throws Exception
            final Process proc = Runtime.getRuntime().exec("sh");
            if (false)
                new StreamGobbler(proc.getErrorStream(), "ERROR").start();
                new StreamGobbler(proc.getInputStream(), "OUTPUT").start();
            final Writer writer = new OutputStreamWriter(proc.getOutputStream());
            for (int commandIndex = 0; commandIndex < 20000; commandIndex++)
                writer.write("echo Index " + commandIndex + "\n");
                writer.write("ls\n");
                writer.flush();
                writer.write("fnaskfdkdhflakjfljd\n");
                writer.flush();
            writer.close();
            final int exitValue = proc.waitFor();
            System.out.println("Exit value = " + exitValue);
    }

  • Running unix commands from sqlplus

    I will like to change my directory from sqlprompt. What is the command to do that?
    SQL>

    Don't think you can do what you want. The 'host' or '!' command in sqlplus spawns another shell, as soon as it returns the settings are back to the parent shell "the one that started sqlplus".

  • Run Unix command / Run Unix shell script from Forms9i

    Hi,
    I have a requirement to run Unix command and Unix shell scripts from Forms9i.
    I know HOST command cannot be used directly. I also know we can create some JAVA stored procedure to perform the task, but I don't want to create any JAVA stored procedure as there are some security concerns.
    Please point me towards any other way to achieve the same.
    I would really appreciate your help.
    Thanks,
    Kumar

    There is no reason why HOST can't be used. This is what it is for. As for using Java, it is not a stored procedure that you would be using, it would be imported Java (imported into the form).
    The best way to use the HOST command is to call a script (.sh) rather than calling a Unix command directly. This is because HOST will not pick up environment variables set at the system level. So the script would first need to set the necessary environment variables then call the desired commands.

  • Run multiple unix commands from ODI procedure

    I want to run a series of unix commands from ODI procedure. I dont want to use Unix shell scripts. (I know that works).I am just trying to place the contents of the shell scripts in ODI procedure with Operating system as technology. But I am unable to execute the proecedure.
    For example below is a very small 3 line commands I would execute
    filename="/var/test.txt"
    ls -l $filename > /var/anotherfile.txt
    chmod 777 $filename
    I am not sure if there is any specific syntax that I have to follow for executing unix commands. Also I dont want to write a Jython and use os.system command as well.
    Appreciate any help on this

    First your original question... You can put more than one DOS command on a single line, simply separate each command with an ampersand (&). For example:
    mkdir c:\abc & cd abc & dir*
    Regarding your concerns about performance, well that would depend on exactly what you mean. Using CLIENT_HOST (or HOST on the server) simply opens a shell (DOS in this case) then passes your command to it. The performance of performing this action really isn't measurable. Basically you are just pressing a button and you should get a near immediate action. As for the performance of executing each command, that has nothing to do with Forms. Once the command is passed to the shell, the rest is a function of the shell and whatever command you passed.
    Having said that, if you were to write something sloppy like a loop (in pl/sql) which called CLIENT_HOST lots of times repeatedly, then yes there would be a performance problem because the pushing of the button will cause an exchange to and from the server and each cycle in the loop will do the same.
    So the answer to how performance is impacted will depend on what exactly you need to accomplish. If it is a single call to CLIENT_HOST, this should be fine.

  • Backup/Recovery from web application

    Hello guys,
    I am using Oracle 9i as DB and Oracle 9iAS for web application server. I want to provide Backup and Recovery functionality to the user via web. I don't know any thing in this regard.
    Is it possible that we can take backup and recovery from web application?
    Is there any alternative for this function.
    any other comments will be appreciated.
    Thank you,
    Jawed Nazar Ali

    Read this article in order to get an idea about Java Stored Procedures.
    Oracle Developer JAVA STORED PROCEDURES
    Simplify with Java Stored Procedures
    By Kuassi Mensah
    Use Java stored procedures to bridge SQL, XML, Java, and J2EE and Web Services.
    Stored procedures allow a clean separation of persistence logic that runs in the database tier from business logic that runs in the middle tier. This separation reduces overall application complexity and increases reuse, security, performance, and scalability.
    A major obstacle, however, for widespread adoption of stored procedures is the set of various proprietary, database-dependent implementation languages that different database vendors use. The use of Java-based stored procedures fixes this concern. Oracle has implemented ANSI standards that specify the ability to invoke static Java methods from SQL as procedures or functions. This implementation is called simply "Java stored procedures."
    In this article, you will learn how Java stored procedures help simplify and increase the performance of your business logic and extend database functionality. I'll show how Oracle enables the use of Java stored procedures within the database. I'll also look at how Java stored procedures access data, and show how to create a basic Java stored procedure.
    PL/SQL or Java
    When you think of Oracle stored procedures, you probably think of PL/SQL. Oracle, however, has provided Java support in the database since Oracle8i, to offer an open and portable alternative to PL/SQL for stored procedures. I can hear the $64,000 question: "How do I choose between PL/SQL and Java? Should I forget all the things I've been told about PL/SQL and move on to the greener Java pastures?"
    Both languages are suitable for database programming, and each has its strengths and weaknesses. In deciding which language to use, here's a general rule of thumb:
    Use PL/SQL for database-centric logic that requires seamless integration with SQL and therefore complete access to database objects, types, and features.
    Use Java as an open alternative to PL/SQL for database independence, but also for integrating and bridging the worlds of SQL, XML, J2EE, and Web services.
    OracleJVM Lets You Run Java within the Database
    Since Oracle8i, Release 1 (Oracle 8.1.5), Oracle has offered a tightly integrated Java virtual machine (JVM) that supports Oracle's database session architecture. Any database session may activate a virtually dedicated JVM during the first Java code invocation; subsequent users then benefit from this already Java-enabled session. In reality, all sessions share the same JVM code and statics—only private states are kept and garbage collected in an individual session space, to provide Java sessions the same session isolation and data integrity capabilities as SQL operations. There is no need for a separate Java-enabled process for data integrity. This session-based architecture provides a small memory footprint and gives OracleJVM the same linear SMP scalability as the Oracle database.
    Creating Java Stored Procedures
    There are a few steps involved in turning a Java method into a Java stored procedure. These include loading the Java class into the database using the loadjava utility, and publishing the Java methods using a call specification (Call Spec) to map Java methods, parameter types, and return types to their SQL counterparts. The following section shows how to do this.
    I'll use a simple Hello class, with one method, Hello.world(), that returns the string "Hello world":
    public class Hello
    public static String world ()
    return "Hello world";
    The Loadjava Utility
    Loadjava is a utility for loading Java source files, Java class files, and Java resource files; verifying bytecodes; and deploying Java classes and JAR files into the database. It is invoked either from the command line or through the loadjava() method contained within the DBMS_JAVA class. To load our Hello.class example, type:
    loadjava -user scott/tiger Hello.class
    As of Oracle9i Release 2, loadjava allows you to automatically publish Java classes as stored procedures by creating the corresponding Call Specs for methods contained in the processed classes. Oracle provides Oracle9i JDeveloper for developing, testing, debugging, and deploying Java stored procedures.
    The Resolver Spec
    The JDK-based JVM looks for and resolves class references within the directories listed in the CLASSPATH. Because Oracle database classes live in the database schema, the OracleJVM uses a database resolver to look for and resolve class references through the schemas listed in the Resolver Spec. Unlike the CLASSPATH, which applies to all classes, the Resolver Spec is applied on a per-class basis. The default resolver looks for classes first in the schema in which the class is loaded and then for classes with public synonyms.
    loadjava -resolve <myclass>
    You may need to specify different resolvers, and you can force resolution to occur when you use loadjava, to determine at deployment time any problems that may occur later at runtime.
    loadjava -resolve -resolver "((* SCOTT) (foo/bar/* OTHERS)
    (* PUBLIC))"
    Call Spec and Stored Procedures Invocation
    To invoke a Java method from SQL (as well as from PL/SQL and JDBC), you must first publish the public static method through a Call Spec, which defines for SQL the arguments the method takes and the SQL types it returns.
    In our example, we'll use SQL*Plus to connect to the database and define a top-level Call Spec for Hello.world():
    SQL> connect scott/tiger
    SQL> create or replace function helloworld return
    VARCHAR2 as language java name 'Hello.world () return
    java.lang.String';
    Function created.
    You can then invoke the Java stored procedure as shown below:
    SQL> variable myString varchar2[20];
    SQL> call helloworld() into :myString;
    Call completed.
    SQL> print myString;
    MYSTRING
    Hello world
    Java stored procedures are callable, through their Call Spec, from SQL DML statements (INSERT, UPDATE, DELETE, SELECT, CALL, EXPLAIN PLAN, LOCK TABLE, and MERGE), PL/SQL blocks, subprograms, and packages, as well as database triggers. The beauty of Call Spec is that stored procedure implementations can change over time from PL/SQL to Java or vice versa, transparently to the requesters.
    Call Spec abstracts the call interface from the implementation language (PL/SQL or Java) and therefore enables sharing business logic between legacy applications and newer Java/J2EE-based applications. At times, however, when invoking a database-resident Java class from a Java client, you may not want to go through the PL/SQL wrapper. In a future release, Oracle plans to provide a mechanism that will allow developers to bypass the Call Spec.
    Advanced Data-Access Control
    Java stored procedures can be used to control and restrict access to Oracle data by allowing users to manipulate the data only through stored procedures that execute under their invoker's privileges while denying access to the table itself. For example, you can disable updates during certain hours or give managers the ability to query salary data but not update it, or log all access and notify a security service.
    Sharing Data Logic Between Legacy and J2EE Applications
    Because legacy applications and J2EE applications both invoke stored procedures through the Call Spec, the same data logic can be shared between J2EE and non-J2EE worlds. Thanks to Call Spec, this data logic can be shared regardless of the implementation language used (whether PL/SQL or Java).
    Autogeneration of Primary Keys for BMP Entity Beans
    When using BMP for EJB entity beans, a bean instance can be uniquely identified by the auto-generated primary key associated with the newly inserted data as a return value for ejbCreate(). You can retrieve this value within ejbCreate() in one database operation by using a stored procedure that inserts the corresponding data and retrieves or computes the primary key. Alternatively, you could insert the data and retrieve the corresponding key (or ROWID) in one SQL statement, using the RETURN_GENERATED_KEYS feature in JDBC 3.0. However, the stored procedure approach is more portable across JDBC driver versions and databases.
    You can implement this pattern with these three steps:
    Create the Java stored procedure, defining a public static Java method insertAccount() within a public GenPK class. This method will insert data, compute a unique key (by passing out a sequence number), and return the computed key as primary key.
    Define the Call Spec.
    CREATE OR REPLACE PROCEDURE insertAccount(owner IN
    varchar, bal IN number, newid OUT number)
    AS LANGUAGE JAVA NAME 'GenPK.insertAccount(
    java.lang.String [])';
    Invoke the stored procedure within ejbCreate().
    Public AccountPK ejbCreate(String ownerName, int balance) throws CreateException
    try {
    CallableStatement call = conn.prepareCall{
    "{call insertAccount(?, ?, ?)}"};          
    return new AccountPK(accountID);
    Custom Primary Key Finders for CMP Entity Beans
    Finder methods are used for retrieving existing EJB entity bean instances. Primary key finders allow you to retrieve a uniquely identified EJB instance. For CMP entity beans, the EJB container automatically generates the primary key finder findByPrimaryKey() method, based on declarative description. In some situations, however, you might need more control; for example, you may need a specialized finder such as findByStoredProcKey(). In these situations, you can use Java stored procedures in conjunction with an object relational framework (such as Oracle9i Application Server [Oracle9iAS] TopLink) to implement a custom primary key finder method. After you define the EJB finder as a REDIRECT or NAMED finder, TopLink will generate the SQL query for retrieving the bean instance.
    Data-Driven EJB Invocation
    In a data-driven architecture, business logic invocation can be triggered as a result of database operations (such as inserts, updates, or deletes). A Java stored procedure implementing the data logic can be declared as a database trigger to invoke EJBs running in a middle-tier J2EE application server. You can make EJB calls by using either standard remote method invocation (RMI) over Interoperable Inter-ORB Protocol (IIOP), using a J2EE 1.3 compatible server, or RMI over a vendor-specific transport protocol (such as ORMI with Oracle9iAS/OC4J or RMI over T3 with BEA WebLogic). Each application server vendor has its own optimized protocol while providing RMI over IIOP for interoperability. Oracle9iAS supports both RMI calls over IIOP and ORMI protocols.
    Data-Driven Messaging
    Oracle9i Database embeds Advanced Queuing (AQ), which is an integrated, persistent, reliable, secure, scalable, and transactional message-queuing framework. Oracle exposes AQ features to Java developers through the standard Java Messaging System (JMS) API. Java stored procedures can invoke AQ operations through the JMS interface to allow fast, intra-session, scalable, data-driven messaging.
    Java stored procedures can use JMS to invoke AQ operations. You can implement this pattern in four steps:
    Create and start the JMS Queue (to do so, embed the following operations within a SQL script):
    execute dbms_aqadm.create_queue_table(queue_table =>
    'queue1', queue_payload_type =>
    'SYS.AQ$_JMS_TEXT_MESSAGE', comment => 'a test queue',
    multiple_consumers => false, compatible => '8.1.0');
    execute dbms_aqadm.create_queue( queue_name => 'queue1',
    queue_table => 'queue1' );
    execute dbms_aqadm.start_queue(queue_name => 'queue1');
    Create the Java stored procedure (a code snippet is shown):
    public static void runTest(String msgBody)
    try
    // get database connection
    ora_drv = new OracleDriver();
    db_conn = ora_drv.defaultConnection();
    // setup sender (cf online code sample)
    // create message
    s_msg = s_session.createTextMessage(msgBody);
    // send message
    sender.send(s_msg);
    s_session.commit();
    // receive message
    r_msg = (TextMessage) receiver.receive();
    r_session.commit();
    // output message text
    String body = r_msg.getText();
    System.out.println("message was '"+body+"'");
    Create the Call Spec:
    create or replace procedure jmsproc (t1 IN VARCHAR)
    as language java name 'jmsSample.main (java.lang.String[])';
    Invoke the stored procedure:
    call jmsproc('hello');
    Database-Assisted Web Publishing (Cache Invalidation)
    One of the common issues application architects must face is how to cache database information reliably to increase overall system performance. JCACHE is an upcoming standard specification (JSR 107) that addresses this problem. It specifies an approach for temporary, in-memory caching of Java objects, including object creation, shared access, spooling, invalidation, and consistency across JVMs. It can be used to cache read-mostly data such as product catalogs and price lists within JSP. Using JCACHE, most queries will have response times an order of magnitude faster because of cached data (in-house testing showed response times about 15 times faster).
    In order to track all the changes to the origin data and refresh the cached data, a Java stored procedure is attached to a table as a trigger. Any change to this table will result in the automatic invocation of this stored procedure, which in turn will call out a defined JSP to invalidate the JCACHE object that maps its state to the database table. Upon invalidation, the very next query will force the cache to be refreshed from the database. Next Steps
    READ MORE about Java Stored Procedures
    This article is adapted from the white paper "Unleash the Power of Java Stored Procedures." You can find the white paper at:
    /tech/java/java_db/pdf/
    OW_30820_JAVA_STORED_PROC_paper.PDF
    New PL/SQL features in Oracle9i Database, Release 2
    /tech/pl_sql/pdf/
    Paper_30720_Doc.pdf
    Resolver Spec
    /docs/products/oracle9i/
    doc_library/release2/java.920/a96659.pdf
    OracleJVM and Java 2 Security
    /docs/products/oracle9i/
    doc_library/release2/java.920/a96656.pdf
    DOWNLOAD Code
    Exercise code examples from this article:
    /sample_code/tech/
    java/jsp/Oracle9iJSPSamples.html
    LEARN about stored procedures as Web services
    /tech/webservices
    Extending Database Functionality
    One of the great things about running Java code directly in the database is the ability to implement new functionality by simply loading the code or library and using the Call Spec to make the entry points (public static methods) available to SQL, PL/SQL, Java, J2EE, and non-Java APIs. Oracle9i Database customers can easily extend database functionality. Oracle itself leverages this capability for new utilities and packages such as the XML Developer Kits (XDKs).
    Bridging SQL, PL/SQL, Java, J2EE, .NET, and XML
    The Oracle XDK is written in Java and exposes its public methods as Java stored procedures, extending the database's XML programmability. SQL, PL/SQL, Java, J2EE, and non-Java (.NET) business logic all have access to the XML parser, the XSLT processor, the XPath engine, and XML SQL Utility (XSU).
    The XML parser is accessible through the xmlparser and xmldom packages. XSU is a Java utility that generates an XML document from SQL queries or a JDBC ResultSet, and writes data from an XML document into a database table or view. Using XSU, XML output can be produced as Text, DOM trees, or DTDs. XSU is exposed to PL/SQL through the dbms_xmlquery and dbms_xmlsave packages.
    Conclusion
    The integration of the Oracle database with a Java VM enables the creation of portable, powerful, database-independent data logic and persistence logic. The loose coupling of business logic that runs in the middle tier with data logic that runs in the database tier improves application scalability, performance, flexibility, and maintenance.
    Kuassi Mensah ([email protected]) is a product manager in the Server Technologies division at Oracle.
    http://otn.oracle.com/oramag/oracle/03-jan/o13java.html
    Joel Pérez

  • Execute unix commands from Java

    Hi,
    I have a client application running on windows. This client should connect to a unix server and check for the existence of a file and display the result as "File found/File not found". In order to connect from windows to the unix server, I used the sockets and the connection is successfully established. The second part is to check for the presence of the file in unix server. I searched in google.com and the option I found to execute a unix command from java is the "Runtime.exec()". Runtime.exec is considered as the less effective (not a favorable) one.
    Is there any other option available (other than the Runtime) to execute the unix command from java? Can you please let me know.
    Thanks a lot
    Aishu

    So, please let me know how I can execute the above unix commands without Runtime.exec()You have a client and a server.
    You want something to run on the server, not the client.
    That means that something must in fact being running on the server before the client does anything at all.
    For example telnet. Or a J2EE server application.
    So is something like that running?
    If not then there absolutely no way to do what you want, even with Runtime.exec().
    If yes then what you do depends on what is running. So Runtime.exec() would be pointless if a J2EE server was running.

  • Re: Executing UNIX commands from PC Client

    Hello,
    You can run FTP on the client and connect to your unix server to
    transfer the files across.
    As far as running UNIX commands goes you can transfer the command
    set to a service object deployed on the server and run them from there.
    Hope this helps.
    Greetings,
    I have a file which needs to be FTP'd to a remote sever. The file is
    created on the PC Client tier of the application. In addition, I have a
    few unix scripts which I would like the client to execute. Is there a way
    to execute unix (or server) based commands from a Forte Service Object.
    Any help would be greatly appreciated. Thanks.
    Craig Balliet
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>
    >
    Get Your Private, Free Email at http://www.hotmail.com
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    Hi,
    If the problem is only to copy a file from one system to an other, you
    should use only Forte. Here is an abstract from the on line help :
    Copying a Set of Files Between Partitions
    To copy a set of files using the FileSystem class:
    1 In the local partition, instantiate a FileSystem object using the
    "new" operator.
    In this example, we use the name "localFileSystem" for this FileSystem
    object.
    2 Invoke a method that will execute on the remote partition, either on a
    service object or any distributed reference to an object in the remote
    partition.
    3 In this method, instantiate a FileSystem object and return it to the
    local partition.
    For this example, we will use the name "remoteFileSystem" to refer to
    this FileSystem object. Note that you do not need to set the IsAnchored
    attribute on FileSystem objects that are to be returned as distributed
    references. These objects are automatically created as anchored objects,
    so references to them in other partitions are always returned as
    distributed references.
    4 In the local partition, invoke the SetRemoteFS method on the
    localFileSystem object, using the distributed reference to
    remoteFileSystem as the remoteFS parameter.
    5 Invoke the SetRemoteFS method on the remoteFileSystem distributed
    reference, passing the localFileSystem object as the remoteFS parameter.
    6 Invoke the SetLocalDir and SetRemoteDir methods to set the working
    directory on the local and remote systems, respectively.
    7 Construct one or more file names in portable operating system format
    (see Naming Files in FileSystem Methods ) that represent the file, or
    files, that are to be copied between systems.
    8 Put the files names you constructed into TextData objects and insert
    them into an array of TextData objects.
    9 Invoke the PushFiles method on localFileSystem, using the array of
    TextData objects containing the file names, to move files from the local
    system to the remote system. If you want to move files from the remote
    system to the local system, invoke the PullFiles method instead..
    Further Information:
    Using FileSystem
    Naming Files in FileSystem Methods
    Hope this helps,
    Daniel Nguyen
    Freelance Forte Consultant
    Steven Arijs wrote:
    >
    To accomplish the FTP to the remote server , you can implement this by using
    the FileSystem Class. You will find all information you need in the Forte
    help.
    To run operating system commands (f.i. unix command and scripts) from within a
    forte application , you can use the RunCommand method on
    task.part.OperatingSystem. (See the forte help).
    You can let your client call a method on a service object that resides on the
    server and then this method will run the script using the above method.
    Hope this helps,
    Steven Arijs
    Craig_D_Balliet%[email protected] wrote:
    Greetings,
    I have a file which needs to be FTP'd to a remote sever. The file is
    created on the PC Client tier of the application. In addition, I have a
    few unix scripts which I would like the client to execute. Is there a way
    to execute unix (or server) based commands from a Forte Service Object.
    Any help would be greatly appreciated. Thanks.
    Craig Balliet
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>-
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>-
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

  • Issue with receiving response from web application

    Hi,
    I have configured B2B with business protocol as 'Custom document document over Internet', document exchange protocol as AS2-1.1 and transport protocol HTTPS1.1 to invoke a web application deployed in Oracle Application server. B2B is able to invoke the web application with HTTPS request which contains an xml.
    I have set the acknowledgment mode as 'Sync' and 'Is acknowledgement handled by B2B' as true. But while receiving the response from web application which is an xml, B2B is showing the error as
    Description: Unable to identify the document protocol of the message
    StackTrace:
    Error -: AIP-50083: Document protocol identification error
         at oracle.tip.adapter.b2b.engine.Engine.identifyDocument(Engine.java:3244)
         at oracle.tip.adapter.b2b.engine.Engine.processIncomingMessage(Engine.java:1665)
         at oracle.tip.adapter.b2b.msgproc.Request.postTransmit(Request.java:2382)
         at oracle.tip.adapter.b2b.msgproc.Request.outgoingRequestPostColab(Request.java:1825)
         at oracle.tip.adapter.b2b.msgproc.Request.outgoingRequest(Request.java:974)
         at oracle.tip.adapter.b2b.engine.Engine.processOutgoingMessage(Engine.java:1166)
         at oracle.tip.adapter.b2b.data.MsgListener.onMessage(MsgListener.java:833)
         at oracle.tip.adapter.b2b.data.MsgListener.run(MsgListener.java:400)
         at java.lang.Thread.run(Thread.java:534)
    I have added headers as present in the wire message of the request. In B2B, it is showing the wire message for response as follows.
    TO_PARTY=XXX
    AS2-To=XXX
    DOCTYPE_NAME=TestAS2DT
    DOCTYPE_REVISION=1.0
    Date=Tue, 03 Nov 2009 06:09:22 GMT
    AS2-Version=1.1
    AS2-From=YYY
    Content-Transfer-Encoding=binary
    [email protected]
    ACTION_NAME=TestAS2_BA
    Content-Type=application/xml
    Server=Oracle-Application-Server-10g/10.1.3.4.0 Oracle-HTTP-Server
    MIME-version=1.0
    User-Agent=AS2 Server
    FROM_PARTY=YYY
    Content-Disposition=attachment; filename=1.0
    Connection=Keep-Alive
    From=YYY
    Keep-Alive=timeout=15, max=100
    <?xml version="1.0" encoding="UTF-8"?>
    <Books>
    <Book>
    <BookTitle>Ajax Hacks</BookTitle>
    <Author>Bruce W. Perry</Author>
    <PubDate>March 2006</PubDate>
    </Book>
    </Books>
    I am able to see the xml sent as response from web application in Payload as follows.
    <?xml version="1.0" encoding="UTF-8"?>
    <Books>
    <Book>
    <BookTitle>Ajax Hacks</BookTitle>
    <Author>Bruce W. Perry</Author>
    <PubDate>March 2006</PubDate>
    </Book>
    </Books>
    I am able to see the HTTP response in b2b_dc_transport.log. In transport log it is not showing any error. Please help me to fix this issue.

    Hi,
    Request and Response should be part of same agreement. I hope you are not confused between Acknowledgement and Response. Acknowledgement can be received in the same session (sync mode) but Response will always come in a different session and will be treated as a different document. If, for request, party A is initiator and B is responder then for response party B will be initiator and party A will be responder (as Requset and Response are two docs in case of Custom Document)
    For configuring X-Path, please refer section 8.3.11 Configuring the XPath Expression for a Custom XML Document at below link -
    http://download.oracle.com/docs/cd/B14099_19/integrate.1012/b19370/busact_coll.htm#sthref784
    Please let us know whether you are trying to receive a response or Ack?
    Regards,
    Anuj

Maybe you are looking for

  • Blue Screen of Death on a Mac, never thought I'd see it.

    This my first Mac product ever. I was hoping to have both Mac and Windows on one machine for convenience, and attempt to use Boot Camp. Everything went smoothly: the partition and installation of Windows (Vista Ultimate 32bit). Then I installed the d

  • Set timeout for dynamic web service call in wls

    Hi, I have a dynamic client using Call interface to invoke 3rd party web service. How can I set the timeout for the call? I know there is a property to set for static client. Thanks

  • Tool bar across top of PSE8 organizer page is missing.

    The tool bar is missing. There is this tiny little box and when i put the mouse over it it will display all the menues eg, File Edit Find. Does anyone now how to make it come back as normal across the top. I am running Windows7 and the latest IE.

  • Macbook Pro "13 2.7Ghz 2011, VERY slow after Sleep

    So, this is the case. I recently changed from windows to Mac, and by first look, I was very impressed, BUT!! Ever since I bought the Macbook Pro I have had a little enoyig problem. Whenever I close the lid or it goes to sleep automatically (cause of

  • Switching from pc to a MAC!! What should I know about iTunes switching??

    Well I am finally getting a Macbook Pro. What I need to know is: I have an iPhone and use my pc for syncing. I am getting rid of my pc and getting a macbook. The macbook will be my main iTunes server. Should I save any iTunes files from my pc before