Forum Stats

  • 3,752,074 Users
  • 2,250,455 Discussions
  • 7,867,708 Comments

Discussions

Different behavior between java-plugin and java-webstart

Thomas
Thomas Member Posts: 7 Blue Ribbon

Hello!

My Environment:

Oracle Forms 12.2.1.2.0

java-version 1.8.0_151

Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 


The issue;

This works with java-plugin (IE11) but not with java-webstart:

webutil_host.Blocking('cmd /c "dir C:\ > c:\xyz.txt"');

webutil_host.BLOCKING('cmd /c "dir C:\ > \"c:\xyz.txt\""');


There is a different behavior between java-plugin and java-webstart.

When I call "webutil_host,Blocking(...)" the java plugin executes the command.

The same command is not executed via java-webstart.

Annotation:

The Parameter "WebUtilNextGenHost" is set to "true"


Who knows an answer or can help me.

Thanks for your help...

Best Answer

  • Thomas
    Thomas Member Posts: 7 Blue Ribbon
    Accepted Answer

    Hello Michael!

    Thanks for the reply.

    We have submitted a request to Oracle Support.

    But there is currently no solution.


    I have programmed it differently now and it works with java-plugin and webstart.

    For information, here is my solution:

    ===============

    declare

     v_nslookup_out varchar2(1000);

     v_process_id   webutil_host.process_id;

     v_output_array webutil_host.output_array;

    begin+++++

     v_process_id   := webutil_Host.Blocking('cmd /c "dir C:\"';

     v_output_array := webutil_Host.Get_Standard_Output(v_process_id);

     for i in 1..v_output_array.count

     loop

      v_nslookup_out := v_nslookup_out || chr(10) || v_output_array(i); 

     end loop;  

     /*

     variable <v_nslookup_out> contains the Output;

     */

    end;

    ===============

Answers

  • Michael Ferrante-Oracle
    Michael Ferrante-Oracle Senior Principal Product Manager USMember Posts: 6,815 Employee

    Just tested in 12.2.1.4 (and nightly build) and it works as expected. Because there were numerous changes between the Forms version you are using it is possible that it may not work in the old version you have. Moving to 12.2.1.4 may become necessary.

    Something else to note though. There are changes to Java related to this beginning with 8u231+. Those changes are explained in the Java Release Notes for 8u231. Refer to the section that discusses "Runtime.exec and ProcessBuilder Argument Restrictions ". This is how Forms (WebUtil) does it under the hood.

    https://www.oracle.com/java/technologies/javase/8u231-relnotes.html#JDK-8221858

    So it looks like the code below is correct. Likely you are just missing the setting described in the Rel Notes.

    webutil_host.BLOCKING('cmd /c "dir C:\ > \"c:\xyz.txt\""');

    In the client side JRE settings, you'll need to add the following to the Runtime settings:

    -Djdk.lang.Process.allowAmbiguousCommands=true

    I believe this can be set as an applet parameter, but I have not tested. So I cannot guarantee that the applet parameter will work. I do, however know that setting it directly in the JRE does work.

    Also, the directory where you write the file must exist before trying to create the file. If not, the call will fail. You can use WebUtil to create the sub-directories as needed (and delete too).


  • Thomas
    Thomas Member Posts: 7 Blue Ribbon
    Accepted Answer

    Hello Michael!

    Thanks for the reply.

    We have submitted a request to Oracle Support.

    But there is currently no solution.


    I have programmed it differently now and it works with java-plugin and webstart.

    For information, here is my solution:

    ===============

    declare

     v_nslookup_out varchar2(1000);

     v_process_id   webutil_host.process_id;

     v_output_array webutil_host.output_array;

    begin+++++

     v_process_id   := webutil_Host.Blocking('cmd /c "dir C:\"';

     v_output_array := webutil_Host.Get_Standard_Output(v_process_id);

     for i in 1..v_output_array.count

     loop

      v_nslookup_out := v_nslookup_out || chr(10) || v_output_array(i); 

     end loop;  

     /*

     variable <v_nslookup_out> contains the Output;

     */

    end;

    ===============

  • Michael Ferrante-Oracle
    Michael Ferrante-Oracle Senior Principal Product Manager USMember Posts: 6,815 Employee

    @Thomas

    Glad you were able to get it working. Like I mentioned, I was not able to reproduce the original issue you mentioned. So that suggests a possible issue in the version you are using. Both 12.2.1.4 and nightly work as expected using Java 8u2281 and 8u291. That said, it should be noted that we are investigating a possible problem with the WEBUTIL.HOST calls that are being impacted by a change in 8u291. The change apparently is an update to a change that was implemented in 8u231. Details of the new change are in the 8u291 Release Notes. Again, we are working with the Java team to better understand the change and why it is changing some behavior in Forms 12.2.1.4 WebUtil HOST calls.

    https://www.oracle.com/java/technologies/javase/8u291-relnotes.html#JDK-8250568

    Regarding your work-around, thank you for sharing your code. I'm sure others will benefit from your solution. Depending on the use-case, I would say your solution is a better approach than the original. Writing the output to a file only to read its contents back in is expensive and time consuming.

    One comment about the code you shared though, setting your output variable to a size of 1000 likely will be too small in some cases. In the event it is too small, an ORA-06502 will be thrown. If it is the case where you don't know which directory will be scanned, I would recommend setting this to at least 4000. If using Forms 12.2.1.4, you can set it to 32767 because MAX_STRING_SIZE (FORMS_EXTENDED_STRING) is assumed by default to be enabled, therefore 32k is supported in .4 without any config changes. For version 12.2.1.0 - 12.2.1.3 set FORMS_EXTENDED_STRING=1

    Also to note is that this code will need to be modified if the directory being scanned is expected to include spaces.

    Your code re-posted here (with minor edits) for easier reading:

    declare
       v_rtn_out varchar2(32767);
       v_process_id  webutil_host.process_id;
       v_output_array webutil_host.output_array;
    begin
       v_process_id  := webutil_Host.Blocking('cmd /c "dir C:\Windows\"');
       v_output_array := webutil_Host.Get_Standard_Output(v_process_id);
       for i in 1..v_output_array.count loop
          v_rtn_out := v_rtn_out || chr(10) || v_output_array(i); 
       end loop; 
       -- Cleanup
        WEBUTIL_HOST.RELEASE_PROCESS (v_process_id);
       -- Display the output in a multi-line text field
       :HOST.DIROUT := v_rtn_out;
    
    end;