I need to run multiple external programs concurrently using RMI objects.

have a web based solutiion which uses a backend machine for some processing. I have a RMI based Java proram running on the backend machine and the web server talks with this backend machine through RMI. Now, on this backend machine, I need to call some external program using Process s = Runtime.getRuntime().exec(....). Since this is a web application, multiple clients will connect at the same time and I need to run this external program for multiple clients at the same time.
Here is what I do. I have a separate RMI object bound to registry for each client that connects to the web server. This RMI object implements runnable interface, since I can't extend this class from Thread (it already extends from UnicastRemoteObject). So each time I call upon a method from this object, only one process gets started and other objects need to wait till this process finishes.
I need to start multiple processes at the sametime so that other clients don't have to wait for this thread to finish.
Please let me know if anybody has any other solution than installing an application server on this backend machine.
Here is my code.
public class iLinkOnlineSession extends UnicastRemoteObject implements Session, Serializable, Runnable
  public iLinkOnlineSession(String sessName, String sessId, String rootLogs, String rootWrks) throws RemoteException
    setSessionId(sessId);
    setName(sessName);
    ROOT_LOGS = rootLogs;
    ROOT_WORKSPACE = rootWrks;
    searchKeys_ = new Vector();
    searchObjects_ = new Hashtable();
    Thread s = new Thread(this);
    s.start();
  public void run()
    System.out.println("running");
  public String checkLogin(String user, String passwd)
    String msg = "";
    String cmd = "iLinkOnlineLogin";
    cmd += " param "+ user + " param " + passwd;
    System.out.println("cmd: " + cmd);
    try
      Runtime run = Runtime.getRuntime();
      Process proc = run.exec(cmd);           // Call to the external program.
      InputStream in = proc.getInputStream();
      Reader inp = new InputStreamReader(in);
      BufferedReader rd = new BufferedReader(inp);
      String line = rd.readLine();
      while(line != null)
        System.out.println(line);
        msg += line;
        line = rd.readLine();       
      int res = proc.waitFor();
    }catch(Exception e)
         e.printStackTrace();
    System.out.println("Msg: " + msg);
    return msg;
  public String searchObject(String user, String passwd, String param1, String paramVal1, String param2, String paramVal2, String param3, String paramVal3, String relLev, String mfgLoc)
    String cmd = "iLinkOnlineSearch";
    cmd += " param " + user + " param " + passwd + " param " + getSessionId() + " param " + logFile_ + " param " + param1 + " param " + paramVal1 +
          " param " + param2 + " param " + paramVal2 + " param " + param3 + " param " + paramVal3 + " param "
          + relLev + " param " + mfgLoc;
    System.out.println("cmd: " + cmd);
    try
      Runtime run = Runtime.getRuntime();
      Process proc = run.exec(cmd);                // External program.
      InputStream in = proc.getInputStream();
      Reader inp = new InputStreamReader(in);
      BufferedReader rd = new BufferedReader(inp);
      FileWriter out = new FileWriter(resultFile_);
      System.out.println("Filename: "+resultFile_);
      BufferedWriter wout = new BufferedWriter(out);
      String line = rd.readLine();
       while(line != null)
        System.out.println(line);
        wout.write(line);
        wout.newLine();
        wout.flush();
        line = rd.readLine();
      int res = proc.waitFor();
      wout.close();
      if(res == 0)
        boolean ret = createResultTable();
        if(ret == true)
          return GlobalConstants.SUCCESS_MSG;
        else
          return GlobalConstants.ERROR_MSG;
    }catch(Exception e)
            e.printStackTrace();
    System.out.println("getting results");
    return GlobalConstants.ERROR_MSG;
  }

I guess I don't get it.
RMI servers are inherently multi-threaded, so why are you running separate servers for every client?

Similar Messages

  • How to run multiple java files concurrently using command line?

    Hi,
    I have to write a script to run multiple java files and c files concurrently. Say, A and C are java files and B is another binary executable file, I have to make sure they are run in the order A-B-C, then I was trying to run by using
    java A & ./B & java C
    But it turned out that B could run before A started... Is there any way that I can ensure that A runs before B, and B runs before C by using the command line?
    Thanks a lot.

    GKY wrote:
    Sorry, I didn't make my question clear enough...
    A has to give some output files that B needs to get started,Then B can start at any time--even before A--and just wait for those files to be written. For instance, A could write to a temp file, then rename it to the real name. However, if there are multiple files, and they all have to exist, even this won't necessarily work. There are other approaches that will though.
    although writing the output takes very short time,Depends on when the OS decides to give A CPU time, what else is going on on that disk controller and/or network, etc.
    B could still run before A finishes the writing, As it can if you sleep for 1, or 10, or 1,000,000 seconds before starting B.
    if B can't find the info it wants, it fails to move on. That's why I need to make sure A starts before B.No, you need to make sure A's data is there before B tries to use that data.
    Edited by: jverd on Jul 29, 2008 1:06 PM

  • I have a program that runs in Java Console. I need to run multiple copies of the program. I can't do this with tabs. Can I do it with separate windows/processes

    The program in question was implemented as a Java applet that runs in a browser. The developer says it must run under the Java Console and that I cannot run more than one copy of it in a given browser technology (e.g., Firefox); but I can run multiple copies if I use, eg, Firefox for one, IE 32 bit for another, Chrome for a 3rd and IE 64 bit for a 4th. I have tested this, and this does work.
    Why would it not be the case if I spawned a completely different Firefox instance/process? When asked this question, the developer said, no, you have to run a different browser implementation to get a distinct Java Console for each one.
    Does this make sense in general, or, more importantly, is it true for Firefox?
    Thanks,
    Dennis

    It is working for me if I open a second Firefox instance with its own profile by starting Firefox with the -no-remote command line switch.
    * http://kb.mozillazine.org/Creating_a_new_Firefox_profile_on_Windows
    * http://kb.mozillazine.org/Shortcut_to_a_specific_profile
    * http://kb.mozillazine.org/Using_multiple_profiles_-_Firefox
    * http://kb.mozillazine.org/Bypassing_the_Profile_Manager
    Use the -no-remote command line switch to open another Firefox instance with its own profile and to run different Firefox instances simultaneously.
    * http://kb.mozillazine.org/Opening_a_new_instance_of_Firefox_with_another_profile

  • Running an External Program from Batch on Windows Server 2008R2 Failing

    Hi,
    I am trying to run an external program from a batch job and it is failing with this error message:
    Ext. prog.: ERROR: Input redirection is not supported, exiting the process immediately.
    Ext. prog.: External program terminated with exit code 1
    The program I am trying to run is:  timeout
    This command works on the OS: timeout -t 30
    I have setup the step to look like this:
    Under External Program:
    -Name: timeout
    -Parameter: -t 30
    I have also tried:
    -Name: timeout -t -30
    -Parameter:
    I am running ECC 6.04 on top of Windows Server 2008R2 with SQL Server 2008R2. 
    When we were running in Server 2003 on ECC 6.0 I was able to use the Sleep program just fine in the same manner.  I have found out that sleep is not available in server 2008.  It was replaced with timeout.
    After an update to EHP4 and moving to Windows Server 2008R2, Is there any pre-work that needs to be done on the SAP or Windows side before we can run external programs?
    Thank you,
    Neil

    > SAPService<SID> and <SID>ADM both have Administrator rights for the server.
    > That means they should have full access.
    No - this is no more true like that since Windows 2008, it's a bit more complex:
    http://en.wikipedia.org/wiki/User_Account_Control
    > Where would you setup the permission/policy to "interact with the desktop"?
    Add the policy using group policy editor (gpedit.msc)
    Markus

  • How can I run an external program without quitting Firefox?

    I want to run an external program from within Firefox, much as Outlook express is run from the email button. How do I set this up?
    Firefox doesn't import my Bookmarks from the listed html file. Any cure for this?

    I don't want to run the mail program, I want to run another program.
    Maxthon allows me to do this using External Tools. Does Firefox allow me to run other programs without leaving Firefox?
    2. Firefox allows me to load an html file which contains my bookmarks, but it doesn't load the bookmarks file. is there a solution?

  • How can I run an external program from a PLSQL procedure?

    Is there a package to run an external program from PLSQL? or is there another way to do that?
    thanks.

    here there is an example about how a PL/SQL procedure can
    work with an external C program.
    http://download-east.oracle.com/docs/cd/A87860_01/doc/appdev.817/a76936/dbms_pi2.htm#1003384
    Apart from that you have Java Stored Procedures option
    to carry out your task.
    Java Stored Procedures Developer's Guide Contents / Search / Index / PDF
    http://download-east.oracle.com/docs/cd/B10501_01/java.920/a96659.pdf
    Joel P�rez

  • Can we run multiple sapinst programs in parallel?

    We are planning to upgrade our EP, XI and BW simultaneously. These SIDs all reside on the same server and same OS. Is it possible to run multiple sapinst programs in parallel? I know it may require specifying separate ports for the 2nd and 3rd instance of sapinst. For example: sapinst 1 gets default ports 21212, 21213. sapinst 2 will take 21214, 21215 and sapinst 3 takes 21216 and 21217.
    Has anyone attempted this sort of a thing before? Appreciate your thoughts.

    Never done that before, maybe it works .. however it could run into problems when the sapinst are trying to access the same paths / files.
    Regards,
    Siddhesh

  • Attach doc from external content server- using Generic Object Service (GOS)

    Dear All,
    i have intergrated an external content server to SAP using SAP archive link. All the scanned document are there in Content server and corresponding entries are done in SAP.I can search and view document using tcode : OAAD
    Please tell me steps for "how to attach a document from external content server using Generic Object Service "
    Scenario is :  For example when we change any Master records or create a new PO, or do some financial transaction then i need to attach the supporting document which is there in my content server connected  to SAP.how do we manual attach a Document in SAP using GOS.
    Do we need to do some special configuration to use GOS .please give the steps from initial.
    Thanks
    sandeep

    Hello,
    Check your configuration of document type assignement to required business document - object type, Archivelink table, content repository in OAC3 transaction.
    Goto respective business document > Click on GOS > Create > Store business document - Here you can see defined document type with desctiption. Double click on this the assign your document to this business document. Save it.
    This will help in attaching the document to your required business document.
    To verify you can check the archivelink table or by transaction OAAD.
    Hope this will help you.
    -Thanks,
    Ajay

  • Do I need to run anti-viral program after trying to open a spam attachment?

    I was tricked by a spam email and clicked on a link, which did not open.  I've been advised to delete the email (done), change my password (done), and run anti-viral program (not done, and never have).  What, if anything, should I do? 

    You don't need to run antivirus software after that. Just be more careful in the future.
    (114282)

  • Help needed in running a  java program

    hi
    how to run a java program using another java program.
    i have tried a litte to run the notepad,mspaint applications sucessfully using the Runtime class,but how to specify a java program init . the program is given below
    public class cls
    public static void main(String args[])
      Runtime r=Runtime.getRuntime();
      Process p=null;
      try{
        p=r.exec("notepad" );}
        catch(Exception e) {
        System.out.println("error on execution");
    }to run another java program how to modify the exec() or any other way to do this.

    thank u
    its working without any error but it doesn't print any thing on the screen.
    the program is
    this program to be run by cls.java
                                             // hello.java
    import java.io.*;
    public class hello
    public static void main(String[] args)
        System.out.println("hello world");
      }cls.java is given below
                                                    //cls.java
    public class cls
    public static void main(String args[])
      Runtime r=Runtime.getRuntime();
      Process p=null;
      try{
        p=r.exec("java  hello" );}
        catch(Exception e) {
        System.out.println("error on execution");
    }

  • Running the external programs from SM69 t-code and RSBDCOS0 report

    Hi All,
      I am trying to execute the external commands from SM69 and RSBDCOS0. It's throwing the below error:
    26.10.2009 17:26:49 Job started                                                                                00           516
    26.10.2009 17:26:50 Step 001 started                                                                                BT           611
    26.10.2009 17:26:50 External command: ZARCHIVELOG_COPY                                                                BT           630
    26.10.2009 17:26:50 Related parameter:                                                                                BT           613
    26.10.2009 17:26:50 Ext. prog.:   > Function: BtcXpgPanicCan't exec external program (No such file or directory)      BT      606
    26.10.2009 17:26:50 Ext. prog.: External program terminated with exit code 1                                          BT           606
    26.10.2009 17:26:50 Ext. prog.: SAPXPG started on <hostname>_<SID>_00, Process ID 1632, Process Number 12   BT           606
    26.10.2009 17:26:50 External program was cancelled                                                                    BT           614
    26.10.2009 17:26:50 Job cancelled                                                                                00           518
    <SID>adm has full authorization on sapxpg.
    Please let me know what might be the wrong.
    Regards,
    Sridhar

    Dear Markus,
       The dev_xpg file contains the below information
    Trace file of external program (trace level 3)
    < Function: BtcTrcInit> Function: BtcXpgStart  External program: mv
      Process id: 29450
      Parent process id: 29449
      Rearrange StdErr to be collected in memory
      Rearrange StdOut to be collected in memory
    In t-code sm21 dont have any thing.
    Regards,
    sridhar

  • Is it possible to run a java program without using the command prompt?

    Hi,
    I was wondering whether it is possible to run a Java program (not an applet) without using a command line in the command prompt?
    Basically I want to run a program that will be continually running in the background and hence I don't want to have a command prompt screen loaded up as well - I just want the program to be running in the task bar.
    I know how to run the program in the task bar - but I still need to launch the program from the command prompt - is there anyway I can get a program running without having to start it from the command prompt?
    Cheers

    Or create a desktop shortcut (in Windows) or an application launcher ( in Linux GUI).

  • I have iMac and need a good photo editing program to use.  Reviews say aperture runs really slow with Lion, any suggestions?

    I need a program where I can remove objects and touch up dead grass, etc.

    Reviews say Aperture runs really slow with Lion, any suggestions?
    To add on to Corky02 answer:
    The recent Aperture release AP 3.3.x is very efficient, both on Lion and Mountain Lion. But you need a decent hardware to support it. The older Macs will have problems with the storage and CPU requirements. For good performance on large raw images plenty of RAM is important, at least 4GB, but 8GB would be much better, and your library should be on a fast disk, preferably on an internal drive. And don't let the system drive get too full.
    Many reports about Aperture being slow are due to putting the Aperture library onto slow disks or acessing  the original image files over the network, insufficient RAM, or corrupted or  ill-designedAperture databases.
    Aperture excels at all kinds of image processing that can be considered image developement - raw processing and color/lighting adjustments, but does not do compositing. If you are shooting raw and want professional image developement I'd recommend to do this in Aperture and not in iPhoto - you will have much more control over this in Aperture (after a steep learning curve). You can also  repair and retouch the image to correct minor blamishes. For graphics compositing and inpainting you can set up an external editor and send your images from Aperture to this external editor - any of the editors Corky recommended would be o.k. for this.
    To see, if you will want the advanced image processing in Aperture or the easy to use, more basic options in iPhoro will be sufficient to you have a look at the Aperture User manual, or the tutorial on the support page: Aperture Support
    But Aperture is a professional apllication, not "plug and play". You should only consider it, if you are willing to spend some time on learning to use it properly and are willing to work your way through the manual.
    Regards
    Léonie

  • I need to run a Windows program on MacAir!  HELP!

    I have a Macbook Air.  I host a bowling tournament every year but the software I use doens't have a MAC version.  I'm told I can download some software that lets me use a Windows program on my Mac.
    Any suggestions on what to use?
    Thanks in advance for the help!

    Windows on Intel Macs
    There are presently several alternatives for running Windows on Intel Macs.
         1. Install the Apple Boot Camp software.  Purchase Windows
             XP w/Service Pak2, Vista, or Windows 7.  For Boot Camp
             4.0 and above you can only use Windows 7 or later. Follow
             instructions in the Boot Camp documentation on
             installation of Boot Camp, creating Driver CD, and
             installing Windows.  Boot Camp enables you to boot the
             computer into OS X or Windows.
         2. Parallels Desktop for Mac and Windows XP, Vista Business,
             Vista Ultimate, or Windows 7.  Parallels is software
             virtualization that enables running Windows concurrently
             with OS X.
         3. VM Fusion and Windows XP, Vista Business, Vista Ultimate,
             or Windows 7.  VM Fusion is software virtualization that
             enables running Windows concurrently with OS X.
         4. CrossOver which enables running many Windows
             applications without having to install Windows.  The
             Windows applications can run concurrently with OS X.
         5. VirtualBox is an Open Source freeware virtual machine such
             as VM Fusion and Parallels that was developed by Solaris.
             It is not as fully developed for the Mac as Parallels and VM
             Fusion.
    Note that VirtualBox, Parallels, and VM Fusion can also run other operating systems such as Linux, Unix, OS/2, Solaris, etc.  There are performance differences between dual-boot systems and virtualization.  The latter tend to be a little slower (not much) and do not provide the video performance of the dual-boot system. See MacTech Labs- Virtualization Benchmarks, January 2013 | MacTech for comparisons of Boot Camp, Parallels, and VM Fusion. Boot Camp is only available with Leopard or Snow Leopard. Except for Crossover and a couple of similar alternatives like DarWine you must have a valid installer disc for Windows.
    You must also have an internal optical drive for installing Windows. Windows cannot be installed from an external optical drive.

  • Need to run multiple copies of portal on one machine

    This is a little involved to explain so I'll try to be clear.
    Right now we have multiple developers working on our single copy of our portal
    running on one machine at another location. No good can come of this and much
    bad has already happened.
    What we need is to be able to run different copies of our portal on different
    ports on that same machine. Making a copy of the domain, changing the port and
    java.io.tmpdir just confuses the first server started when the second one goes
    RUNNING. Changing the Web Application name doesn't help either.
    It looks like it's only our stuff that gets cornfused when I set up multiple servers
    (user_projects/someDomain, user_projects/someDomain2) or multiple Web Apps (someDomain/beaApps/portalApp/webApp1,
    someDomain/beaApps/portalApp/webApp2) since I can log into the console just fine.
    The Big Idea is that we need each developer to have their own sandbox to play
    in along with a demo/test copy of our software.
    I've dug through the BEA docs and these news groups and have not found anything
    that directly pertains to our situation. The BEA docs are particularly thin on
    information pertaining to dealing with more than one developer or deploying to
    remote machines.
    Here are some of the particulars and constraints of our setup.
    We are running WebLogic Platform 7.0.0.0 on a Solaris box at another physical
    location. All access is via network. We have no root access for a variety of
    reasons.
    Oracle is used for our JDBC. No Pointbase.
    Our WebApp has a servlet as the starting point.
    We deploy an exploded version of our servlet and JSPs for convenience.
    We edit and compile our java source on Windows boxes and FTP the .class and .jsp
    files up to their proper places on the server.
    Naturally, the ideal solution would be to have more than one machine for a server.
    Right now we don't have that option.
    Thanks for any help that you can give,
    Jon Davis

    Travis,
    We tried something very similar to that. We're using WebLogic Platform 7.0.
    We only have one login on this Solaris box.
    I copied our domain (${HOME}/bea/user_projects/somePortal) to another directory
    (${HOME}/bea/user_projects/somePortal-devel) and changed the relevant XML files
    with regards to ports and installation directories.
    Maybe the UID that each server runs as is the difference........
    Maybe an earlier version of the products are more tolerant of this and what we're
    experiencing is a "feature".
    At least I know that my initial approach wasn't such a bad idea :)
    Thanks,
    Jon
    "travis wissink" <[email protected]> wrote:
    >
    Jon,
    We do this with very little issues. I’ll take a stab at putting this
    into words.
    I suggest that you have the developers run their own instance from their
    own Solaris
    user home directory. So in /home/travis make a directory bea/app (/home/travis/bea/app)
    in the bea/app directory copy the applications, bin, StartPortal.sh,
    StopPortal.sh,
    and config directory from your current application, probably /opt/bea/wlportal4.0/.
    Then make sure that your scripts (in the developers home directory)
    all reference
    jar files in the /opt/bea/{wlportal4.0 and wlserver6.1} directory's.
    Next go
    through the /home/travis/bea/app/config/portalDomain/{config.xml & *.sh},
    /home/travis/bea/app/bin/unix/*.sh,
    and /home/travis/bea/app/application/portalDomain/{applicationDir}/WEB-INF/web.xml
    and start and stop scripts to change all “application” directory references
    to
    relative pathing from the /home/travis/app/bea directory also change
    all references
    of the 7501 and 7502 ports to another port for each developer.
    Hope this is readable and helps
    -travis
    "Jon Davis" <[email protected]> wrote:
    This is a little involved to explain so I'll try to be clear.
    Right now we have multiple developers working on our single copy ofour
    portal
    running on one machine at another location. No good can come of this
    and much
    bad has already happened.
    What we need is to be able to run different copies of our portal ondifferent
    ports on that same machine. Making a copy of the domain, changing the
    port and
    java.io.tmpdir just confuses the first server started when the second
    one goes
    RUNNING. Changing the Web Application name doesn't help either.
    It looks like it's only our stuff that gets cornfused when I set upmultiple
    servers
    (user_projects/someDomain, user_projects/someDomain2) or multiple Web
    Apps (someDomain/beaApps/portalApp/webApp1,
    someDomain/beaApps/portalApp/webApp2) since I can log into the console
    just fine.
    The Big Idea is that we need each developer to have their own sandbox
    to play
    in along with a demo/test copy of our software.
    I've dug through the BEA docs and these news groups and have not found
    anything
    that directly pertains to our situation. The BEA docs are particularly
    thin on
    information pertaining to dealing with more than one developer or deploying
    to
    remote machines.
    Here are some of the particulars and constraints of our setup.
    We are running WebLogic Platform 7.0.0.0 on a Solaris box at another
    physical
    location. All access is via network. We have no root access for avariety
    of
    reasons.
    Oracle is used for our JDBC. No Pointbase.
    Our WebApp has a servlet as the starting point.
    We deploy an exploded version of our servlet and JSPs for convenience.
    We edit and compile our java source on Windows boxes and FTP the .class
    and .jsp
    files up to their proper places on the server.
    Naturally, the ideal solution would be to have more than one machine
    for a server.
    Right now we don't have that option.
    Thanks for any help that you can give,
    Jon Davis

Maybe you are looking for

  • InDesign Crashed and Now Can't Open the File It Crashed On

    I had a file open from a G4 server. I left and came back and my computer had gone to sleep losing the connection to the server. InDesign crashed with that file open and now I can't open the file at all I keep getting this error message: Cannot open t

  • Html web Gallery: Cell Number Size

    I need to determine how to alter the size of the Cell Numbers in the :standard" Lightroom Web Gallery layout. The numbering is  too large to be clearly seen in the upper left hand corner of the cell i;e the thumbnails cover a portion of the numerals.

  • Nokia N97 Phone Aplications

    What's with the lack of N97 official phone applications? One of the most widely used phone applications are Skype, Gmail and Nokia Sports Tracker and since the launch of the phone there are no offical releases of none of them? What is taking so long?

  • LED light on 3220

    last night one of the green led lights in my grips switched on and wont go off unless i remove the battery. i have switched the light sequences off and they dont flash. this is just on continuously and running down my battery! any ideas? Thanks

  • Action Controls at the AppModuleDataControl level

    hi, I have a problem where in I need to make a fragment of the page and display action buttons like Create, Delete etc. In my present case i need to make the action buttons in such a way that i need to on click of new any screen in another facet shou