daust / JasperReportsIntegration

JasperReportsIntegration provides an interface to use the JasperReports reporting engine in an Oracle database application, specifically with Oracle Application Express (Oracle APEX).
BSD 3-Clause "New" or "Revised" License
55 stars 23 forks source link

Issue with PDF download - network error #92

Closed octavarium12 closed 2 years ago

octavarium12 commented 2 years ago

Hi I am using Jasperreportsintegration 2.7 with cloud database , I cant download pdf to my pc or mobile . Its Failed -network error problem. I tried different browser. When I turn option in Jasper Procedure to download PDF without preview than I have no problem. Only when downloading from preview window. How to debug this problem Thanks

daust commented 2 years ago

More details, please. What is the exact error? Screenshot?

When you open the developer toolbar in the browser you can get more details. image

octavarium12 commented 2 years ago

More details, please. What is the exact error? Screenshot?

When you open the developer toolbar in the browser you can get more details. image @daust Thanks for info, I captured this : screen2 When i click to download pdf to my pc i got this error snipe1

This is my built in process code in Apex:

declare
  l_additional_parameters varchar2(5000);
  verija number;
begin
utl_http.set_wallet('');
  -- set the url for the j2ee application
  -- better retrieve that from a configuration table
  bmt.xlib_jasperreports.set_report_url('https://ccc.com/jri/report');

 l_additional_parameters := 'p_p='||apex_util.url_encode(:P226_NEW_11);

  bmt.xlib_jasperreports.show_report (p_rep_name => 'report123',

                             p_rep_format => 'pdf',  
                                  p_data_source => 'default',  
                                --  p_rep_locale => 'en_US',  
                              --    p_rep_encoding => 'UTF-8',
                      --  p_out_filename        => 'Karton_radnika.pdf',

                      -- p_save_is_enabled  =>  true,
                         --  p_save_filename      =>  'testt'        
                                  p_additional_params => l_additional_parameters
                                  );

  -- stop rendering of the current APEX page
  apex_application.g_unrecoverable_error := true;

end;

I can preview PDF but cant download it.

daust commented 2 years ago

Hi,

a quick search on google (or DuckDuckGo for that matter ;) leads to antivirus software blocking it locally on your PC: https://duckduckgo.com/?q=browser+download+%22Failed+-+Network+error%22&atb=v221-1&ia=web

Seems to be unrelated to JRI.

Can you try some of the suggestions ? Does it work?

Best ~Dietmar.

octavarium12 commented 2 years ago

@daust thanks for advice, I tried to disable antivirus, also I tried it on different pc - s and on mobile. Its same error on every device. I tried all browsers. Also direct downloading without preview is working so its not about folder or drive rights or policies. Its some strange bug , I had same problem on 2.4 version.

daust commented 2 years ago

Best to have a personal look at it. Please send me an email to dietmar.aust at opal-consulting.de, then we can schedule a zoom call.

octavarium12 commented 2 years ago

Sure, I will send e-mail. Thank you

daust commented 2 years ago

Hi @octavarium12,

I have tried your test case on my machine and the same error occurs. This is related to how Google Chrome PDF Viewer handles the file.

I could download the file and view it as a text file. In there, I could see the following APEX error:

ERR-7620 Could not determine workspace for application ().

This indicates that the built-in pdf viewer will issue a request ... but leaving out the parameters that are required for APEX. This confirms my assumption.

The workaround would be:

Anyhow, since the rendering in the before-header section already works for you ... I would go with option 1).

Best of luck ~Dietmar.

octavarium12 commented 2 years ago

Hi @daust . I use option 1, also I use redirect on another page with same logic for my direct printing from link on interactive reports. Mostly there is no need for my reports to be previewed before downloading and for those specific one this is solution. I will experiment more with PDF viewers and stuff. Should I close Issue now ?

Thank you for your time Haris.

daust commented 2 years ago

Yes, close the issue, please. Especially, since it is not related to the integration per se. It is an issue of how the internal pdf viewer in Google Chrome handles the pdf-"file", which is not really a file on the backend server but rather a post request.

Actually, you don't even have to use a separate page.

I often put it on the same page (so the application logic is not cluttered on too many pages) by making the rendering pl/sql process conditional to a certain request value, e.g. I use "RUN_REPORT" as an example. You can choose any kind of request variable that you want.

image

So the process will NOT be rendered initially.

Your submit button on will do nothing on the processing side. It will ONLY activate the branch, which will go to the SAME page (5) and issue the request RUN_REPORT: image

This time, the page will be re-rendered, and the process is being run because the condition is met this time.

This way, the application logic is on the same page and easy to understand.

Best ~Dietmar.

octavarium12 commented 2 years ago

@daust Yes but this is parameter form, I get empty report because parameter value is lost after I branch on same site.

daust commented 2 years ago

Sure, no big deal.

Just pass it along in the branch like you would always do it: image

octavarium12 commented 2 years ago

@daust I just tested it , it will not work with passing parameter on same form because it gets always same value from select list. The final solution which works for redirecting on same form:

  1. Set process before header , named it RUN_REPORT and did that server side condition that it fires only on REQUEST = RUN_REPORT
  2. On button redirect on same page without passing parameters in same form and without option to clear cache and reset pagination. On advanced request writing RUN_REPORT
  3. And on select list set dynamic action to set value to invisible parameter and to submit select list. So when page open , process RUN_REPORT will take selected parameter because cache is not cleared . Thank you for your advices and I will close the issue

Haris