Exception "Cannot run program" while using ProcessBuilder class

Hi Java-Folks,
I try to start a program within a Java application using the ProcessBuilder class. This is the first time I use ProcessBuilder so I do not have any deep knowledge of it. Here is a snippet of my code:
static void connectToHost(String Host) {
ProcessBuilder pb = new ProcessBuilder("connect.exe"), Host);
Map<String, String> env = pb.environment();
env.put("SHELLWIDTH", "64");
pb.directory(new File("C:\\MyProgram\\ExApp\\shell"));
try (
Process p = pb.start();
} catch (IOException ex) {
Logger.getLogger(ShellUtil.class.getName()).log(Level.SEVERE, null, ex);
}Using this method I get an IOException which says *"Cannot run program "connect.exe" (in directory "C:\MyProgram\ExApp\shell"): CreateProcess error=2, The system couldn't find the specified file"*
Does anybody have an idea why this is not working? I tried to start another application like "notepad.exe" and that works fine. So it seems related to the fact
that the program I want to start is only available in a certain directory and not via the PATH env-variable.
I would appreciate any help or hint :-)
Regards,
Lemmy

Okay I guess I misinterpreted the JavaDocs regarding the directory method. The exception message is a little bit confusing too, because it seems like Java tries to find the Application within the specified
working directory.
I tried to use the full path with the ProcessBuilder constructor and it looks like this variant is working. I still have some trouble with the application itself but I was able to start another program which is
not in the PATH var, using the full path to the executable.
Thanks for the help so far.
Bye
Lemmy

Similar Messages

  • ProcessBuilder: Cannot run program

    Hello,
    In my code I need to run a windows application. Through the Command Prompt I would type:
    C:\>"C:\Documents and Settings\Simpatico\My Documents\Woerter Speichern Files\changeBackgroud" "C:\\Documents and Settings\\Simpatico\\My Documents\\Woerter Speichern Files\\testimage.bmp"In Java I wrote:
    ProcessBuilder pb = new ProcessBuilder("C:\\Documents and Settings\\Simpatico\\My Documents\\Woerter Speichern Files\\changeBackground", C:\\Documents and Settings\\Simpatico\\My Documents\\Woerter Speichern Files\\testimage.bmp);
              pb.directory(new File("C:\\Documents and Settings\\Simpatico\\My Documents\\Woerter Speichern Files"));
              try {
                   pb.start();
              } catch (IOException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();And I get:
    java.io.IOException: Cannot run program "C:\Documents and Settings\Simpatico\My Documents\Woerter Speichern Files\changeBackground": CreateProcess error=2, The system cannot find the file specified
         at java.lang.ProcessBuilder.start(Unknown Source)The problem is with executing the application, changeBackground in the first place, and not the parameter passing.

    simpatico_gabriele wrote:
    1. They are not. Please qualify ur claim.All right, I will. Your code is like this:
    ProcessBuilder pb = new ProcessBuilder("C:\\Documents and Setting...{code}
    The string you pass as a parameter there starts with the letter C, not with a quote. You still don't believe it? Try this:
    {code}System.out.println("C:\\Documents and Setting");{code}
    Notice how what's printed out doesn't start with a quote?
    It's really annoying how you ask for help and then flatly reject it when it's given. This is the last help I will be giving you.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • OWB - Workflow- Cannot run program "/usr/bin/perl": CreateProcess error=2,

    Hi All,
    I am using OWB 11gR2 and I am getting "perl" location error after start workflow for any dimension or fact.
    *Cannot run program "/usr/bin/perl": CreateProcess error=2, The system cannot find the file specified
    The log is below. I am using Windows 2008 R2 OS and 11gR2 DB. The perl path is set in the environment variables and I can run the perl.exe from command line.
    Why OWB is looking for the Unix base path "/usr/bin/perl": is a question for me.
    If anybody knows the issue please guide me.
    Thanks
    OUBIWF_D_DEVICE_ACTIVITY_TYPE                                        2012-07-04 16:57:37.0     4
    Parameters                                             
    OUBIWF_D_DEVICE_ACTIVITY_TYPE:FILEMGR_PRE                              1          2012-07-04 16:57:38.0     2
    Parameters                                             
    RPE-02229: The following debug information was collected:                                             
    RPE-02230: Debug Information: os.name = Windows Server 2008 R2                                             
    RPE-02230: Debug Information: os.version = 6.1                                             
    RPE-02230: Debug Information: os.arch = amd64                                             
    RPE-02230: Debug Information: user.name = INT-A-MDM-01$                                             
    RPE-02230: Debug Information: user.dir = C:\product\11.2.0\dbhome_3\owb\bin\win32                                             
    RPE-02230: Debug Information: argv.arg0 = /usr/bin/perl                                             
    RPE-02230: Debug Information: argv.arg1 = /spl/intbase/DB/tools/filemgr/splfilemgr.plx                                             
    RPE-02230: Debug Information: argv.arg2 = -l                                             
    RPE-02230: Debug Information: argv.arg3 = /spl/BIDevelopment/bi2400db                                             
    RPE-02230: Debug Information: argv.arg4 = -n                                             
    RPE-02230: Debug Information: argv.arg5 = D_DEVICE_ACTIVITY_TYPE_EXT.DAT                                             
    RPE-02230: Debug Information: argv.arg6 = -p                                             
    RPE-02230: Debug Information: argv.arg7 = 1                                             
    RPE-02230: Debug Information: argv.arg8 = -s                                             
    RPE-02230: Debug Information: argv.arg9 = S                                             
    RPE-02230: Debug Information: argv.stdin =                                             
    RPE-02230: Debug Information: USERPROFILE = C:\Windows\system32\config\systemprofile                                             
    RPE-02230: Debug Information: JAVAPATH = C:\product\11.2.0\dbhome_3\jdk6                                             
    RPE-02230: Debug Information: NODEID = 1                                             
    RPE-02230: Debug Information: IAS_HOME = C:\product\11.2.0\dbhome_3                                             
    RPE-02230: Debug Information: SystemDrive = C:                                             
    RPE-02230: Debug Information: RTHOME = C:\product\11.2.0\dbhome_3                                             
    RPE-02230: Debug Information: Path = C:\product\11.2.0\dbhome_3\bin;C:\product\11.2.0\dbhome_3\jdk6\jre\bin\client;C:\product\11.2.0\dbhome_3\jdk6\jre\bin;C:\product\11.2.0\dbhome_3\owb\bin\admin;C:\Windows\system32                                             
    RPE-02230: Debug Information: CONNECT_SPEC = 10.34.32.136:1521:MDM                                             
    RPE-02230: Debug Information: PROCESSOR_REVISION = 1a05                                             
    RPE-02230: Debug Information: OCM_ORACLE_HOME = C:\product\11.2.0\dbhome_3                                             
    RPE-02230: Debug Information: USERDOMAIN = WORKGROUP                                             
    RPE-02230: Debug Information: ALLUSERSPROFILE = C:\ProgramData                                             
    RPE-02230: Debug Information: TMP = C:\Windows\TEMP                                             
    RPE-02230: Debug Information: CommonProgramFiles = C:\Program Files\Common Files                                             
    RPE-02230: Debug Information: PROMPT = $P$G                                             
    RPE-02230: Debug Information: PROCESSOR_LEVEL = 6                                             
    RPE-02230: Debug Information: JVM_OPTIONS = -Xmx768M                                             
    RPE-02230: Debug Information: LOCALAPPDATA = C:\Windows\system32\config\systemprofile\AppData\Local                                             
    RPE-02230: Debug Information: COMPUTERNAME = INT-A-MDM-01                                             
    RPE-02230: Debug Information: SystemRoot = C:\Windows                                             
    RPE-02230: Debug Information: ORA_HOME = C:\product\11.2.0\dbhome_3                                             
    RPE-02230: Debug Information: USERNAME = INT-A-MDM-01$                                             
    RPE-02230: Debug Information: APPDATA = C:\Windows\system32\config\systemprofile\AppData\Roaming                                             
    RPE-02230: Debug Information: ProgramData = C:\ProgramData                                             
    RPE-02230: Debug Information: PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC                                             
    RPE-02230: Debug Information: ORACLE_HOME = C:\product\11.2.0\dbhome_3                                             
    RPE-02230: Debug Information: RTUSER = OWBSYS                                             
    RPE-02230: Debug Information: ProgramFiles(x86) = C:\Program Files (x86)                                             
    RPE-02230: Debug Information: TEMP = C:\Windows\TEMP                                             
    RPE-02230: Debug Information: OEM_HOME = C:\product\11.2.0\dbhome_3                                             
    RPE-02230: Debug Information: ProgramFiles = C:\Program Files                                             
    RPE-02230: Debug Information: JDK_HOME = C:\product\11.2.0\dbhome_3\jdk6                                             
    RPE-02230: Debug Information: OCM_HOME = C:\product\11.2.0\dbhome_3                                             
    RPE-02230: Debug Information: ProgramW6432 = C:\Program Files                                             
    RPE-02230: Debug Information: PROCESSOR_IDENTIFIER = Intel64 Family 6 Model 26 Stepping 5, GenuineIntel                                             
    RPE-02230: Debug Information: STARTUP_TYPE = -manual                                             
    RPE-02230: Debug Information: PROCESSOR_ARCHITECTURE = AMD64                                             
    RPE-02230: Debug Information: OS = Windows_NT                                             
    RPE-02230: Debug Information: FP_NO_HOST_CHECK = NO                                             
    RPE-02230: Debug Information: CommonProgramW6432 = C:\Program Files\Common Files                                             
    RPE-02230: Debug Information: ORACLE_SID = mdm                                             
    RPE-02230: Debug Information: DISCOVERER_ALLOW_DB_CONNECT_STRING = YES                                             
    RPE-02230: Debug Information: OWB_HOME = C:\product\11.2.0\dbhome_3                                             
    RPE-02230: Debug Information: NUMBER_OF_PROCESSORS = 2                                             
    RPE-02230: Debug Information: PUBLIC = C:\Users\Public                                             
    RPE-02230: Debug Information: PSModulePath = C:\Windows\system32\WindowsPowerShell\v1.0\Modules\                                             
    RPE-02230: Debug Information: CommonProgramFiles(x86) = C:\Program Files (x86)\Common Files                                             
    RPE-02230: Debug Information: ComSpec = C:\Windows\system32\cmd.exe                                             
    RPE-02235: The operating system has reported that it cannot execute the requested command. This may be because the command or the parameters are invalid, or that the command is shell command. Any result code return is specific to the operating system. Debug information has been produced.                                             
    Cannot run program "/usr/bin/perl": CreateProcess error=2, The system cannot find the file specified                                             
    OUBIWF_D_DEVICE_ACTIVITY_TYPE:EMAIL_FILEMGR                              1          2012-07-04 16:57:40.0Parameters                                             
    ORA-24247: network access denied by access control list (ACL)
    ORA-06512: at "SYS.UTL_TCP", line 17
    ORA-06512: at "SYS.UTL_TCP", line 267
    ORA-06512: at "SYS.UTL_SMTP", line 161
    ORA-06512: at "SYS.UTL_SMTP", line 197
    ORA-06512: at line 8

    Hi There
    Am experiencing the same issue. Did you manage to resolve it, is so can you advice what the resolution is. Thanks
    Regards,
    Kayode

  • Error: Cannot run program "C:\Oracle\Middleware\jdk160_21\jre\bin\javaw.exe

    Hi
    I have created a sample Fusion Web Application(ADF) and created a test.jsp in viewcontroller with few components. I have started the integrated weblogic server and started successfully, but when I run test.jsp it is giving me the below error
    Error: Cannot run program "C:\Oracle\Middleware\jdk160_21\jre\bin\javaw.exe" (in directory "C:\Documents and Settings\chowdamr\Application Data\JDeveloper\system11.1.1.4.37.59.23\o.jdeveloper\DefaultWorkspace"): CreateProcess error=267, The directory name is invalid.
    Initially this page is working successfuly.
    Please tell me whats the problem.
    Edited by: 858782 on May 13, 2011 5:28 AM

    There are some problems when JDev's system directory (e.g. the \system11.1.1.4.37.59.23 directory) is in a path that contains spaces (as it is in your case - C:\Documents and Settings\...). Move the system directory to a path without spaces and try again. The simplest way to move it is to start JDeveloper in a "single user" mode (use <tt>jdeveloper.exe -singleuser</tt>) which will create the system directory within JDev's home directory. Of course, if your JDeveloper is installed in a path containing spaces, it will not work either (for example, if JDev is in C:\Program Files\...).
    Have a look here for a more sophisticated approach for moving the system directory to another location:
    http://technology.amis.nl/blog/8387/change-the-jdeveloper-system-directory
    Dimitar

  • Cannot run program "keytool": java.io.IOException

    Hi,
    I would like to follow the procedure to change the master password
    of glassfish server hosting APEX listener
    using the change-master-password subcommand, but the utility keytool
    is not found:
    glassfish@ahost:/opt/glassfish3/glassfish/domains/mydom01/config> /opt/glassfish3/bin/asadmin
    /opt/glassfish3/bin/asadmin
    Use "exit" to exit and "help" for online help.
    asadmin> change-master-password mydom01
    Enter the current master password> changeit
    Enter the new master password> changedit
    Enter the new master password again> changedit
    Cannot run program "keytool": java.io.IOException: error=2, No such file or directory
    Command change-master-password failed.
    asadmin>
    Command multimode failed.
    glassfish@ahost:/opt/glassfish3/glassfish/domains/mydom01/config> which java
    /usr/bin/java
    glassfish@ahost:/opt/glassfish3/glassfish/domains/mydom01/config>
    All of glassfish is running fine apart from this.
    keytool could be found in /usr/java/latest/bin/keytool.
    Do we need to have this in the path? There is no requirement in the
    install guide for this, nor did the RPM installation adjust the system
    path accordingly.
    Hopefully someone can tell my how things ought to be regarding keytool?
    Thanks, Tom

    Hi Tom,
    the procedure to change the master password of glassfish server hosting APEX listener... sounds more like a GlassFish-related topic to me. I guess you'd get the best answers for such questions in a GlassFish-related forum...
    For what it's worth, I'll try my best anyway:
    Cannot run program "keytool": java.io.IOException: error=2, No such file or directoryThis seems to be a pretty clear error message: keytool , which is probably used to manage the keys for GlassFish users, wasn't found. This means, you're either running on an OS that is not officially certified for GlassFish, or you GlassFish hasn't been configured properly.
    You ran
    glassfish@ahost:/opt/glassfish3/glassfish/domains/mydom01/config> which java
    /usr/bin/java... which indicates you assume your GlassFish is running without JAVA_HOME being set. If that's true, I'd begin to setup you GlassFish properly starting with that parameter.
    Anyway, you also found out that
    keytool could be found in /usr/java/latest/bin/keytool.... which is not +/usr/bin+ and hence probably not in the global search path of the user on whose behalf your GlassFish is running. So, you could either create a link-set[*] for +/usr/bin/keytool+ to (finally) point to +/usr/java/latest/bin/keytool+, or you setup JAVA_HOME to be +/usr/java/latest+ .
    [*] Note that depending on your OS there might be more than one stage of indirection, e.g. my Ubuntu has +/usr/bin/java+ pointing to +/etc/alternatives/java+ which is pointing to +/usr/lib/jvm/java-6-sun/jre/bin/java+ where +/usr/lib/jvm/java-6-sun/+ is pointing to the directory containing the actual JDK to be used. You'll probably find something like that on your system as well. My Ubuntu box has a link for +/usr/bin/keytool+, so I get that when running "which keytool".
    Do we need to have this in the path? There is no requirement in the install guide for this, nor did the RPM installation adjust the system path accordingly.Again, this is not a GlassFish forum.
    I hope my hints help you solve your problem. If they don't, please choose the appropriate forum for your next post on that topic. And I guess, giving some more information on your OS and how you manage your JDK (and which version you use) will help people there to help you.
    Thanks,
    Udo

  • Java.io.IOException: Cannot run program "ant"

    Hi all,
    I'm running a Job in Hudson.
    I build this job from a Hudson Master Server but the job is built in a Hudson Linux Node.
    This is the result:
    Started by user builder
    Building remotely on Linux-Node
    Updating http://150.200.20.200:8000/mvtv_all/DESCOS/MVTVc_D2ph1/branches revision: 17-may-2013 16:01:46 depth:infinity ignoreExternals: false
    At revision 529
    Updating http://150.200.200.200:8000/mvtv_all/DESCOS/KaluModules/branches revision: 17-may-2013 16:01:46 depth:infinity ignoreExternals: false
    At revision 529
    no change for http://159.200.300.20:8000/mvtv_all/DESCOS/MVTVc_D2ph1/branches since the previous build
    no change for http://159.230.300.20:8000/mvtv_all/DESCOS/KaluModules/branches since the previous build
    No emails were triggered.
    [bt] $ ant -file build.xml -DSUBSYSTEM=ALL -DTARGET=makeBuild -DCRLIST= -DOWNER= -DbuildTool.patch.release=$RELEASE -DbuildTool.system=$SYSTEM -DbuildTool.patch.type=$PATCH_TYPE -DbuildTool.subsystem=ALL -DbuildTool.buildRules=pkgBuild -DbuildTool.dynamicView=$WORKSPACE/ALL -DbuildTool.compilationRules=compile -DbuildTool.patch.name=$PATCH_NAME makeBuild
    FATAL: command execution failed.Maybe you need to configure the job to choose one of your Ant installations?
    java.io.IOException: Cannot run program "ant" (in directory "/hudson/buildTool/src/bt"): error=2, No existe el fichero o el directorio
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
    at hudson.Proc$LocalProc.<init>(Proc.java:192)
    at hudson.Proc$LocalProc.<init>(Proc.java:164)
    at hudson.Launcher$LocalLauncher.launch(Launcher.java:639)
    at hudson.Launcher$ProcStarter.start(Launcher.java:274)
    at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:794)
    at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:768)
    at hudson.remoting.UserRequest.perform(UserRequest.java:114)
    at hudson.remoting.UserRequest.perform(UserRequest.java:48)
    at hudson.remoting.Request$2.run(Request.java:283)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:722)
    Caused by: java.io.IOException: error=2, No existe el fichero o el directorio
    at java.lang.UNIXProcess.forkAndExec(Native Method)
    at java.lang.UNIXProcess.<init>(UNIXProcess.java:135)
    at java.lang.ProcessImpl.start(ProcessImpl.java:130)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1021)
    ... 15 more
    Do you know something about this issue?
    Thanks and Regards

    No, and this is not the Hudson forums either. But see this error?
    FATAL: command execution failed.Maybe you need to configure the job to choose one of your Ant installations?Try posting that in Google and see what you get. That's basic misery solution research 101. Post the error in Google. 999/1000 times someone has already run into it before. Please learn from their experiences by reading through them.

  • Running programs WINDOWS using java

    Hi ,
    I would appreciate if anyone could tell me how to run programs WINDOWS using JAVA language .Thank you.

    I am not quite sure what you mean by that, but if you want to execute a program use:
    Runtime.exec(String)

  • Cannot create class in system package while Using Sprite class

    Hi i developed a game using Sprite class & imported
    javax.microedition.lcdui.game.*; package. But when i tried to build this project it gave me "Cannot create class in system package" error. Worst thing is that now again if i build, then it displays error "package javax.microedition.lcdui.game.*; does not exist" . Pls help me

    First exception means that you tried to create a class with the package name equaling one from the predefined libraries in midp/cldc.
    For your second error, add all the jars you are using into the project's classpath.
    Mihai

  • Parallel ABAP programming while using references

    Hi SCN,
    first of all the context of my problem, to get to its root:
    I have created a kind of Framework (object oriented), which later on will provide an easy way to set up Charts in a Dashboard.
    Put simply, the framework works like this:
    There is a interface for the source of the data and customizing to be shown in the chart, with the methods 'get_data' and 'get_customizing'.
    You can simply implement the specific interface in a class, which therefore is a 'source object' for the chart classes later on (getting the Chart Customizing and the Chart data using the defined methods mentioned above). The chart classes use the functionality of CL_GUI_CHART_ENGINE.
    This concept works fine so far.
    But I added a quite important feature - every chart should be refreshed after some time. Therefore I use the class CL_GUI_TIMER, which triggers the refreshing after some time. The problem is: if there are for instance two graphs shown and the first one is refreshing it's data (so the 'get_data' method of the source object is processed, which could mean there are some select statements implemented and therefore need some time). WHILE this is processing, the time may has come for the second graph to refresh (so CL_GUI_TIMER raises the 'finished' event) - so the event will be fired, but the handler method for the won't be executed, because the first chart is currently processing the GET_DATA method. This means, nothing happens when the second chart should be refreshed.
    Fine, I told myself, parallel programming could easily fix this (later on, I figured out I was horribly mistaken (comment: I had no experience in parallel programming in ABAP so far)).
    My intention was to give every chart object a separate 'thread', so they wouldn't be in each others ways (and thereby, as a side effect, the whole construct would gain some performance).
    Finally we got to the actual problem:
    There my problems started - the only way, to do some parallel programming in ABAP seems to be function modules using RFC (event though I always want to stay on the same application server). So the 'parallel thread' has to be a RFC function module - which means, there is no possibility for me to supply some object references to the function module (in my example, this would be the graph objects). So far I tried to do some workarounds like:
    - using serialization, whereby I give the serialized objects into the function module as a string and rebuild it in there, which would work fine, if there where no attributes of objects, that are not serialize-able, in the chart objects (like a instance of CL_GUI_TIMER and some more).
    - using shared objects, which gives me a way to access the object from the function module as well. But - there is no way to use event-handler methods in shared objects classes. So if I mark the 'Root class' of the chart classes as shared memory-enabled in SE24, I can't activate it, because it contains some event-handler methods (for example the one that reacts on the 'finished' event of CL_GUI_TIMER).
    Now I'm running out of ideas, how I could solve my problems and use parallel programming in ABAP actually using references and all the object oriented features I need (events, interfaces, inheriting and so on).
    Does someone of you out there have any idea how I could fix this - if there may is another way of parallel programming in ABAP, or another way to access objects using RFC function modules, or anything else?
    I really appreciate any hint you could give me.
    Let me know, if you need some more information.
    Thank you very very much for your help and best regards
    Sebastian

    As you said RFC Enabled function modules are the only way to enable parallel processing.
    Your event handler for the 'finished' event of your timer can call an RFC FM with another method on the class being performed when it's done:
    CALL FUNCTION func STARTING NEW TASK task
                  [DESTINATION {dest|{IN GROUP {group|DEFAULT}}}]
                  parameter list
                  CALLING meth ON END OF TASK].
    You can pass in what you need for the select and get back the results. Then the method you call 'on end of task' can perform the rest of the refresh. If you want to stick to mostly OO concepts then the RFC function module could just be a wrapper for a static method on your class which gathers data for your refresh...

  • Regardin handling exception in a function, while using that function in sql

    Hi gurus,
    I have a question regarding logging exceptions while using functions.
    I wrote a separate package to handle errors, where i have a procedure.
    In this proc i'm logging my error into a table and then raise the error to the front end.
    Ex:
    proc_log_and_raise    -- this proc... inserts my error into a table and then raisenow i included this error procedure in all functions and procedures.
    consider an example with a sample procedure and function.
    function func_1(( v_var   varchar2) return varchar2 is
    begin
         select   column2
         from     table2
        where col1 = v_var;
    exception
        when others then
             proc_log_and_raise;
    end;  
    procedure proc_1( v_var   varchar2) is
    begin
        select   func_1(v_var)  -- error occurs here..
        from     table_a
        where   col1 = v_var;
    exception
        when others then
             proc_log_and_raise;
    end;    now i do
    exec  proc_1( v_var );but now my problem is, when an error occurs in func_1, i'm getting an error with DML operation ( as we are inserting into error table)
    ORA-14551: cannot perform a DML operation inside a query.
    so what i want to do is, log both function and procedure where error occured.
    So is there any other better way, we can write our exception handling, so that i can log error and use function in a select statement.
    thank you.

    I changed my procedure a little, to make it simple.
    FUNCTION        PKG_WEEKLY.FUNC_1
                RETURN NUMBER IS 
                exc exception;
    BEGIN                         
                raise exc;
                RETURN           v_provr_rcoupt;
    EXCEPTION
                when exc then
                            PKG.PKG_ERROR.USP_LOG_AND_RAISE(
                                        'batch_1',
                                        'func_1',
                                        SQLCODE,
                                        DBMS_UTILITY.FORMAT_ERROR_STACK || DBMS_UTILITY.FORMAT_ERROR_BACKTRACE()); 
    END FUNC_1;     
    PROCEDURE    PKG_WEEKLY.PROC_1(
                cur_details                                OUT      sys_refcursor) IS
    BEGIN
                OPEN cur_details FOR
                SELECT            NVL(PKG.PKG_WEEKLY.FUNC_1,0))    FROM DUAL;
    EXCEPTION
                WHEN OTHERS THEN
                            REPORT_APP_PKG.PKG_REPORT_ERROR.USP_LOG_AND_RAISE(
                                        'batch_1',
                                        'PROC_1',
                                        SQLCODE,
                                        DBMS_UTILITY.FORMAT_ERROR_STACK || DBMS_UTILITY.FORMAT_ERROR_BACKTRACE());  
    END PROC_1; Now i execute it.
    exec PKG_WEEKLY.PROC_1(:cursor); Error logged into the table:
    242 batch_1 func_1 ORA-06510: PL/SQL: unhandled user-defined exception
    ORA-06512: at "REPORT_APP_PKG.PKG_REPORT_WEEKLY_CAO", line 230
    04/14/2009 16:09:25
    ERRORS displayed to the front end:
    ORA-20156: ORA-06510: PL/SQL: unhandled user-defined exception
    ORA-06512: at "PKG.PKG_WEEKLY", line 230
    ORA-06512: at "PKG.PKG_ERROR", line 48
    ORA-06512: at "PKG.PKG_ERROR", line 226
    ORA-06512: at "PKG.PKG_WEEKLY", line 261
    thank you

  • Cannot run a servlet using Tomcat. Urgent

    I have a webapplication which uses some jsp's and servlets. The jsp pages work fine when I use
    http://hostname:8080/MyWebapp/Filename.jsp
    However, when I developed a java servlet and put the class file in WEB-INF/classes directory of my web application and tried to access it.
    I got a resource not found error.
    The strange thing is that when I put the file in the web-inf/classes folder of examples webapplication (which comes with Tomcat) I am able to run the servlet using
    http://hostname:8080/examples/servlet/Class file
    I am not sure what is wrong.
    Can someone help me.
    Thanks in advance
    Vamsi.

    It's predictable. The Servlet and JSP specifications mandate that you cannot directly access resources under WEB-INF directory. You have to set up servlet mapping configuration in your web.xml to specify how to access the resources, both Servlet and JSP, there.
    When you copied your files in a demo webapp of Tomcat, the web.xml of the demo app already set up the mapping like following for you. So you could use http://hostname:8080/examples/servlet/Class to visit the servlet.
    <servlet-mapping>
    <servlet-name>invoker</servlet-name>
    <url-pattern>/servlet/*</url-pattern>
    </servlet-mapping>
    The default setting since Tomcat 4.1 turned off servlet invoker in web.xml under conf directory. You can uncomment the above lines in this file to turn it on. Then you are able to visit your servlet without <servlet-mapping> configured using the following syntax,
    http://hostname:8080/<your_app_name>/servlet/<your_servlet_name>

  • CAN COMPILE BUT CANNOT RUN PROGRAM

    I am finally able to compile my program, I have the extensions .class, when I try to run the program I get an error message "main"java.lang.noclassdef
    after message appears after I type java Saluton or whatever program I am trying to run.
    Any suggestions, someone justed I use textpad, but I don't think this has anything to do with not being able to run programs, I am using windows 98 second edition.

    This is a CLASSPATH problem.
    For example, if your .class file is in the directory C:\javaclasses then you would set the CLASSPATH environment variable to that using:
    set CLASSPATH=C:\javaclasses
    Add this to your autoexec.bat and reboot so you don't have to type this every time you open a DOS prompt.
    You may want to add the current directory, ., to the list of directories (use ; to separate directories).
    set CLASSPATH=.;C:\javaclasses
    If your class is part of a package, you have to use the directory that is the parent of the packages' directories.

  • Getting Error while using CallTarget class

    I am getting following error while using the CallTarget.
    "Exception in thread "main" java.lang.NullPointerException
    at org.apache.tools.ant.taskdefs.Ant.init(Ant.java:147)
    at org.apache.tools.ant.taskdefs.CallTarget.init(CallTarget.java:85)
    at org.apache.tools.ant.taskdefs.CallTarget.setTarget(CallTarget.java:150
    at AntCallTarget.main(AntCallTarget.java:7)"
    Can anyone please help me solve this problem.
    The code where i am getting this error is
              CallTarget antCall = new CallTarget();
              antCall.setTarget("Main");

    I am getting following error while using the CallTarget.
    "Exception in thread "main" java.lang.NullPointerException
    at org.apache.tools.ant.taskdefs.Ant.init(Ant.java:147)
    at org.apache.tools.ant.taskdefs.CallTarget.init(CallTarget.java:85)
    at org.apache.tools.ant.taskdefs.CallTarget.setTarget(CallTarget.java:150
    at AntCallTarget.main(AntCallTarget.java:7)"
    Can anyone please help me solve this problem.
    The code where i am getting this error is
              CallTarget antCall = new CallTarget();
              antCall.setTarget("Main");

  • Function module equivalent to SWE_EVENT_CREATE while using ABAP classes

    Hi there,
    I used to use SWE_CREATE_EVENT to fire the events linked to my BOR objects, in order to start certain workflows.
    Now I am using ABAP classes within the WorkFlows, and the name of the classes MUST (in my case) be longer than 10 characters, and SWE_EVENT_CREATE is cutting the name so it does not work
    Do you know any FM equivalent to start an event from a ABAP class (SE24) object?
    I have tried to use SAP_WAPI_START_WORKFLOW, but I cannot find the way to include my object in the container. Any ideas on this point would be welcome as well
    Thanks so much,
    Miguel

    Thanks for such a quick reply,
    You were right. I actually did follow Jocelyn's blogs, but somehow I skipped the raising event section.
    Just for information, the URL with the solution to this problem is:
    /people/jocelyn.dart/blog/2006/07/27/raising-abap-oo-events-for-workflow
    Have a good one

  • Strange Behavior of program while using BAPI_PO_CREATE1

    Hello SAP GURUs,
    I've created an Upload Program using BAPI_PO_CREATE1 for Mass Service PO Creation.
    When I execute the program and Specify the File for uploading, It Gives me errors as
    E     BAPI     1     No instance of object type PurchaseOrder has been created. External reference:
    E     MEPO     0     Purchase order still contains faulty items
    E     6     436     In case of account assignment, please enter acc. assignment data for item
    But when I come back to Selection Screen of the Program and specify the SAME FILE AGAIN and Execute,
    The Program runs successfully and generates the PO number.
    I have never seen such strange behavior in any BAPIs before.
    Pls help..

    PERFORM refresh_tables.
      PERFORM fill_tables.
    END-OF-SELECTION.
    Display the Summary as an ALV Grid Display
      IF NOT ig_mymssg[] IS INITIAL.
        PERFORM display_basic_list . "Grid Display
      ELSE.
        MESSAGE s000 WITH 'No data exists'(051).
        STOP.
      ENDIF.
    *&      Form  refresh_tables
          text
    -->  p1        text
    <--  p2        text
    FORM refresh_tables .
      REFRESH:   ig_fieldcat,
                 ig_mymssg,
                 poitem,
                 poitemx,
                 poaccount,
                 poaccountx,
                 poservices,
                 ig_return.
                wt_itab,  record,  record2 .
    ENDFORM.                    " refresh_tables
    *&      Form  fill_tables
          text
    -->  p1        text
    <--  p2        text
    FORM fill_tables .
      record2[] = record[].
      record3[] = record[].
      DELETE ADJACENT DUPLICATES FROM record COMPARING id_no.
      DELETE ADJACENT DUPLICATES FROM record2 COMPARING id_no po_item.
      SELECT MAX( packno ) FROM esll INTO wrk_packno.
      LOOP AT record.
        CLEAR : poheader, poheaderx, wa_poitem, wa_poitemx, wa_poservices, wa_poaccount, wa_poaccountx, wa_poschedulex, wa_poschedule.
        REFRESH: poitem, poitemx, poaccount, poaccountx, poservices, ig_return,  posrvaccessvalues, poschedule, poschedulex.
        PERFORM po_header.
        LOOP AT record2 WHERE id_no = record-id_no.
          wrk_packno = wrk_packno + 1.
          PERFORM po_item.
          PERFORM po_scheudle.
          PERFORM acc_assignment.
          PERFORM po_services.
        ENDLOOP.
        PERFORM create_po.
      ENDLOOP.
    ENDFORM.                    " fill_tables
    *&      Form  display_basic_list
          text
    -->  p1        text
    <--  p2        text
    FORM display_basic_list .
      g_repid = sy-repid.
      PERFORM f2000_fieldcat_init .
      PERFORM display_alv_grid_1.
    ENDFORM.                    " display_basic_list
    *&      Form  f2000_fieldcat_init
          text
    -->  p1        text
    <--  p2        text
    FORM f2000_fieldcat_init .
      REFRESH ig_fieldcat.
      PERFORM fill_fields_of_fieldcatalog USING 'IG_MYMSSG'
                                                  'STATUS'
                                                    c_x
                                                    'Status'
                                                    '10'.
      PERFORM fill_fields_of_fieldcatalog USING 'IG_MYMSSG'
                                                'RECORD'
                                                c_x
                                                'Record'
                                                '20'.
      PERFORM fill_fields_of_fieldcatalog USING 'IG_MYMSSG'
                                                'ERRMSG'
                                                'Message'
                                                '100'.
    ENDFORM.                    " f2000_fieldcat_init
    *&      Form  display_alv_grid_1
          text
    -->  p1        text
    <--  p2        text
    FORM display_alv_grid_1 .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program = g_repid
          i_structure_name   = 'IG_MYMSSG'
          i_grid_title       = 'LOG'
          is_layout          = wg_layout
          it_fieldcat        = ig_fieldcat[]
          i_save             = c_save
        TABLES
          t_outtab           = ig_mymssg
        EXCEPTIONS
          program_error      = 1
          OTHERS             = 2.
      IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " display_alv_grid_1
    *&      Form  fill_fields_of_fieldcatalog
          text
         -->P_0626   text
         -->P_0627   text
         -->P_C_X  text
         -->P_0629   text
         -->P_0630   text
    FORM fill_fields_of_fieldcatalog  USING    p_tabname TYPE slis_tabname
                                               p_field TYPE slis_fieldname
                                               p_key TYPE c
                                               p_name
                                               len.
    To fill in the fields of the table fieldcatalog depending on the field
      CLEAR wg_fieldcat.
      wg_fieldcat-fieldname = p_field. " The field name and the table
      wg_fieldcat-tabname = p_tabname.. " name are the two minimum req
      wg_fieldcat-key = p_key. " Specifies the column as a key
      wg_fieldcat-seltext_l = p_name. " Column Header
      wg_fieldcat-outputlen = len.
      APPEND wg_fieldcat TO ig_fieldcat.
    ENDFORM.                    " fill_fields_of_fieldcatalog
    *&      Form  create_po
          text
    -->  p1        text
    <--  p2        text
    FORM create_po .
      CLEAR : wg_return.
      REFRESH : ig_return.
      CALL FUNCTION 'BAPI_PO_CREATE1'
        EXPORTING
          poheader          = poheader
          poheaderx         = poheaderx
        IMPORTING
          exppurchaseorder  = po_no
        TABLES
          return            = ig_return
          poitem            = poitem
          poitemx           = poitemx
          poschedule        = poschedule
          poschedulex       = poschedulex
          poaccount         = poaccount
          poaccountx        = poaccountx
          poservices        = poservices
          posrvaccessvalues = posrvaccessvalues.
      SORT ig_return BY type.
      READ TABLE ig_return INTO wg_return WITH KEY type = 'S'.
      IF sy-subrc EQ 0.
        CLEAR : wg_return.
        REFRESH : ig_return.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
        CLEAR wg_errmsg.
        WRITE icon_green_light AS ICON TO wg_errmsg-status.
        CONCATENATE record-id_no po_no INTO wg_errmsg-record SEPARATED BY '/'.
       wg_errmsg-record = po_no.
        wg_errmsg-errmsg = 'PO created'.
        APPEND wg_errmsg TO ig_mymssg.
      ELSE.
        CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
        READ TABLE ig_return INTO wg_return WITH KEY type = 'E' TRANSPORTING message.
        CLEAR wg_errmsg.
        WRITE icon_red_light AS ICON TO wg_errmsg-status.
        wg_errmsg-record = record-id_no.
        wg_errmsg-errmsg = wg_return-message.
        APPEND wg_errmsg TO ig_mymssg.
      ENDIF.
    ENDFORM.                    " create_po
    *&      Form  po_header
          text
    -->  p1        text
    <--  p2        text
    FORM po_header .
      poheader-comp_code   = record-comp_code.
      poheader-doc_type    = record-doc_type.
      poheader-vendor      = record-vendor.
      poheader-purch_org   = 'SERV'.
      poheader-pur_group   = record-pur_group.
      poheader-currency    = 'INR'.
      poheaderx-comp_code   = 'X'.
      poheaderx-doc_type    = 'X'.
      poheaderx-vendor      = 'X'.
      poheaderx-purch_org   = 'X'.
      poheaderx-pur_group   = 'X'.
      poheaderx-currency    = 'X'.
    ENDFORM.                    " po_header
    *&      Form  po_item
          text
    -->  p1        text
    <--  p2        text
    FORM po_item .
    DATA : days TYPE num2.
    DATA : final_dt TYPE datum.
    DATA : is_ok TYPE boole_d.
    DATA : msg_hndlr TYPE REF TO if_hrpa_message_handler.
    days = 20.
    CALL FUNCTION 'HR_ECM_ADD_PERIOD_TO_DATE'
       EXPORTING
         orig_date       = sy-datum
         num_days        = days
         signum          = '+'
         message_handler = msg_hndlr
       IMPORTING
         result_date     = final_dt
         is_ok           = is_ok.
      CLEAR: wa_poitem,wa_poitemx.
      wa_poitem-po_item      = record2-po_item.
      wa_poitem-short_text   = record2-short_text.
      wa_poitem-plant        = record2-plant.
      wa_poitem-matl_group   = 'S001'.
      wa_poitem-tax_code     = 'LA'.
      wa_poitem-item_cat     = item_cat.
      wa_poitem-pckg_no      = wrk_packno.
      wa_poitem-acctasscat   = acctasscat.
    wa_poitem-gr_to_date   = final_dt.
      APPEND wa_poitem TO poitem.
      wa_poitemx-po_item      = record2-po_item.
      wa_poitemx-po_itemx      = 'X'.
      wa_poitemx-short_text   = 'X'.
      wa_poitemx-plant        = 'X'.
      wa_poitemx-tax_code     = 'X'.
      wa_poitemx-item_cat     = 'X'.
      wa_poitemx-acctasscat   = 'X'.
      wa_poitemx-pckg_no      = 'X'.
      wa_poitemx-matl_group   = 'X'.
      wa_poitem-gr_to_date    = 'X'.
      APPEND wa_poitemx TO poitemx.
    ENDFORM.                    " po_item
    *&      Form  PO_SERVICES
          text
    -->  p1        text
    <--  p2        text
    FORM po_services .
      CLEAR: wa_poservices, wa_posrvaccessvalues.
      wa_poservices-pckg_no = wrk_packno.
      wa_poservices-line_no  = '0000000001'.
      wa_poservices-outl_ind = 'X'.
      wa_poservices-subpckg_no = wa_poservices-pckg_no + 1.
      wa_poservices-from_line = '000001'.
      APPEND wa_poservices TO poservices.
      CLEAR wa_poservices.
      wrk_packno = wrk_packno + 1.
      wa_poservices-pckg_no = wrk_packno.
      wa_poservices-line_no  = '0000000002'.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          input  = record2-service
        IMPORTING
          output = record2-service.
      wa_poservices-ext_line = '0000000010'.
      wa_poservices-service  = record2-service.
      wa_poservices-quantity = record2-quantity.
      wa_poservices-gr_price = record2-gr_price.
      wa_posrvaccessvalues-pckg_no = wrk_packno.
      wa_posrvaccessvalues-line_no = '0000000002'.
      wa_posrvaccessvalues-serial_no = '01'.
      wa_posrvaccessvalues-serno_line = '01'.
    wa_posrvaccessvalues-quantity = record2-quantity.
    wa_posrvaccessvalues-net_value = record2-gr_price.
      APPEND wa_poservices TO poservices.
      APPEND wa_posrvaccessvalues TO posrvaccessvalues.
    ENDFORM.                    " PO_SERVICES
    *&      Form  ACC_ASSIGNMENT
          text
    -->  p1        text
    <--  p2        text
    FORM acc_assignment .
      DATA : tmp_gl LIKE bapimepoaccount-gl_account.
      tmp_gl = '400265'.
      CLEAR : wa_poaccount, wa_poaccountx.
      wa_poaccount-po_item      =  record2-po_item.
      wa_poaccount-serial_no    = '01'.
      wa_poaccount-co_area      = '1000'.
      wa_poaccount-quantity     = record2-quantity.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          input  = tmp_gl
        IMPORTING
          output = wa_poaccount-gl_account.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          input  = record2-orderid
        IMPORTING
          output = wa_poaccount-orderid.
      APPEND wa_poaccount TO poaccount.
      wa_poaccountx-po_item      = record2-po_item.
      wa_poaccountx-serial_no    = '01'.
      wa_poaccountx-co_area      = 'X'.
      wa_poaccountx-quantity     = 'X'.
      wa_poaccountx-gl_account   = 'X'.
      wa_poaccountx-orderid      = 'X'.
      APPEND wa_poaccountx TO poaccountx.
    ENDFORM.                    " ACC_ASSIGNMENT
    *&      Form  PO_SCHEUDLE
          text
    -->  p1        text
    <--  p2        text
    FORM po_scheudle .
      CLEAR : wa_poschedule, wa_poschedulex.
      wa_poschedule-po_item = record2-po_item.
      wa_poschedule-sched_line = '0001'.
    wa_poschedule-del_datcat_ext = 'D'.
      wa_poschedule-delivery_date = sy-datum.
      wa_poschedule-quantity = record2-quantity.
      APPEND wa_poschedule TO poschedule.
      wa_poschedulex-po_item = record2-po_item.
      wa_poschedulex-sched_line = '0001'.
      wa_poschedulex-po_itemx = 'X'.
      wa_poschedulex-sched_linex = 'X'.
    wa_poschedulex-del_datcat_ext = 'X'
      wa_poschedulex-delivery_date = 'X'.
      wa_poschedulex-quantity = 'X'.
      APPEND wa_poschedulex TO poschedulex.
    ENDFORM.                    " PO_SCHEUDLE

Maybe you are looking for

  • There was a problem connecting to the server...please check the share name..every 3 seconds.  made computer useless

    there was a problem connecting to the server...please check the share name..every 3 seconds.  made computer useless. Lion.  It only complains about one of my PCs that usually shares OK with the imac.

  • Compiling .java files

    I am currently just using notepad in Windows XP to create my .java files, and going to the command prompt to compile my files. Is there a way of being able to compile my .java files without having to navigate to the folder with which they are in??

  • Mail Message Import Hanging in Max OSX 10.8

    I have just purchased a new iMac and cannot import my mail messages. It is hanging on 920 of 14000 each time. Does anyone know how to overcome this problem? I have read through some of the threads on this and tried some of the recommendations but am

  • 2 rpds on one server

    Hi Gurus, I created 2 presentation service and given 2 port for to instanceconfig.xmls but when i started the preseentation services but gettting following error message An error occoured during execution of bind. an attempt was made to access a sock

  • The gatekeeper doesn't send an ACF to the h323 gateway

    Hi, I found a h323 gateway can't make any international calls thru a gatekeeper. From the debug log, the gatekeeper doesn't send an ACF to the gateway after received a LCF from another gatekeeper. Is it a know bug or configuration issue? Attached is