WebUtil_c_Api problem

I´m trying to execute the following C function:
extern "C" __declspec( dllexport ) int add(int* value1, int* value2);
So I have make the folling package:
PACKAGE BODY calculator IS
     add_func webutil_c_api.FunctionHandle;
     add_func_parameters webutil_c_api.ParameterList;
     add_param1 webutil_c_api.ParameterHandle;
     add_param2 webutil_c_api.ParameterHandle;
     add_return PLS_INTEGER;     
     FUNCTION i_dll_add(add_func IN webutil_c_api.FunctionHandle, value1 IN OUT NOCOPY PLS_INTEGER,
               value2 IN OUT NOCOPY PLS_INTEGER)
               RETURN PLS_INTEGER;
     PRAGMA INTERFACE (c, i_dll_add, 11265);
     FUNCTION dll_add (value1 IN OUT NOCOPY PLS_INTEGER, value2 IN OUT NOCOPY PLS_INTEGER)
          RETURN PLS_INTEGER IS
          BEGIN
               RETURN i_dll_add(add_func, value1, value2);
END dll_add;
          add_func := webutil_c_api.register_function('Calculator_ws.dll', 'add');
          add_func_parameters := webutil_c_api.create_parameter_list;           
          add_param1 := webutil_c_api.add_parameter(add_func_parameters, webutil_c_api.C_INT_PTR, webutil_c_api.PARAM_INOUT, 0);
          add_param2 := webutil_c_api.add_parameter(add_func_parameters, webutil_c_api.C_INT_PTR, webutil_c_api.PARAM_INOUT, 1);
          add_return := webutil_c_api.Invoke_Int('Calculator_ws.dll', 'add', add_func_parameters);           
          webutil_c_api.Destroy_Parameter_List(add_func_parameters);
          webutil_c_api.Deregister_Function(add_func);           
END calculator;
But when I execute the FUNCTION it doesn't work. Does anyone which could be the problem?
Thank you.

Look again at your code - It seems to me this has been converted from some ORA_FFI code am I correct??
If you are calling the dll_add function then this is in turn calling i_dll_add, and that is calling to a DLL loaded on the server side (that's the pragma interface bit) and not touching WebUtil or the client side at all.
So rip out the i_dll_add spec and body and move all the webutil code calls into dll_add where they will actually be called.

Similar Messages

  • Hard Coded Path Problem while using  WEBUTIL_C_API

    My 9i form is calling a C program using WEBUTIL_C_API it works fine with out any problem, if i hard code the path of DDL FILE as follows.
    f_handle := WEBUTIL_C_API.register_function('c:\winnt\system32\tabs.dll','buildit');
    If i remove the hard coded path then the form does not work.
    How can i overcome the probelem?
    Thanks

    The DLL has to be on the OS PATH.
    So it may be
    1) c:\winnt\system32 is not on your PATH (it should be)
    2) Maybe the PATH is too long, and c:\winnt\system32 is now too 'far back' to be used by the OS. Just move it forward.
    Similarly, if you put the DLL in another folder, then that folder should be on the PATH.
    If the above do not give a solution, it would be good to check with FileMon (freeware from www.sysinternals.com) to see if the OS is actually looking at your folder to locate the DLL.
    Regards - Roelof.

  • Convert ORA_FFI to WEBUTIL_C_API to print locally

    I am trying to figure out how to convert this package to WEBUTIL_C_API to be able to print to a users local printer (EPSON slip printer)... ANY help would be appreciated...
    PACKAGE EPSON_SLIP_PRINTER_INTERFACE IS
    * This package provides functions to interact with the EPSON
    * TM-U295 slip printers.
    * The OPEN_PRINTER function must be called to obtain a printer ID.
    * This printer ID can then be used when calling other functions
    * that require a printer to be specified.
    * NOTE that the printer ID is only valid within the same thread
    * that called the OPEN_PRINTER function.
    * Brendan Rickey 2004-JAN-09
    -- AVAILABLE PRINTERS
    CHEQUE_PRINTER     VARCHAR2(50) := 'Generic / Text Only droite';
    INVOICE_PRINTER     VARCHAR2(50) := 'Generic / Text Only left';
    -- ERROR CODES
    -- Some of the provided functions return a NUMBER value that may hold
    -- an error code (negative number).
    -- These are the possible error codes:
    SUCCESS                    NUMBER := 0;     --no error
    ERR_TYPE               NUMBER := -10;     --parameter type error
    ERR_OPENED               NUMBER := -20; --printer already opened
    ERR_NO_PRINTER     NUMBER := -30;     --the printer driver does not exist
    ERR_NO_TARGET          NUMBER := -40;     --no printer found (could of off, faulty, unsupported)
    ERR_NO_MEMORY          NUMBER := -50;     --insufficient memory
    ERR_HANDLE               NUMBER := -60;     --invalid printer ID
    ERR_TIMEOUT               NUMBER := -70;     --time out error
    ERR_ACCESS               NUMBER := -80;     --cannot read/write to printer (printing in progress)
    ERR_PARAM               NUMBER := -90;     --parameter error
    ERR_OFFLINE               NUMBER := -110;     --printer was opened in offline state.  Status must be changed to online.
    ERR_NOT_EPSON          NUMBER := -120;     --printer is not an EPSON printer
    * INITIALIZE
    * Initializes the interface between Forms and the EPSON library (call before any other function in the package).
    * Returns:
    * TRUE if the library is registered successfully,
    * FALSE otherwise (library not found etc...)
    function INITIALIZE return BOOLEAN;
    * OPEN_PRINTER
    * Obtains a handle on the specified EPSON slip printer (either CHEQUE_PRINTER or INVOICE_PRINTER).
    * Returns:
    *           a printer ID for the specified printer (greater than 0)
    *           an error code on failure (less than 0):
    * ERR_TYPE, ERR_OPENED, ERR_NO_PRINTER, ERR_NO_TARGET, ERR_NO_MEMORY, ERR_PARAM
    function OPEN_PRINTER (p_printer_name IN VARCHAR2) return NUMBER;
    * CLOSE_PRINTER
    * Releases the handle on the specified printer.
    * Returns:
    *           0 on success
    *           ERR_HANDLE on failure
    function CLOSE_PRINTER (p_printer_id IN NUMBER) return NUMBER;
    * IS_PAPER_OUT
    * Tests if there is no paper in the printer.
    * Returns:
    *           1 if there is no paper in the printer, 0 if paper is in the printer
    *           ERR_HANDLE or ERR_PARAM on failure.
    function IS_PAPER_OUT (p_printer_id IN NUMBER) return NUMBER;
    * PRINT_TEXT
    * Prints the specified text to the specified printer.
    * Returns:
    *           0 on success
    *           ERR_HANDLE, ERR_ACCESS, ERR_OFFLINE, ERR_NOT_EPSON, or ERR_PARAM on failure.
    function PRINT_TEXT (p_printer_id IN NUMBER, p_text IN VARCHAR2) return NUMBER;
    * RELEASE_PAPER
    * Performs the Release function on the specified printer.
    * Returns:
    *           0 on success
    *           ERR_HANDLE, ERR_ACCESS, ERR_OFFLINE, ERR_NOT_EPSON, or ERR_PARAM on failure.
    function RELEASE_PAPER (p_printer_id IN NUMBER) return NUMBER;
    /* PRIVATE FUNCTIONS
    function BiOpenMonPrinter(arg0 in PLS_INTEGER,
    arg1 in out VARCHAR2)
    return PLS_INTEGER;
    function BiCloseMonPrinter(arg0 in PLS_INTEGER)
    return PLS_INTEGER;
    function BiGetStatus(arg0 in PLS_INTEGER,
    arg1 in out PLS_INTEGER)
    return PLS_INTEGER;
    function BiDirectIO(arg0 in PLS_INTEGER,
    arg1 in PLS_INTEGER,
    arg2 in out VARCHAR2,
    arg3 in out PLS_INTEGER,
    arg4 in out VARCHAR2,
    arg5 in PLS_INTEGER,
    arg6 in PLS_INTEGER)
    return PLS_INTEGER;
    function BiDirectIOEx(arg0 in PLS_INTEGER,
    arg1 in PLS_INTEGER,
    arg2 in out VARCHAR2,
    arg3 in out PLS_INTEGER,
    arg4 in out VARCHAR2,
    arg5 in PLS_INTEGER,
    arg6 in PLS_INTEGER,
    arg7 in PLS_INTEGER)
    return PLS_INTEGER;
    END;
    PACKAGE BODY EPSON_SLIP_PRINTER_INTERFACE IS
    v_msg_b VARCHAR2(20);
    v_EPSON_LIBRARY_OK BOOLEAN:= FALSE;
    --ORA_FFI function handles and library handle
    lh_EpsStmApi ora_ffi.libHandleType;                    --DLL library handle
    fh_BiOpenMonPrinter ora_ffi.funcHandleType;          --DLL function handle
    fh_BiCloseMonPrinter ora_ffi.funcHandleType;     --DLL function handle
    fh_BiGetStatus ora_ffi.funcHandleType;               --DLL function handle
    fh_BiDirectIO ora_ffi.funcHandleType;               --DLL function handle
    fh_BiDirectIOEx ora_ffi.funcHandleType;               --DLL function handle
    --constant
    ASB_SLIP_BOF     PLS_INTEGER := 4*power(16,5);     --BOF printer status flag 0x00400000
    c_release_code      CHAR(2) := CHR(27)||CHR(113);     --ESC+q, to release the paper
    -------PRIVATE FUNCTIONS--------
    * Brendan Rickey 2004-JAN-09
    * The following are functions that are required to interface with the
    * EPSON StatusAPI DLL (C library) though ORA_FFI.
    * The following describes the DLL functions that are made available
    * through this ORA_FFI implementation:
    Function Purpose
    BiOpenMonPrinter Get a handle on a printer.
    Parameters
    p_Type --int: 1 if p_Name is a port, 2 if a printer name.
    ,p_Name --varchar2: the port of printer name to open.
    Return printer identifier number (>0) on success, < 0 on failure.
    BiCloseMonPrinter Close the monitor on the printer.
    Parameters
    p_Handle --int: The numerical printer handle returned from BiOpenMonPrinter.
    Return 0 on success, < 0 on failure.
    BiGetStatus Returns the status of the printer.
    Parameters     
    p_Handle --int: The numerical printer handle returned from BiOpenMonPrinter.
    ,p_Status OUT --long: The status of the printer (use AND bitwise operator to test for statuses).
    Return 0 on success, < 0 on failure.
    BiDirectIO Sends data to and Reads data from the printer. Use BiDirectIOEx if more that 255 chars are to be written/read.
    Parameters
    p_Handle --int: The numerical printer handle returned from BiOpenMonPrinter.
    ,p_WriteLen --short: The length of the command/data being sent to the printer (max 255).
    ,p_WriteCmd --varchar2: The command/data to send to the printer.
    ,p_ReadLen --short: The length of the data to be read from the printer (max 255)
    (Use 0 if no data is to be read).
    ,p_ReadBuff OUT --varchar2: The buffer where the the data read from the printer is stored.
    ,p_Timeout --long: write/read time out in msecs.
    ,p_NullTerminate --short: 0 => reading of data from printer is performed until time out or length of p_ReadLen is reached.
    1 => reading is finished at thepoint when a NULL is received from the printer. ReadLen must have a value.
    Return 0 on success, < 0 on failure.
    BiDirectIOEx Sends data to and Reads data from the printer (handles larger quantities of write/read data).
    Parameters
    p_Handle --int: The numerical printer handle returned from BiOpenMonPrinter.
    ,p_WriteLen --long: The length of the command/data being sent to the printer.
    ,p_WriteCmd --varchar2: The command/data to send to the printer.
    ,p_ReadLen --long: The length of the data to be read from the printer (Use 0 if no data is to be read).
    ,p_ReadBuff OUT --varchar2: The buffer where the the data read from the printer is stored.
    ,p_Timeout --long: write/read time out in msecs.
    ,p_NullTerminate --short: 0 => reading of data from printer is performed until time out or length of p_ReadLen is reached.
    1 => reading is finished at thepoint when a NULL is received from the printer. ReadLen must have a value.
    ,p_Option --short: 0 => prevents Automatic Status Back (ASB) during execution of this function (as does BiDirectIO).
    1 => does not disable Automatic Status Back (ASB).
    Return 0 on success, < 0 on failure.
    function icd_BiOpenMonPrinter(funcHandle in ora_ffi.funcHandleType, arg0 in PLS_INTEGER,
    arg1 in out VARCHAR2)
    return PLS_INTEGER;
    pragma interface(c, icd_BiOpenMonPrinter, 11265);
    function BiOpenMonPrinter(arg0 in PLS_INTEGER,
    arg1 in out VARCHAR2)
    return PLS_INTEGER is
    begin
    return(icd_BiOpenMonPrinter(fh_BiOpenMonPrinter,
    arg0,
    arg1));
    end;
    function icd_BiCloseMonPrinter(funcHandle in ora_ffi.funcHandleType, arg0 in PLS_INTEGER)
    return PLS_INTEGER;
    pragma interface(c, icd_BiCloseMonPrinter, 11265);
    function BiCloseMonPrinter(arg0 in PLS_INTEGER)
    return PLS_INTEGER is
    begin
    return(icd_BiCloseMonPrinter(fh_BiCloseMonPrinter,
    arg0));
    end;
    function icd_BiGetStatus(funcHandle in ora_ffi.funcHandleType, arg0 in PLS_INTEGER,
    arg1 in out PLS_INTEGER)
    return PLS_INTEGER;
    pragma interface(c, icd_BiGetStatus, 11265);
    function BiGetStatus(arg0 in PLS_INTEGER,
    arg1 in out PLS_INTEGER)
    return PLS_INTEGER is
    begin
    return(icd_BiGetStatus(fh_BiGetStatus,
    arg0,
    arg1));
    end;
    function icd_BiDirectIO(funcHandle in ora_ffi.funcHandleType, arg0 in PLS_INTEGER,
    arg1 in PLS_INTEGER,
    arg2 in out VARCHAR2,
    arg3 in out PLS_INTEGER,
    arg4 in out VARCHAR2,
    arg5 in PLS_INTEGER,
    arg6 in PLS_INTEGER)
    return PLS_INTEGER;
    pragma interface(c, icd_BiDirectIO, 11265);
    function BiDirectIO(arg0 in PLS_INTEGER,
    arg1 in PLS_INTEGER,
    arg2 in out VARCHAR2,
    arg3 in out PLS_INTEGER,
    arg4 in out VARCHAR2,
    arg5 in PLS_INTEGER,
    arg6 in PLS_INTEGER)
    return PLS_INTEGER is
    begin
    return(icd_BiDirectIO(fh_BiDirectIO,
    arg0,
    arg1,
    arg2,
    arg3,
    arg4,
    arg5,
    arg6));
    end;
    function icd_BiDirectIOEx(funcHandle in ora_ffi.funcHandleType, arg0 in PLS_INTEGER,
    arg1 in PLS_INTEGER,
    arg2 in out VARCHAR2,
    arg3 in out PLS_INTEGER,
    arg4 in out VARCHAR2,
    arg5 in PLS_INTEGER,
    arg6 in PLS_INTEGER,
    arg7 in PLS_INTEGER)
    return PLS_INTEGER;
    pragma interface(c, icd_BiDirectIOEx, 11265);
    function BiDirectIOEx(arg0 in PLS_INTEGER,
    arg1 in PLS_INTEGER,
    arg2 in out VARCHAR2,
    arg3 in out PLS_INTEGER,
    arg4 in out VARCHAR2,
    arg5 in PLS_INTEGER,
    arg6 in PLS_INTEGER,
    arg7 in PLS_INTEGER)
    return PLS_INTEGER is
    begin
    return(icd_BiDirectIOEx(fh_BiDirectIOEx,
    arg0,
    arg1,
    arg2,
    arg3,
    arg4,
    arg5,
    arg6,
    arg7));
    end;
    --------PUBLIC FUNCTIONS--------
    function INITIALIZE return BOOLEAN IS
    BEGIN
    --When this is the first package function called, code in the package's
    --body is executed and sets v_EPSON_LIBRARY_OK.
    RETURN v_EPSON_LIBRARY_OK;
    END;
    function OPEN_PRINTER (p_printer_name IN VARCHAR2) return NUMBER IS
         v_printer                    PLS_INTEGER;
         v_printer_name     VARCHAR2(50) := p_printer_name;
         v_name_type           PLS_INTEGER := 2; --use printer Name to specify printer     
    BEGIN
         /* Open a monitor for the printer */
         v_printer := BiOpenMonPrinter(v_name_type,v_printer_name);
         RETURN v_printer;
    END;
    function CLOSE_PRINTER (p_printer_id IN NUMBER) return NUMBER IS
    v_return PLS_INTEGER;
    BEGIN
    /* CLOSE the printer monitor */
         v_return := BiCloseMonPrinter(p_printer_id);
         RETURN v_return;
    END;
    function IS_PAPER_OUT (p_printer_id IN NUMBER) return NUMBER IS
         v_return          PLS_INTEGER;
         v_status          PLS_INTEGER := -123456;
    BEGIN
         /* Test if paper is in the printer by first getting the status (a binary integer) */
         v_return := BiGetStatus(p_printer_id,v_status);
         IF v_return <> 0 THEN
              RETURN v_return;
         ELSE
         --Test for BOF status flag
         IF WIN_API_BITOP.BITWISE_AND(v_status,ASB_SLIP_BOF) = ASB_SLIP_BOF THEN
              RETURN 1; --paper out
         ELSE
              RETURN 0; --paper in
         END IF;
         END IF;
    END;
    function PRINT_TEXT (p_printer_id IN NUMBER, p_text IN VARCHAR2) return NUMBER IS
    v_return          PLS_INTEGER;
    v_text               VARCHAR2(2000) := p_text;
    v_text_len          PLS_INTEGER;                    --number of characters to be printed
    v_read_len      PLS_INTEGER := 0;               --number of characters to be read from the printer
    v_read_buff      VARCHAR2(255) := NULL;          --not used: holds characters read from the printer
    v_timeout      PLS_INTEGER := 1000;          --not used: amount of time to wait for response (msecs)
         v_nullTerm          PLS_INTEGER := 0;               --not used: 0 means read until reached v_read_len or v_timeout
         -- 1 means read until NULL received from printer
         v_option          PLS_INTEGER := 0;           --0 means do not answer other requests while printing
                                                                --1 means do not stop answering other requests while printing
    BEGIN
         --Get the number of chars to be printed and then print.
         v_text_len := length(p_text);
         v_return := BiDirectIOEx(p_printer_id,
         v_text_len,
         v_text,
         v_read_len,
         v_read_buff,
         v_timeout,
         v_nullTerm,
         v_option);
         --Ignore timeout(-70) errors, otherwise return error
         IF v_return = -70 THEN
              v_return := 0;     
         END IF;
         RETURN v_return;
    END;
    function RELEASE_PAPER (p_printer_id IN NUMBER) return NUMBER IS
    BEGIN
    /* Release the paper by sending the release escape code to the printer */
         RETURN PRINT_TEXT(p_printer_id, c_release_code);
    END;
    -----END OF FUNCTION IMPLEMENTATIONS-----
    BEGIN
    * Load the EPSON printer driver's StatusAPI library.
    * Create an ORA_FFI interface to the library by doing the following for each desired function:
    *          1- Create a handle on the function,
    *          2- Register the return value,
    *          3- Register the arguments/parameters in the correct order.
    lh_EpsStmApi := ora_ffi.load_library('', 'EpsStmApi.DLL');
    IF Ora_Ffi.Is_Null_Ptr(lh_EpsStmApi) THEN
         AFC_MESSAGES('I','MAIN-0020','E',v_msg_b);
         v_EPSON_LIBRARY_OK := FALSE;
    ELSE
    fh_BiOpenMonPrinter := ora_ffi.register_function(lh_EpsStmApi, 'BiOpenMonPrinter', ora_ffi.c_std);
    ora_ffi.register_return(fh_BiOpenMonPrinter, ora_ffi.c_int, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiOpenMonPrinter, ora_ffi.c_int, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiOpenMonPrinter, ora_ffi.c_char_ptr, ora_ffi.pls_varchar2);
    fh_BiCloseMonPrinter := ora_ffi.register_function(lh_EpsStmApi, 'BiCloseMonPrinter', ora_ffi.c_std);
    ora_ffi.register_return(fh_BiCloseMonPrinter, ora_ffi.c_int, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiCloseMonPrinter, ora_ffi.c_int, ora_ffi.pls_pls_integer);
    fh_BiGetStatus := ora_ffi.register_function(lh_EpsStmApi, 'BiGetStatus', ora_ffi.c_std);
    ora_ffi.register_return(fh_BiGetStatus, ora_ffi.c_int, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiGetStatus, ora_ffi.c_int, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiGetStatus, ora_ffi.c_long_ptr, ora_ffi.pls_pls_integer);
    fh_BiDirectIO := ora_ffi.register_function(lh_EpsStmApi, 'BiDirectIO', ora_ffi.c_std);
    ora_ffi.register_return(fh_BiDirectIO, ora_ffi.c_int, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiDirectIO, ora_ffi.c_int, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiDirectIO, ora_ffi.c_short, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiDirectIO, ora_ffi.c_char_ptr, ora_ffi.pls_varchar2);
    ora_ffi.register_parameter(fh_BiDirectIO, ora_ffi.c_short_ptr, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiDirectIO, ora_ffi.c_char_ptr, ora_ffi.pls_varchar2);
    ora_ffi.register_parameter(fh_BiDirectIO, ora_ffi.c_long, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiDirectIO, ora_ffi.c_short, ora_ffi.pls_pls_integer);
    fh_BiDirectIOEx := ora_ffi.register_function(lh_EpsStmApi, 'BiDirectIOEx', ora_ffi.c_std);
    ora_ffi.register_return(fh_BiDirectIOEx, ora_ffi.c_int, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiDirectIOEx, ora_ffi.c_int, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiDirectIOEx, ora_ffi.c_long, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiDirectIOEx, ora_ffi.c_char_ptr, ora_ffi.pls_varchar2);
    ora_ffi.register_parameter(fh_BiDirectIOEx, ora_ffi.c_long_ptr, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiDirectIOEx, ora_ffi.c_char_ptr, ora_ffi.pls_varchar2);
    ora_ffi.register_parameter(fh_BiDirectIOEx, ora_ffi.c_long, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiDirectIOEx, ora_ffi.c_short, ora_ffi.pls_pls_integer);
    ora_ffi.register_parameter(fh_BiDirectIOEx, ora_ffi.c_short, ora_ffi.pls_pls_integer);
    v_EPSON_LIBRARY_OK := TRUE;
    END IF;
    EXCEPTION
         WHEN OTHERS THEN
              AFC_MESSAGES('I','MAIN-0021','E',v_msg_b);
              v_EPSON_LIBRARY_OK := FALSE;
    END;

    Hi Duncan,
    Thanks for the response. Beyond the problem you pointed out I found that the "open server" command is requiring a window handle parameter, even though it isn't used by the program. I talked with Oracle Support and it turns out that even if the window handle isn't used, it's existence makes it not work with the current version of webutil.
    The program I am working with also has a COM interface, so I decided to back up and redo the interface using webutil OLE2. I've got it working now, just a little more polishing to do.
    Thanks again for the help.
    Mark

  • Webutil Invoke_String problem

    I've the following c function:
    extern "C" __declspec( dllexport ) char cGreeting(char* value1, char* value2);
    And follow PL/SQL code:
    PACKAGE BODY SAMPLE IS
         FUNCTION greeting(value1 IN OUT VARCHAR2, value2 IN OUT VARCHAR2) RETURN VARCHAR2 IS
              greeting_func webutil_c_api.FunctionHandle;
              greeting_params webutil_c_api.ParameterList;
              greeting_param1 webutil_c_api.ParameterHandle;
              greeting_param2 webutil_c_api.ParameterHandle;
              greeting_return VARCHAR2(1000);          
              BEGIN               
                   greeting_func := webutil_c_api.register_function('cClient.dll', 'cGreeting');
                   greeting_params := webutil_c_api.create_parameter_list;
                   greeting_param1 := webutil_c_api.add_parameter(greeting_params, webutil_c_api.C_CHAR_PTR, webutil_c_api.PARAM_INOUT, value1, 1000);
                   greeting_param2 := webutil_c_api.add_parameter(greeting_params, webutil_c_api.C_CHAR_PTR, webutil_c_api.PARAM_INOUT, value2, 1000);
                   greeting_return := webutil_c_api.Invoke_char('cClient.dll', 'cGreeting', greeting_params);
                   webutil_c_api.destroy_parameter_list(greeting_params);
                   webutil_c_api.deregister_function(greeting_func);
                   return greeting_return;
         END greeting;
    END SAMPLE;
    When I invoke this function appears this error:
    ERROR>WUL-911 [CApiFunctions.invokeCApi()] Unsupported return type for C DLL function
    Does anyone know where is the problem?
    Thank you.

    I've tried your sample. I´ve a forms and, when I push a button, throw the following code:
    declare
              myValue1 varchar2(20);
              myValue2 varchar2(20);
         greeting_func webutil_c_api.FunctionHandle;
         greeting_params webutil_c_api.ParameterList;
         greeting_param1 webutil_c_api.ParameterHandle;
         greeting_param2 webutil_c_api.ParameterHandle;
         greeting_return varchar2(1000);
         file_type text_io.file_type;
         BEGIN
         greeting_func := webutil_c_api.register_function('cClient.dll', 'myGreeting');
         greeting_params := webutil_c_api.create_parameter_list;
         greeting_param1 := webutil_c_api.add_parameter(greeting_params, webutil_c_api.C_CHAR_PTR, webutil_c_api.PARAM_INOUT, myValue1, 20);
         greeting_param2 := webutil_c_api.add_parameter(greeting_params, webutil_c_api.C_CHAR_PTR, webutil_c_api.PARAM_INOUT, myValue2, 20);
         greeting_return := webutil_c_api.Invoke_String(greeting_func, greeting_params);
         message(greeting_return);
         webutil_c_api.destroy_parameter_list(greeting_params);
         webutil_c_api.deregister_function(greeting_func);     
    EXCEPTION
              WHEN OTHERS THEN
                   file_type := text_IO.Fopen('c:\Sign\DAP\samples\logs\log.txt', 'w');
                   text_io.put( file_type, tool_err.message);
                   text_io.fclose(file_type);
    But the browser crash and print a file with the follow message:
    An unexpected exception has been detected in native code outside the VM.
    Unexpected Signal : EXCEPTION_ACCESS_VIOLATION occurred at PC=0x102c233f
    Function name=(N/A)
    Library=C:\Program Files\Oracle\JInitiator 1.3.1.9\bin\JNIsharedstubs.dll
    NOTE: We are unable to locate the function name symbol for the error
    just occurred. Please refer to release documentation for possible
    reason and solutions.
    Current Java thread:
         at oracle.forms.webutil.cApi.CPtr.getString(Native Method)
         at oracle.forms.webutil.cApi.CApiFunctions.invokeCApi(CApiFunctions.java:827)
         at oracle.forms.webutil.cApi.CApiFunctions.getProperty(CApiFunctions.java:131)
         at oracle.forms.handler.UICommon.onGet(Unknown Source)
         at oracle.forms.engine.Runform.onGetHandler(Unknown Source)
         at oracle.forms.engine.Runform.processMessage(Unknown Source)
         at oracle.forms.engine.Runform.processSet(Unknown Source)
         at oracle.forms.engine.Runform.onMessageReal(Unknown Source)
         at oracle.forms.engine.Runform.onMessage(Unknown Source)
         at oracle.forms.engine.Runform.processEventEnd(Unknown Source)
         at oracle.ewt.lwAWT.LWComponent.redispatchEvent(Unknown Source)
         at oracle.ewt.lwAWT.LWComponent.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)
    ..... [a list of libraries]
    I've a windows XP and IE6. Do you know what can be wrong?
    Thank you.

  • Webutil invoke.string problem with c++

    hi ,
    am using forms 10g and trying to call a dll in c++
    it works when i call the dll using webutil to return an integer from the dll by sending 2 parameters of type varchar2
    to invoke the function returning integer
    rc1 := WEBUTIL_C_API.Invoke_int('cards_dll.dll','Retrieving',args);     
    but when i try to return string an error occurs from the exception because oracle cant understand the type returned from c++ dll
    this is my code in c++ wish is correct
    am sending one parameter in my parameter list of type varcahar2 and i want to return a string from c
    f_handle      := WEBUTIL_C_API.register_function('cards_dll.dll','Retrieving');
    args      := WEBUTIL_C_API.create_parameter_list;
    param1      := WEBUTIL_C_API.add_parameter(args,WEBUTIL_C_API.C_CHAR_PTR,WEBUTIL_C_API.PARAM_IN ,x,6);
    rc1 := WEBUTIL_C_API.Invoke_string('cards_dll.dll','Retrieving',args);     -----here is the problem
    WEBUTIL_C_API.Destroy_Parameter_List(args);
    WEBUTIL_C_API.Deregister_Function(f_handle);                                                                                
    return rc1;
    EXCEPTION
         WHEN OTHERS THEN
         MESSAGE('ERROR:' || ERROR_TEXT);
         FOR I IN 1..Tool_Err.Nerrors
         LOOP
              message (Tool_Err.Message);PAUSE;
              Tool_Err.Pop;
         END LOOP;
    END ;
    in c++dll
    am using
    extern "C" __declspec(dllexport) LPCSTR __cdecl Retrieving(LPCSTR com_reader);
    //it means return longpointer and receive long pointer in com_reader
    LPCSTR result ;
    RESULT = "JIHAD abou ghannam 10081977 august10" as example
    return RESULT;
    what should i do to receive jihad in forms 10g.
    note i can get back an integer using extern "C" __declspec(dllexport) int __cdecl Retrieving(LPCSTR com_reader);
    but not a string so its not a hardware or web problem its a type problem i think, no?
    there is another way to use other than invoke.string in oracle or i have to change the type LPCSTR IN C++?

    hi ,
    am using forms 10g and trying to call a dll in c++
    it works when i call the dll using webutil to return an integer from the dll by sending 2 parameters of type varchar2
    to invoke the function returning integer
    rc1 := WEBUTIL_C_API.Invoke_int('cards_dll.dll','Retrieving',args);     
    but when i try to return string an error occurs from the exception because oracle cant understand the type returned from c++ dll
    this is my code in c++ wish is correct
    am sending one parameter in my parameter list of type varcahar2 and i want to return a string from c
    f_handle      := WEBUTIL_C_API.register_function('cards_dll.dll','Retrieving');
    args      := WEBUTIL_C_API.create_parameter_list;
    param1      := WEBUTIL_C_API.add_parameter(args,WEBUTIL_C_API.C_CHAR_PTR,WEBUTIL_C_API.PARAM_IN ,x,6);
    rc1 := WEBUTIL_C_API.Invoke_string('cards_dll.dll','Retrieving',args);     -----here is the problem
    WEBUTIL_C_API.Destroy_Parameter_List(args);
    WEBUTIL_C_API.Deregister_Function(f_handle);                                                                                
    return rc1;
    EXCEPTION
         WHEN OTHERS THEN
         MESSAGE('ERROR:' || ERROR_TEXT);
         FOR I IN 1..Tool_Err.Nerrors
         LOOP
              message (Tool_Err.Message);PAUSE;
              Tool_Err.Pop;
         END LOOP;
    END ;
    in c++dll
    am using
    extern "C" __declspec(dllexport) LPCSTR __cdecl Retrieving(LPCSTR com_reader);
    //it means return longpointer and receive long pointer in com_reader
    LPCSTR result ;
    RESULT = "JIHAD abou ghannam 10081977 august10" as example
    return RESULT;
    what should i do to receive jihad in forms 10g.
    note i can get back an integer using extern "C" __declspec(dllexport) int __cdecl Retrieving(LPCSTR com_reader);
    but not a string so its not a hardware or web problem its a type problem i think, no?
    there is another way to use other than invoke.string in oracle or i have to change the type LPCSTR IN C++?

  • Nocopy and Webutil_c_api

    Hi,
    First of all, sorry for my bad english.
    I would like to know how to use 'nocopy' with webutil_c_api
    Because, I have a function in a dll like this:
    function_name( var1 by reference )
    The problems is the 'var 1'.
    How can i solve this problem ?

    up

  • Webutil_c_api with user32.dll (ShowWindow method) crashes

    Hello,
    I am trying to hide a window by using the method ShowWindow of user32.dll.
    So I use the package webutil_c_api.
    It works, my window becomes hidden, but just after that, the Forms applet crashes with Internet Explorer.
    Here is the code :
    declare
         v_args webutil_c_api.ParameterList;
         v_param webutil_c_api.ParameterHandle;
         v_res pls_integer;
    begin
      v_args := webutil_c_api.create_parameter_list;
      v_param := webutil_c_api.add_parameter(v_args, webutil_c_api.C_LONG, webutil_c_api.PARAM_IN, 66152);
      v_param := webutil_c_api.add_parameter(v_args, webutil_c_api.C_INT, webutil_c_api.PARAM_IN, 0);
      v_res := webutil_c_api.invoke_long('user32.dll', 'ShowWindow', v_args);
      MESSAGE('ShowWindow -> ' || v_res);
    EXCEPTION
         WHEN OTHERS THEN
           message('Error code: '||to_char(sqlcode)||'  Txt: '||sqlerrm);
           PAUSE;
           raise form_trigger_failure;
    end;Notice : I had to hardcode the Window Handler 66152 because I'm not able to find it (there is another problem).
    Do you have some hints?
    Thanks,
    Nicolas.

    When it crashes, it produces a file that is placed on my desktop :
    An unexpected exception has been detected in native code outside the VM.
    Unexpected Signal : EXCEPTION_ACCESS_VIOLATION occurred at PC=0x2
    Function name=(N/A)
    Library=(N/A)
    NOTE: We are unable to locate the function name symbol for the error
          just occurred. Please refer to release documentation for possible
          reason and solutions.
    Current Java thread:
         at oracle.forms.webutil.cApi.CFunc.callInt(Native Method)
         at oracle.forms.webutil.cApi.CApiFunctions.invokeCApi(CApiFunctions.java:837)
         at oracle.forms.webutil.cApi.CApiFunctions.getProperty(CApiFunctions.java:144)
         at oracle.forms.handler.UICommon.onGet(Unknown Source)
         at oracle.forms.engine.Runform.onGetHandler(Unknown Source)
         at oracle.forms.engine.Runform.processMessage(Unknown Source)
         at oracle.forms.engine.Runform.processSet(Unknown Source)
         at oracle.forms.engine.Runform.onMessageReal(Unknown Source)
         at oracle.forms.engine.Runform.onMessage(Unknown Source)
         at oracle.forms.engine.Runform.processEventEnd(Unknown Source)
         at oracle.ewt.lwAWT.LWComponent.redispatchEvent(Unknown Source)
         at oracle.ewt.lwAWT.LWComponent.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Window.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)
    Dynamic libraries:
    0x00400000 - 0x00419000      C:\Program Files\Internet Explorer\IEXPLORE.EXE
    0x77F50000 - 0x77FF7000      C:\WINNT\System32\ntdll.dll
    0x77E60000 - 0x77F46000      C:\WINNT\system32\kernel32.dll
    0x77C10000 - 0x77C63000      C:\WINNT\system32\msvcrt.dll
    0x77D40000 - 0x77DCC000      C:\WINNT\system32\USER32.dll
    0x77C70000 - 0x77CB0000      C:\WINNT\system32\GDI32.dll
    0x77DD0000 - 0x77E5D000      C:\WINNT\system32\ADVAPI32.dll
    0x78000000 - 0x78086000      C:\WINNT\system32\RPCRT4.dll
    0x70A70000 - 0x70AD5000      C:\WINNT\system32\SHLWAPI.dll
    0x71700000 - 0x71849000      C:\WINNT\System32\SHDOCVW.dll
    0x71950000 - 0x71A34000      C:\WINNT\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.10.0_x-ww_f7fb5805\comctl32.dll
    0x773D0000 - 0x77BC2000      C:\WINNT\system32\SHELL32.dll
    0x77340000 - 0x773CB000      C:\WINNT\system32\comctl32.dll
    0x771B0000 - 0x772D1000      C:\WINNT\system32\ole32.dll
    0x74720000 - 0x74764000      C:\WINNT\System32\MSCTF.dll
    0x71500000 - 0x715FD000      C:\WINNT\System32\BROWSEUI.dll
    0x72430000 - 0x72442000      C:\WINNT\System32\browselc.dll
    0x75F40000 - 0x75F5F000      C:\WINNT\system32\appHelp.dll
    0x76FD0000 - 0x77048000      C:\WINNT\System32\CLBCATQ.DLL
    0x77120000 - 0x771AB000      C:\WINNT\system32\OLEAUT32.dll
    0x77050000 - 0x77115000      C:\WINNT\System32\COMRes.dll
    0x77C00000 - 0x77C07000      C:\WINNT\system32\VERSION.dll
    0x76670000 - 0x76757000      C:\WINNT\System32\SETUPAPI.dll
    0x5AD70000 - 0x5ADA4000      C:\WINNT\System32\UxTheme.dll
    0x63000000 - 0x63096000      C:\WINNT\system32\WININET.dll
    0x762C0000 - 0x76348000      C:\WINNT\system32\CRYPT32.dll
    0x762A0000 - 0x762B0000      C:\WINNT\system32\MSASN1.dll
    0x76F90000 - 0x76FA0000      C:\WINNT\System32\Secur32.dll
    0x10000000 - 0x1012D000      c:\program files\google\googletoolbar1.dll
    0x1A400000 - 0x1A47A000      C:\WINNT\system32\urlmon.dll
    0x71AD0000 - 0x71AD8000      C:\WINNT\System32\WSOCK32.dll
    0x71AB0000 - 0x71AC5000      C:\WINNT\System32\WS2_32.dll
    0x71AA0000 - 0x71AA8000      C:\WINNT\System32\WS2HELP.dll
    0x76C30000 - 0x76C5B000      C:\WINNT\System32\WINTRUST.dll
    0x76C90000 - 0x76CB2000      C:\WINNT\system32\IMAGEHLP.dll
    0x76B40000 - 0x76B6C000      C:\WINNT\System32\WINMM.dll
    0x76380000 - 0x76385000      C:\WINNT\System32\MSIMG32.dll
    0x6D510000 - 0x6D58D000      C:\WINNT\System32\DBGHELP.DLL
    0x71C20000 - 0x71C6E000      C:\WINNT\System32\netapi32.dll
    0x71B20000 - 0x71B31000      C:\WINNT\system32\MPR.dll
    0x75F60000 - 0x75F66000      C:\WINNT\System32\drprov.dll
    0x71C10000 - 0x71C1D000      C:\WINNT\System32\ntlanman.dll
    0x71CD0000 - 0x71CE6000      C:\WINNT\System32\NETUI0.dll
    0x71C90000 - 0x71CCC000      C:\WINNT\System32\NETUI1.dll
    0x71C80000 - 0x71C86000      C:\WINNT\System32\NETRAP.dll
    0x71BF0000 - 0x71C01000      C:\WINNT\System32\SAMLIB.dll
    0x76EE0000 - 0x76F17000      C:\WINNT\System32\RASAPI32.DLL
    0x76E90000 - 0x76EA1000      C:\WINNT\System32\rasman.dll
    0x76EB0000 - 0x76EDB000      C:\WINNT\System32\TAPI32.dll
    0x76E80000 - 0x76E8D000      C:\WINNT\System32\rtutils.dll
    0x75F70000 - 0x75F79000      C:\WINNT\System32\davclnt.dll
    0x722B0000 - 0x722B5000      C:\WINNT\System32\sensapi.dll
    0x75A70000 - 0x75B15000      C:\WINNT\system32\USERENV.dll
    0x76990000 - 0x769B4000      C:\WINNT\System32\ntshrui.dll
    0x76B20000 - 0x76B35000      C:\WINNT\System32\ATL.DLL
    0x76170000 - 0x761F8000      C:\WINNT\System32\shdoclc.dll
    0x74770000 - 0x747FF000      C:\WINNT\System32\mlang.dll
    0x63580000 - 0x63830000      C:\WINNT\System32\mshtml.dll
    0x75E90000 - 0x75F37000      C:\WINNT\System32\SXS.DLL
    0x6B700000 - 0x6B790000      C:\WINNT\System32\jscript.dll
    0x746F0000 - 0x74716000      C:\WINNT\System32\msimtf.dll
    0x746C0000 - 0x746E7000      C:\WINNT\System32\MSLS31.DLL
    0x76390000 - 0x763AC000      C:\WINNT\System32\IMM32.DLL
    0x76620000 - 0x7666E000      C:\WINNT\System32\cscui.dll
    0x76600000 - 0x7661B000      C:\WINNT\System32\CSCDLL.dll
    0x325C0000 - 0x325D2000      C:\Program Files\Office2003\OFFICE11\msohev.dll
    0x71A50000 - 0x71A8B000      C:\WINNT\system32\mswsock.dll
    0x71A90000 - 0x71A98000      C:\WINNT\System32\wshtcpip.dll
    0x76F20000 - 0x76F45000      C:\WINNT\System32\DNSAPI.dll
    0x76FB0000 - 0x76FB7000      C:\WINNT\System32\winrnr.dll
    0x76F60000 - 0x76F8C000      C:\WINNT\system32\WLDAP32.dll
    0x02C70000 - 0x02C83000      C:\Program Files\Labtec\Labtec Mouse Software\2.0\MOUDL32A.DLL
    0x76FC0000 - 0x76FC5000      C:\WINNT\System32\rasadhlp.dll
    0x6D350000 - 0x6D35D000      C:\Program Files\Oracle\JInitiator 1.3.1.18\bin\npjinit13118.dll
    0x6D130000 - 0x6D15B000      C:\Program Files\Oracle\JInitiator 1.3.1.18\bin\beans.ocx
    0x6D300000 - 0x6D316000      C:\Program Files\Oracle\JInitiator 1.3.1.18\bin\jpishare.dll
    0x6D3F0000 - 0x6D4C7000      C:\PROGRA~1\Oracle\JINITI~1.18\bin\hotspot\jvm.dll
    0x6D220000 - 0x6D227000      C:\PROGRA~1\Oracle\JINITI~1.18\bin\hpi.dll
    0x6D380000 - 0x6D38D000      C:\PROGRA~1\Oracle\JINITI~1.18\bin\verify.dll
    0x6D250000 - 0x6D268000      C:\PROGRA~1\Oracle\JINITI~1.18\bin\java.dll
    0x6D390000 - 0x6D39D000      C:\PROGRA~1\Oracle\JINITI~1.18\bin\zip.dll
    0x6D020000 - 0x6D12B000      C:\Program Files\Oracle\JInitiator 1.3.1.18\bin\awt.dll
    0x73000000 - 0x73023000      C:\WINNT\System32\WINSPOOL.DRV
    0x6D1E0000 - 0x6D21C000      C:\Program Files\Oracle\JInitiator 1.3.1.18\bin\fontmanager.dll
    0x5ED00000 - 0x5EDC6000      C:\WINNT\System32\OPENGL32.dll
    0x68B20000 - 0x68B3E000      C:\WINNT\System32\GLU32.dll
    0x73760000 - 0x737A4000      C:\WINNT\System32\DDRAW.dll
    0x73BC0000 - 0x73BC6000      C:\WINNT\System32\DCIMAN32.dll
    0x0DD70000 - 0x0DFA2000      C:\WINNT\System32\ialmgicd.dll
    0x0DFB0000 - 0x0E02B000      C:\WINNT\System32\ialmgdev.dll
    0x6D340000 - 0x6D348000      C:\Program Files\Oracle\JInitiator 1.3.1.18\bin\net.dll
    0x0FFA0000 - 0x0FFC1000      C:\WINNT\System32\dssenh.dll
    0x6D370000 - 0x6D37A000      C:\Program Files\Oracle\JInitiator 1.3.1.18\bin\packager.dll
    0x0E860000 - 0x0E870000      C:\Program Files\Oracle\JInitiator 1.3.1.18\bin\JNIsharedstubs.dll
    0x76BF0000 - 0x76BFB000      C:\WINNT\System32\PSAPI.DLL
    Local Time = Tue Aug 29 08:53:29 2006
    Elapsed Time = 4
    # The exception above was detected in native code outside the VM
    # Java VM: Java HotSpot(TM) Client VM (1.3.1_04-b02 mixed mode)
    #

  • WEBUTIL_C_API Demo Form

    A number of people have asked me about WEBUTIL_C_API, and I have offered to contribute a simple form that demonstrates how one can use this built-in to access the Windows API.
    I have prepared a reasonably simple and straight-forward example, but I am still writing up instructions. I expect to have the demo completed this weekend -- I will post a URL for downloading it, at that time. Please follow this thread for further information.
    Thanks,
    Eric Adamson
    Lansing, Michigan

    Francois,
    I've placed an updated version of apiwrap.dll & apiwrap.pll at the following URL:
    http://www.ericadamson.com/code_samples/oracle_forms/apiwrap.zip
    The PLL was created using 10.1.2.0.2 -- users with previous versions will probably need to build apiwrap.pll for themselves. For portability, I've also included the APIWRAP package spec & body as simple text files. Note that apiwrap.pll requires webutil.pll -- don't forget to attach it before compiling!
    To save time, this version comes undocumented, but I'm sure you will have no problem figuring everything out! :) For others interested in experimenting with this code, please:
    1. Be certain that WebUtil is installed on your app server or OC4J, and functioning correctly
    2. Know how to build a WebUtil-enabled form.
    3. Know how to compile apiwrap.pll (web forms require PLX's!)
    4. Understand how WebUtil copies native DLL's to the client (read <forms_home>\forms\server\webutil.cfg for details)
    5. Study the APIWRAP package spec for usage information and helpful constants
    6. Refer to the Windows SDK documentation for information on the underlying API calls, FindWindow, ShowWindow, SetWindowText & SetWindowPos. For those who lack Windows SDK documentation, visit http://msdn.microsoft.com and search for the desired function by name, either from the main page, or from the MSDN Library.
    Thanks,
    Eric Adamson
    Lansing, Michigan

  • WEBUTIL_C_API.REBIND_PARAMETER not working

    Dear All,
    I am using 11g forms Version 11.1.1.2.0, and facing the problem
    oracle.forms.webutil.cApi.CApiFunctions bean not found.
    WEBUTIL_C_API.REBIND_PARAMETER will not work
    when i acknowldege OK butten then follwoing alert is populate
    Internal Error: PL/SQL error occurred.
    can any one help me out to resolve the problem.
    Thanx in advance.
    Sohail

    Hi.
    Take a look at: http://www.orafaq.com/forum/t/74615/2/
    and
    oracle.forms.webutil.CApiFunctions bean not found.

  • A problem with threads

    I am trying to implement some kind of a server listening for requests. The listener part of the app, is a daemon thread that listens for connections and instantiates a handling daemon thread once it gets some. However, my problem is that i must be able to kill the listening thread at the user's will (say via a sto button). I have done this via the Sun's proposed way, by testing a boolean flag in the loop, which is set to false when i wish to kill the thread. The problem with this thing is the following...
    Once the thread starts excecuting, it will test the flag, find it true and enter the loop. At some point it will LOCK on the server socket waiting for connection. Unless some client actually connects, it will keep on listening indefinatelly whithought ever bothering to check for the flag again (no matter how many times you set the damn thing to false).
    My question is this: Is there any real, non-theoretical, applied way to stop thread in java safely?
    Thank you in advance,
    Lefty

    This was one solution from the socket programming forum, have you tried this??
    public Thread MyThread extends Thread{
         boolean active = true;          
         public void run(){
              ss.setSoTimeout(90);               
              while (active){                   
                   try{                       
                        serverSocket = ss.accept();
                   catch (SocketTimeoutException ste){
                   // do nothing                   
         // interrupt thread           
         public void deactivate(){               
              active = false;
              // you gotta sleep for a time longer than the               
              // accept() timeout to make sure that timeout is finished.               
              try{
                   sleep(91);               
              }catch (InterruptedException ie){            
              interrupt();
    }

  • A problem with Threads and MMapi

    I am tring to execute a class based on Game canvas.
    The problem begin when I try to Play both a MIDI tone and to run an infinit Thread loop.
    The MIDI tone "Stammers".
    How to over come the problem?
    Thanks in advance
    Kobi
    See Code example below:
    import java.io.IOException;
    import java.io.InputStream;
    import javax.microedition.lcdui.Graphics;
    import javax.microedition.lcdui.Image;
    import javax.microedition.lcdui.game.GameCanvas;
    import javax.microedition.media.Manager;
    import javax.microedition.media.MediaException;
    import javax.microedition.media.Player;
    public class MainScreenCanvas extends GameCanvas implements Runnable {
         private MainMIDlet parent;
         private boolean mTrucking = false;
         Image imgBackgound = null;
         int imgBackgoundX = 0, imgBackgoundY = 0;
         Player player;
         public MainScreenCanvas(MainMIDlet parent)
              super(true);
              this.parent = parent;
              try
                   imgBackgound = Image.createImage("/images/area03_bkg0.png");
                   imgBackgoundX = this.getWidth() - imgBackgound.getWidth();
                   imgBackgoundY = this.getHeight() - imgBackgound.getHeight();
              catch(Exception e)
                   System.out.println(e.getMessage());
          * starts thread
         public void start()
              mTrucking = true;
              Thread t = new Thread(this);
              t.start();
          * stops thread
         public void stop()
              mTrucking = false;
         public void play()
              try
                   InputStream is = getClass().getResourceAsStream("/sounds/scale.mid");
                   player = Manager.createPlayer(is, "audio/midi");
                   player.setLoopCount(-1);
                   player.prefetch();
                   player.start();
              catch(Exception e)
                   System.out.println(e.getMessage());
         public void run()
              Graphics g = getGraphics();
              play();
              while (true)
                   tick();
                   input();
                   render(g);
          * responsible for object movements
         private void tick()
          * response to key input
         private void input()
              int keyStates = getKeyStates();
              if ((keyStates & LEFT_PRESSED) != 0)
                   imgBackgoundX++;
                   if (imgBackgoundX > 0)
                        imgBackgoundX = 0;
              if ((keyStates & RIGHT_PRESSED) != 0)
                   imgBackgoundX--;
                   if (imgBackgoundX < this.getWidth() - imgBackgound.getWidth())
                        imgBackgoundX = this.getWidth() - imgBackgound.getWidth();
          * Responsible for the drawing
          * @param g
         private void render(Graphics g)
              g.drawImage(imgBackgound, imgBackgoundX, imgBackgoundY, Graphics.TOP | Graphics.LEFT);
              this.flushGraphics();
    }

    You can also try to provide a greater Priority to your player thread so that it gains the CPU time when ever it needs it and don't harm the playback.
    However a loop in a Thread and that to an infinite loop is one kind of very bad programming, 'cuz the loop eats up most of your CPU time which in turn adds up more delays of the execution of other tasks (just as in your case it is the playback). By witting codes bit efficiently and planning out the architectural execution flow of the app before start writing the code helps solve these kind of issues.
    You can go through [this simple tutorial|http://oreilly.com/catalog/expjava/excerpt/index.html] about Basics of Java and Threads to know more about threads.
    Regds,
    SD
    N.B. And yes there are more articles and tutorials available but much of them targets the Java SE / EE, but if you want to read them here is [another great one straight from SUN|http://java.sun.com/docs/books/tutorial/essential/concurrency/index.html] .
    Edited by: find_suvro@SDN on 7 Nov, 2008 12:00 PM

  • J2ME problem with threads

    Hi all,
    I would like to ask you for a help. I need to write a small program at my university. I started to write a midlet which function would be to countdown time for sports activities. I woul like to start a new thread - the one that counts down - and at the same time make the main thread sleep. After the "countdown" thread finishes, the main thread wakes up and waits for user input. The problem is that when the "countdown" thread finishes his work, I've got Uncaught exception java/lang/NullPointerException. error and the midlet halts.
    Below you can find the code
    import java.lang.*;
    import java.util.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;
    public class intervals extends MIDlet implements CommandListener
    public Display ekran;
    private SweepCanvas sweeper;
    private Form rundy;
    private TextField round0, round1, round2, round3, round4, round5, round6, round7, round8;
    private long czas,x;
    private Command exitCommand;
    private Command addRound;
    private Command delRound;
    private Command start;
    private TextField repeat;
    private Form odliczanie;
    private Alert ostrz;
    Licznik thread;
    String test;
    StringItem test1;
    int parz,i,j,k;
    static int l;
    int ilrund;
    int ilpowt;
    Item sec;
    long sec1;
    public intervals()
        rundy = new Form("Interwa&#322;y sportowe");
        exitCommand = new Command("Wyj&#347;cie", Command.EXIT, 2);
        addRound = new Command("Dodaj","Dodaj rund&#281;", Command.ITEM,1);
        delRound = new Command("Usu&#324;","Usu&#324; ostatni&#261; rund&#281;", Command.ITEM,1);
        start = new Command("Start", Command.ITEM,1);
        odliczanie = new Form("Odliczanie");
        TextField dodaj(TextField kolej)
            kolej=new TextField("Podaj czas (s) rundy "+parz,null, 4, TextField.NUMERIC);//stworzenie nowej instancji do wybierania czasu trwania rundy
            if(rundy.size()==0)
                rundy.insert(rundy.size(),kolej);
                else
                    rundy.insert(rundy.size()-1, kolej);
            return kolej;
        void odliczanie(TextField round)
            monitor m=new monitor();
            k=Integer.parseInt(round.getString());
            ekran.setCurrent(odliczanie);
            thread=new Licznik(k,odliczanie);
            thread.start();
            ekran.setCurrent(rundy);
    public void startApp()// throws MIDletStateChangeException
        rundy.deleteAll();
        repeat = new TextField("Podaj ilo&#347;&#263; powtórze&#324;",null,1,TextField.NUMERIC);
        rundy.addCommand(addRound);
        rundy.addCommand(exitCommand);
        rundy.setCommandListener(this);
        Canvas obrazek = new MyCanvas();
        ekran = Display.getDisplay(this);
        ekran.setCurrent(obrazek);
        czas=System.currentTimeMillis();
        while (System.currentTimeMillis()<czas+1000)
            continue;
        ekran.setCurrent(rundy);
    public void pauseApp()
    public void destroyApp(boolean unconditional)
        notifyDestroyed();
    public void commandAction(Command c, Displayable s)
        if (c == exitCommand)
            destroyApp(false);
            notifyDestroyed();
        else if(c==addRound)
            if(rundy.size()==0)//Sprawdzenie ilo&#347;ci elementów w celu poprawnego wy&#347;wietlania liczby rund w formie
                parz=1;
                else
                parz=rundy.size();
            switch(parz)
                case 1:
                    round0=dodaj(round0);break;
                case 2:
                    round1=dodaj(round1);break;
                case 3:
                   round2= dodaj(round2);break;
                case 4:
                    round3=dodaj(round3);break;
                case 5:
                    round4=dodaj(round4);break;
                default:
                    ostrz=new Alert("Uwaga","Maksymalna liczba rund wynosi 9", null, AlertType.INFO);
                    ostrz.setTimeout(3000);
                    ekran.setCurrent(ostrz);
            if(rundy.size()==1)
                rundy.append(repeat);
                rundy.addCommand(start);
            rundy.addCommand(delRound);
        else if(c==delRound)
            if(rundy.size()!=0)
                rundy.delete(rundy.size()-2);
                if (rundy.size()==1)
                    rundy.deleteAll();
                if(rundy.size()==0)
                    rundy.removeCommand(delRound);
                    rundy.removeCommand(start);
        else if(c==start)
            ilrund=rundy.size()-1;
            if(this.repeat.size()>0)
                ilpowt=Integer.parseInt(this.repeat.getString());
            ekran = Display.getDisplay(this);
            for (i=1; i<=ilpowt;i++)
                odliczanie= new Form("Odliczanie");
                 for (j=0;j<ilrund;j++)
                    switch(j)
                         case 0:
                             odliczanie(round0);
                             break;
                         case 1:
                             odliczanie(round1);
                             break;
                         case 2:
                             odliczanie(round2);
                             break;
                         case 3:
                             odliczanie(round3);
                             break;
                         case 4:
                             odliczanie(round4);
                             break;
                         case 5:
                             odliczanie(round5);
                             break;
                         case 6:
                             odliczanie(round6);
                             break;
                         case 7:
                             odliczanie(round7);
                             break;
                         case 8:
                             odliczanie(round8);
                             break;
    class Licznik extends Thread
        int czas1,k;
        Form forma;
        monitor m;
        public Licznik(int k,Form formap)
            czas1=k;
            forma=formap;
        public synchronized void run()
            while(czas1>0)
                forma.deleteAll();
                forma.append("Czas pozosta&#322;y (s): "+czas1);
                try{Thread.sleep(1000);} catch(InterruptedException e){e.printStackTrace();}
                czas1--;
            if(czas1<=0)
                m.put();
        }and monitor class
    public class monitor
    boolean busy=false;
    synchronized void get()
        if(!busy)
            try
                wait();
            }catch(InterruptedException e){e.printStackTrace();}
        notify();
    synchronized void put()
        if(busy)
            try
            wait();
            }catch(InterruptedException e){e.printStackTrace();}
        busy=true;
        notify();
    }Can anybody help me with this?

    Groovemaker,
    Your Licznik class has a member m of type monitor, which has not been instantiated (in other words is null) hence, when calling m.put() you get NullPointerException. Please also mind, that using Thread.sleep(1000) is not an accurate way of measuring time.
    If I may, please use recommended for Java class naming conventions - some of your names use lower case, while other don't which is confusing to the reader.
    Daniel

  • Problem with threads within applet

    Hello,
    I got an applet, inside this applet I have a singleton, inside this singleton I have a thread.
    this thread is running in endless loop.
    he is doing something and go to sleep on and on.
    the problem is,
    when I refresh my IE6 browser I see more than 1 thread.
    for debug matter, I did the following things:
    inside the thread, sysout every time he goes to sleep.
    sysout in the singleton constructor.
    sysout in the singleton destructor.
    the output goes like this:
    when refresh the page, the singleton constructor loading but not every refresh, sometimes I see the constructor output and sometimes I dont.
    The thread inside the singleton is giving me the same output, sometime I see more than one thread at a time and sometimes I dont.
    The destructor never works (no output there).
    I don't understand what is going on.
    someone can please shed some light?
    thanks.
    btw. I am working with JRE 1.1
    this is very old and big applet and I can't convert it to something new.

    Ooops. sorry!
    I did.
         public void start() {
         public void stop() {
         public void destroy() {
              try {
                   resetAll();
                   Configuration.closeConnection();
                   QuoteItem.closeConnection();
              } finally {
                   try {
                        super.finalize();
                   } catch (Throwable e) {
                        e.printStackTrace();
         }

  • Problem with Threads and a static variable

    I have a problem with the code below. I am yet to make sure that I understand the problem. Correct me if I am wrong please.
    Code functionality:
    A timer calls SetState every second. It sets the state and sets boolean variable "changed" to true. Then notifies a main process thread to check if the state changed to send a message.
    The problem as far I understand is:
    Assume the timer Thread calls SetState twice before the main process Thread runs. As a result, "changed" is set to true twice. However, since the main process is blocked twice during the two calls to SetState, when it runs it would have the two SetState timer threads blocked on its synchronized body. It will pass the first one, send the message and set "changed" to false since it was true. Now, it will pass the second thread, but here is the problem, "changed" is already set to false. As a result, it won't send the message even though it is supposed to.
    Would you please let me know if my understanding is correct? If so, what would you propose to resolve the problem? Should I call wait some other or should I notify in a different way?
    Thanks,
    B.D.
    Code:
    private static volatile boolean bChanged = false;
    private static Thread objMainProcess;
       protected static void Init(){
            objMainProcess = new Thread() {
                public void run() {
                    while( objMainProcess == Thread.currentThread() ) {
                       GetState();
            objMainProcess.setDaemon( true );
            objMainProcess.start();
        public static void initStatusTimer(){
            if(objTimer == null)
                 objTimer = new javax.swing.Timer( 1000, new java.awt.event.ActionListener(){
                    public void actionPerformed( java.awt.event.ActionEvent evt){
                              SetState();
        private static void SetState(){
            if( objMainProcess == null ) return;
            synchronized( objMainProcess ) {
                bChanged = true;
                try{
                    objMainProcess.notify();
                }catch( IllegalMonitorStateException e ) {}
        private static boolean GetState() {
            if( objMainProcess == null ) return false;
            synchronized( objMainProcess ) {
                if( bChanged) {
                    SendMessage();
                    bChanged = false;
                    return true;
                try {
                    objMainProcess.wait();
                }catch( InterruptedException e ) {}
                return false;
        }

    Thanks DrClap for your reply. Everything you said is right. It is not easy to make them alternate since SetState() could be called from different places where the state could be anything else but a status message. Like a GREETING message for example. It is a handshaking message but not a status message.
    Again as you said, There is a reason I can't call sendMessage() inside setState().
    The only way I was able to do it is by having a counter of the number of notifies that have been called. Every time notify() is called a counter is incremented. Now instead of just checking if "changed" flag is true, I also check if notify counter is greater than zero. If both true, I send the message. If "changed" flag is false, I check again if the notify counter is greater than zero, I send the message. This way it works, but it is kind of a patch than a good design fix. I am yet to find a good solution.
    Thanks,
    B.D.

  • Problem with threads running javaw

    Hi,
    Having a problem with multi thread programming using client server sockets. The program works find when starting the the application in a console using java muti.java , but when using javaw multi.java the program doesnt die and have to kill it in the task manager. The program doesnt display any of my gui error messages either when the server disconnect the client. all works find in a console. any advice on this as I havent been able to understand why this is happening? any comment would be appreciated.
    troy.

    troy,
    Try and post a minimum code sample of your app which
    does not work.
    When using javaw, make sure you redirect the standard
    error and standard output streams to file.
    Graeme.Hi Graeme,
    I dont understand what you mean by redirection to file? some of my code below.
    The code works fine under a console, code is supposed to exit when the client (the other server )disconnects. the problem is that but the clientworker side of the code still works. which under console it doesnt.
    public class Server{
    ServerSocket aServerSocket;
    Socket dianosticsSocket;
    Socket nPortExpress;
    ClientListener aClientListener;
    LinkedList queue = new LinkedList();
    int port = 0;
    int clientPort = 0;
    String clientName = null;
    boolean serverAlive = true;
    * Server constructor generates a server
    * Socket and then starts a client threads.
    * @param aPort      socket port of local machine.
    public Server(int aPort, String aClientName, int aClientPort){
    port = aPort;
    clientName = aClientName;
    clientPort = aClientPort;
    try{
    // create a new thread
    aServerSocket = new ServerSocket(port) ;
    // connect to the nPortExpress
    aClientListener = new ClientListener(InetAddress.getByName(clientName), clientPort, queue,this);
    // aClientListener.setDaemon(true);
    aClientListener.start();
    // start a dianostic port
    DiagnosticsServer aDiagnosticsServer = new DiagnosticsServer(port,queue,aClientListener);
    // System.out.println("Server is running on port " + port + "...");
    // System.out.println("Connect to nPort");
    catch(Exception e)
    // System.out.println("ERROR: Server port " + port + " not available");
    JOptionPane.showMessageDialog(null, (e.toString()),"ERROR: Server port " + port + " not available", JOptionPane.ERROR_MESSAGE);
    serverAlive = false;
    System.exit(1);
    while(serverAlive&&aClientListener.hostSocket.isConnected()){
    try{
    // connect the client
    Socket aClient = aServerSocket.accept();
    //System.out.println("open client connection");
    //System.out.println("client local: "+ aClient.getLocalAddress().toString());
    // System.out.println("client localport: "+ aClient.getLocalPort());
    // System.out.println("client : "+ aClient.getInetAddress().toString());
    // System.out.println("client port: "+ aClient.getLocalPort());
    // make a new client thread
    ClientWorker clientThread = new ClientWorker(aClient, queue, aClientListener, false);
    // start thread
    clientThread.start();
    catch(Exception e)
    //System.out.println("ERROR: Client connection failure");
    JOptionPane.showMessageDialog(null, (e.toString()),"ERROR: Client connection failure", JOptionPane.ERROR_MESSAGE);
    }// end while
    } // end constructor Server
    void serverExit(){
         JOptionPane.showMessageDialog(null, "Server ","ERROR: nPort Failure", JOptionPane.ERROR_MESSAGE);
         System.exit(1);
    }// end class Server
    *** connect to another server
    public class ClientListener extends Thread{
    InetAddress hostName;
    int hostPort;
    Socket hostSocket;
    BufferedReader in;
    PrintWriter out;
    boolean loggedIn;
    LinkedList queue;      // reference to Server queue
    Server serverRef; // reference to main server
    * ClientListener connects to the host server.
    * @param aHostName is the name of the host eg server name or IP address.
    * @param aHostPort is a port number of the host.
    * @param aLoginName is the users login name.
    public ClientListener(InetAddress aHostName, int aHostPort,LinkedList aQueue,Server aServer)      // reference to Server queue)
    hostName = aHostName;
    hostPort = aHostPort;
    queue = aQueue;
    serverRef = aServer;      
    // connect to the server
    try{
    hostSocket = new Socket(hostName, hostPort);
    catch(IOException e){
    //System.out.println("ERROR: Connection Host Failed");
    JOptionPane.showMessageDialog(null, (e.toString()),"ERROR: Connection to nPort Failed", JOptionPane.ERROR_MESSAGE);     
    System.exit(0);
    } // end constructor ClientListener
    ** multi client connection server
    ClientWorker(Socket aSocket,LinkedList aQueue, ClientListener aClientListener, boolean diagnostics){
    queue = aQueue;
    addToQueue(this);
    client = aSocket;
    clientRef = aClientListener;
    aDiagnostic = diagnostics;
    } // end constructor ClientWorker
    * run method is the main loop of the server program
    * in change of handle new client connection as well
    * as handle all messages and errors.
    public void run(){
    boolean alive = true;
    String aSubString = "";
    in = null;
    out = null;
    loginName = "";
    loggedIn = false;
    while (alive && client.isConnected()&& clientRef.hostSocket.isConnected()){
    try{
    in = new BufferedReader(new InputStreamReader(client.getInputStream()));
    out = new PrintWriter(new OutputStreamWriter(client.getOutputStream()));
    if(aDiagnostic){
    out.println("WELCOME to diagnostics");
    broadCastDia("Connect : diagnostics "+client.getInetAddress().toString());
    out.flush();
    else {       
    out.println("WELCOME to Troy's Server");
    broadCastDia("Connect : client "+client.getInetAddress().toString());
         out.flush();
    String line;
    while(((line = in.readLine())!= null)){
    StringTokenizer aStringToken = new StringTokenizer(line, " ");
    if(!aDiagnostic){
    broadCastDia(line);
    clientRef.sendMessage(line); // send mesage out to netExpress
    out.println(line);
    out.flush();
    else{
    if(line.equals("GETIPS"))
    getIPs();
    else{
    clientRef.sendMessage(line); // send mesage out to netExpress
    out.println(line);
    out.flush();
    } // end while
    catch(Exception e){
    // System.out.println("ERROR:Client Connection reset");
                             JOptionPane.showMessageDialog(null, (e.toString()),"ERROR:Client Connection reset", JOptionPane.ERROR_MESSAGE);     
    try{
    if(aDiagnostic){
    broadCastDia("Disconnect : diagnostics "+client.getInetAddress().toString());
    out.flush();
    else {       
    broadCastDia("Disconnect : client "+client.getInetAddress().toString());
         out.flush();
    // close the buffers and connection;
    in.close();
    out.close();
    client.close();
    // System.out.println("out");
    // remove from list
    removeThreadQueue(this);
    alive = false;
    catch(Exception e){
    // System.out.println("ERROR: Client Connection reset failure");
    JOptionPane.showMessageDialog(null, (e.toString()),"ERROR: Client Connection reset failure", JOptionPane.ERROR_MESSAGE);     
    }// end while
    } // end method run
    * method run - Generates io stream for communicating with the server and
    * starts the client gui. Run also parses the input commands from the server.
    public void run(){
    boolean alive = true;
    try{
    // begin to life the gui
    // aGuiClient = new ClientGui(hostName.getHostName(), hostPort, loginName, this);
    // aGuiClient.show();
    in = new BufferedReader(new InputStreamReader(hostSocket.getInputStream()));
    out = new PrintWriter(new OutputStreamWriter(hostSocket.getOutputStream()));
    while (alive && hostSocket.isConnected()){
    String line;
    while(((line = in.readLine())!= null)){
    System.out.println(line);
    broadCast(line);
    } // end while
    } // end while
    catch(Exception e){
    //     System.out.println("ERRORa Connection to host reset");
    JOptionPane.showMessageDialog(null, (e.toString()),"ERROR: Connection to nPort reset", JOptionPane.ERROR_MESSAGE);
    try{
    hostSocket.close();
         }catch(Exception a){
         JOptionPane.showMessageDialog(null, (a.toString()),"ERROR: Exception", JOptionPane.ERROR_MESSAGE);
    alive = false;
    System.exit(1);
    } // end method run

Maybe you are looking for