Runtime#exec() from within a J2EE application

I've got a batch processing task running on a timer as part of my J2EE application on WebLogic 8.1 and I'm experiencing problems with invoking Runtime#exec().
To be more accurate, this is what I'm trying to do:
* Moves a file in the filesystem using native shell commands.
* @param src The file to move.
* @param dst The destination file.
public void move(String src, String dst) {
    Runtime runtime = Runtime.getRuntime();
    Process p = runtime.exec(new String[] { "mv", "-f", src, dst });
}Now, this piece of code works perfectly when run manually ("java Move foo.txt bar.txt") but when it's run within the J2EE application -- as the same user as in the manual case -- the file's won't get moved anywhere.
I suppose it's a permission/policy issue. If that's the case, how should I edit the policy file?
I already tried to add the following lines to weblogic.policy:
grant codeBase "file:${user.domain}/myServer/.internal/-" {
  permission java.security.AllPermission;
grant codeBase "file:${user.domain}/myServer/.wlnotdelete/-" {
  permission java.security.AllPermission;
};...but that didn't seem to help at all.

Ok. I managed to solve this one by myself. The solution was to read the "stdout" and "stderr" streams from the process.
Any idea why reading the streams helped?

Similar Messages

  • Web Dynpro API directly from within a J2EE application

    hello,
    Can we call webdynpro API directly from a J2EE application.
    If it is possible, what all will be required at compile time and runtime.
    Please advice, If an additional configuration is also required.
    Thanks in advance
    Mona

    Hi,
    Check the below link u will get an idea...
    Configuration about J2EE engine
    http://help.sap.com/saphelp_nw70/helpdata/en/a6/6980424dd7d665e10000000a155106/frameset.htm
    http://help.sap.com/saphelp_nw70/helpdata/en/4a/b62640632cec01e10000000a155106/frameset.htm
    Sample applications,
    http://help.sap.com/saphelp_nw70/helpdata/en/f6/4345e8238fcd418197d6692e59d673/frameset.htm
    http://help.sap.com/saphelp_nw70/helpdata/en/f6/baba3eb645dc61e10000000a114084/frameset.htm

  • Start a BO report from within a web-application.

    Hi,
    An enuser want to start a BO report from within a web-application.
    The BO report ideally should not prompt for a login. The fact that we are using BO for reporting purposes should be transparent to the end users. The report should produce its output directly in Excel (pdf?) format. In WebI i can do a 'Save As' to obtain this, but it should go automatically so that the end users get their response directly in Excel
    the report should be parametrized. These parameters will be added to the URL by the calling application.
    To do a basic test of the Opendocument.jsp i created a number of test reports in WEBI, and i use the following URLs to execute them directly
    http://s-olaf-vtst150:8080/OpenDocument/opendoc/openDocument.jsp?&sPath=[My reports]&sDocName=tmsd1&sType=rep&sRefresh=Y
    http://s-olaf-vtst150:8080/OpenDocument/opendoc/openDocument.jsp?&sPath=[My reports]&sDocName=Yearselection&sType=rep&sRefresh=Y&lsSYear:=2002
    So this covers points 1 & 4
    What are the options for points 2 & 3?
    Kind regards,
    Johan

    The BO XI 3.1 environment works quite well now.
    Two more questions:
    1. When a user being member of the Readers group, still sees the Edit button in Webapplication - Infoview. Is it possible to hide or disable that Edit button ?
    2. Is it possible to make a user only seeing a part of the data in the universe ? When a query is run with a parameter, the user ses the parameter in the left column ... but in that way a normal user can change the value of that parameter giving him the possibility to see things he should not see. Making a separate query per user is overkill and too much work to do. Is BO XI 3.1 able to offer this possibility and how ?
    Rgds,
    Johan

  • Java:comp/env namespace is only available from within a J2EE component

    Can someone help me to explain and resolve the Exception?
    The Exception is like below:
    javax.naming.NamingException: java:comp/env namespace is only available from within a J2EE component

    Hi temp,
    I can only guess here -- since you haven't provided much information,
    but if you are trying to lookup an EJB from some client class, then
    the client class must also be deployed to OC4J in order to use the
    "java:comp/env" namespace.
    I think if you did a search of this forum's archives for the text
    "java:comp/env", it would probably explain lots of things to you.
    Good Luck,
    Avi.

  • Calling external programs from within a Tomcat application

    I've got a fairly complex existing Tomcat application (which is packaged and built as a .war file) which I'm trying to edit so that it calls a Perl script part way through the processing, which will generate an XML file used later on. I think I've worked out how to call external scripts from within Java, but at the moment when I try and access the application via Tomcat the application either hangs or bails out (I don't know which, as the log files unhelpfully don't give any error messages).
    The code which is causing the problem looks like this:
    System.err.println("Calling runtime...");
    Runtime runtime = Runtime.getRuntime();
    System.err.println("Executing process...");
    Process process = runtime.exec("/path/to/ysearch.pl 'News' '\"search query\"' 'file");
    System.err.println("Waiting for process...");
    int exitVal = process.waitFor();
    System.out.println("Exited with error code: " + exitVal);The code gets as far as "Executing process..", beyond that there is nothing in the log file so I presume the runtime.exec() call is where the problem is. I'm not interested in reading the output from the script (there shouldn't be any), so that's not an issue, and the permissions on it allow anyone to read or execute ysearch.pl so I don't think there's a problem in that area.
    Does anyone have any suggestions which I could try to get this to work? I've only been using Tomcat for a week (I'm picking up on someone else's code) so I might have made a beginner's mistake. I'm using Tomcat 5 on Fedora Core 7, and Java 1.5.0_01 (I can't easily change any of those).

    I'm not sure, but I thing that overhead caused by calling du cannot be big enough to matter even on older machines.
    But, when calling du from Perl script you are also invoking shell, and this can be a little bit more 'heavy'.

  • How can I execute an IE browser window from within my java application?

    I am programming a java application that requires me to execute a browser application and point to a specific web site. How can I do this? I cannot seem to find any examples on the web.

    Hi Heals,
    This forum is for discussing Measurement Studio for Visual Basic and is not really a good place to ask general purpose Java questions. I suggest searching one of the comp.lang.java.* newsgroups at http://groups.google.com/.
    Off the top of my head, though, I would say take a look at the Runtime.exec method.
    - Elton

  • Is it possible to refresh the client from serverside in j2ee application

    Hello
    Is it possible to refreshh the client from server side in j2ee Application server using JMS technology,
    If you know about it plz. mail me on [email protected] Or plz. reply me over here.
    Thank you

    You can either use server push or client pull.
    Server push:
    Server push the changes to client on every certain time interval.
    You can make client to subscribe for JMS topic created on server side. Every certain interval, server needs to publish a message and JMS will distribute all the message to the subscribers (clients)
    Client pull:
    Each client request/inquiry the changes from server on every certain time interval.
    You can't use JMS (you can but you must use P2P (queue), which is not recommended in this case).
    You can make the client to post HTTP request to get the latest data from server on every certain time interval.
    Alex

  • Calling a webservice from within Bex Web Application Designer

    Hi
    I have a web-template built with BEx web application designer which also contains textboxes. This text should be stored by calling a webservice (standard BI-documents are not an option).
    Can anyone tell me how I could call a webservice from within the BEx web template to store the text contained in the textbox? The webservice-call should include some of the filter-varialbes of the web application.
    Is this only possible by the use of a JavaScript WebItem? If so - does anyone have an example of such a JavaScript.
    Thanks a lot in advance.
    Kind regards.
    Christoph

    Thanks for your response. The BSP page would work out fine if I only needed to save the data.
    But the next time I call the webtemplate, the textarea should be filled by another webservice call with the stored text (so the text can be modified und saved again). This will not be possible by calling a BSP page.
    Do yoiu have any suggestions how to integrate the text (return value from the webservice call) into the textbox in the webtemplate?
    Kind regards.
    Christoph

  • Invoking "java myClass" using Runtime.Exec from a Java Stored Procedure

    Hi All,
    This is regarding the use of Runtime.getRunTime().exec, from a java programme (a Java Stored Procedure), to invoke another Java Class in command prompt.
    I have read many threads here where people have been successuful in invoking OS calls, like any .exe file or batch file etc, from withing Java using the Runtime object.
    Even i have tried a sample java programme from where i can invoke notepad.exe.
    But i want to invoke another command prompt and run a java class, basically in this format:
    {"cmd.exe","java myClass"}.
    When i run my java programme (in command prompt), it doesnt invoke another command prompt...it just stays hanging.
    When i run the java programme from my IDE, VisualCafe, it does open up a command prompt, but doesnt get the second command "java myCLass".
    Infact on the title of the command prompt (the blue frame), shows the path of the java.exe of the Visual Cafe.
    and anyway, it doesnt run my java class, that i have specified inside the programme.
    Even if i try to run a JAR file, it still doesnt do anything.
    (the JAR file other wise runs fine when i manually invoke it from the command prompt).
    Well, my question is, actually i want to do this from a Java Stored Procedure inside oracle 8.1.7.
    My feeling is, since the Java Stored Procedure wont be running from the command prompt (i will be actually invoking it through a Oracle trigger), it may be able to invoke the command prompt and run the java class i want. and that java class has to run with the SUn's Java, not Oracle JAva.
    Does any one have any idea about it?
    Has anyone ever invoked a java class or JAR file in command prompt from another Java Programme?
    YOur help will be highly appreciated.
    (P:S- Right now, my database is being upgraded, so i havent actually been able to create a Java Stored procedure and test it. But i have tested from a normal java programme running in command prompt and also from Visual Cafe).
    Thanks in advance.
    -- Subhasree.

    Hello Hari,
    Thanks for your quick reply.
    Can you please elaborate a little more on exactly how you did? may be just copy an dpaste taht part of teh code here?
    Thanks a lot in advance.
    --Subhasree                                                                                                                                                                                                                                                                                                                                                                                                           

  • Is it possible to call msync from within an EVB Application?

    Does anyone know how to run mSync from within an embedded visual basic application?
    Some sample code or documentation would be particularly welcome.

    The following is taken from the Windows CE documentation that ships with 9i Lite:
    Table 3-16 ISyncOption Public Properties
    username -> Name of the user.
    password -> User password.
    syncParam -> Synchronization preferences. See Section 3.7.2.4, "COM Interface SyncParam Settings" for more information.
    transportType -> Type of transport to use. Only "HTTP" type is supported currently. The default value is HTTP.
    transportParam Parameters of the transport. See Section 3.7.1.5, "Java Interface TransportParam Parameters" for more information.
    syncParam documentation is (also taken from the same document):
    The syncParam is a string that allows support parameters to be specified to the synchronization session. The string is constructed of name-and-value pairs, for example:
    "name=value;name2=value2;name3=value3, ...;"
    The names are not case sensitive, but the values are. The field names which can be used are listed in Table 3-17.
    Table 3-17 COM Interface SyncParam Settings
    "reset" -> N/A Clear all entries in the environment before applying any remaining settings.
    "security" -> "SSL" "CAST5" Use the appropriate selection to choose either SSL or CAST5 stream encryption.
    "pushonly" -> N/A Use this setting to upload changes from the client to the server only, download is not allowed.This is useful when data transfer is one way, client to server.
    "noapps" -> N/A Do not download any new or updated applications. This is useful when synchronizing over a slow connection or on a slow network.
    "syncDirection" -> "SendOnly" "ReceiveOnly" "SendOnly" is the same as "pushonly". "RecieveOnly" allows no changes to be posted to the server.
    "noNewPubs" -> N/A This setting prevents any new publications created since the last synchronization from being sent, and only synchronizes data from the current publications.
    "tableFlag [Publication.Item]" "enable" "disable" The "enable" setting allows [Publication.Item] to be synchronized, disable prevents synchronization.
    "fullrefresh" -> N/A Forces a complete refresh.
    "clientDBMode" -> "EMBEDDED" "CLIENT" If set to "EMBEDDED", access to the database is by conventional ODBC, if set to "CLIENT" access is by multi-client ODBC.
    Example 1
    The first example enables SSL security and disables application deployment for the current synchronization session:
    "security=SSL;noapps;"

  • Saving/Opening documents to SharePoint 2013 from within Office 2010 applications

    I was hoping that Office 2010 would work nicely together in terms of saving to and opening documents from SharePoint 2013. Alas, I was disappointed and somewhat surprised to see that opening/saving documents in SharePoint from within Office still
    involves copying, pasting and hacking the URL of the document library in the Save or Open dialogue box. I was fully expecting that Office 2010 would have display some sort of SharePoint navigation so you could view your sites and document libraries in a similar
    way to folders. A mature document management system this ain't!
    Anyone have any advice on how to improve the Open/Save to/from SharePoint experience in Office 2010? I'm open to the idea of Office add-ins whether third party or official Microsoft.
    Thanks in advance

    Thanks for the reply, but that's from within SharePoint, not Office?
    An example scenario: I create a new document or receive a document, I'm in the document, and I want to publish the document to a document library in SharePoint. At the moment I would have to save the document, load up SharePoint, navigate to the document
    library and then go through the upload process.
    I should really be able to, from within Word, select File - Save to SharePoint (say) and then be able to navigate to the document library I want to publish to. Really basic DMS stuff that I'm surprised isn't there!
    Similar thing to opening a document. I should be able to Open from SharePoint, navigate to the document library via some sort of navigation box, and open it.
    Thoughts appreciated.

  • Running Runtime.Exec from servlet

    Hi all,
    I am currently running a servlet which executes a long shell script. I am doing this in the post request. When i hit submit button in servlet it executes the shell script . My problem is the servlet waits until the program is completed . What am i doing wrong. How can i avoid this.
    Thanks in advance

    Have you considered moving this action to a separate POJO or bean that runs in a separate thread? This handoff should allow your servlet to continue on it's merry way while the shell script executes.
    I've never tested this myself as I avoid Runtime.exec like the plaue.

  • How can native executable files be started from within a Java application.

    Hi Everyone,
    I am currently working on an application that will have the ability to start a program within Windows. What I intend on having is a button within my GUI that can start Microsoft Word. I am completely lost as to where I should begin in order to make this work. If anybody has any pointers they will be greatly appreciated. Thanks.
    Regards
    D

    Hi ,
    easy:
    Runtime.getRuntime().exec(new String[]{path,name});
    see:
    http://java.sun.com/j2se/1.3/docs/api/java/lang/Runtime.html
    HTH

  • Runtime.exec fails to launch C++ application

    A java application launches a C++ Windows based application, providing it with arguments on the command line. This application is supposed to start, to execute something and to exit.
    This is working as long as the java code runs from the command prompt.
    When the java code is running as part of a Java Windows 2000 service, the C++ application starts but enters a loop and never returns. It consumes all CPU and waits for something that I could not figure out. I can just see the process in the Task Manager.
    Windows 2000 service is configured as loging on a user account.
    I have not the code of the C++ application and cannot modify it.
    Here is the piece of code that starts this C++ Application :
    //Start the command and wait for completion
    try{
    java.lang.Process submitProcess = Runtime.getRuntime().exec(command);
    submitProcess.waitFor();
    if(submitProcess.exitValue() == 0){
    return;
    } else{
    System.out.println("exitValue = " + submitProcess.exitValue());
    } catch(Exception e){e.printStackTrace();

    For information, wrapping input and error streams did not return any information.
    Doing further testing, I found that this application - a viewer that I use for its command line print functionality- starts looping when I pass as argument a DWG file. If I ask it to print .DOC or .XLS or .HTML ... files, it works.
    If I start the application from Java code at command prompt, it works even with this DWG file and it does not ask for anything.
    My conclusion is that the loop comes from a component used for Autocad conversion when the Java code launching the application is started as Windows 2000 service.

  • Accessing KM content from within a web application

    We are trying to migrate an application from a BEA webServer onto the webAS. The application relies heavily on the BEA content management system (CMS), this is to be replaced by the KM. We cannot rebuild the application using iViews etc as we have to retain the current look and feel, and hence we will have to call the KM content from the jsp code within the application. Does anyone know if this is possible and can give us an idea of what API's we call...(if the API’s exist and if this is the correct approach).
    Many thanks

    ]> call the KM content from the jsp code
    ]That sounds not very well designed...
    BEA have a content tag library for extracting content from the CMS within a JSP page.  I think this is what James may be referring to.
    Does the KM have equivalent taglibs?  If so, can these be configured to access the KM running on a different J2EE instance (specifically one running on another machine).
    Going to browse the API docs anyway, but if you have a short answer to this, please post.
    Gary

Maybe you are looking for