Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rest v2 html images / charts are not showing up #1

Open
zacharymarshal opened this issue Sep 10, 2013 · 24 comments
Open

Rest v2 html images / charts are not showing up #1

zacharymarshal opened this issue Sep 10, 2013 · 24 comments
Labels

Comments

@zacharymarshal
Copy link

Hi Mariano!

It has been a while, how are you doing?

I was trying out the new stuff using the rest_v2, and the images are coming back from the jasperserver looking like: /jasperserver-pro/rest_v2/reportExecutions/1448340476_1378856082848_7957/exports/html/attachments/img_0_0_55

I added a simple string replace to make them look like this, https://<server>:<port>/jasperserver-pro/rest_v2/reportExecutions/1448340476_1378856082848_7957/exports/html/attachments/img_0_0_55 but still no luck, resource not found.

Here is our version information

Product Edition: Enterprise
Features: Fusion AHD EXP DB AUD ANA MT
Product Version: 5.2.0
Build: 20130626_1922
License Type: Commercial
Expiration: 2014-06-28 16:59:00

Am I doing something wrong or maybe I need to go and re-request those from the server? Thanks so much for any help.

@thureos
Copy link

thureos commented Sep 23, 2013

Same here!

1 similar comment
@ghost
Copy link

ghost commented Sep 23, 2013

Same here!

@marianol
Copy link
Owner

Let me check on this. It looks like a bug in in the REST API. Can @thureos and @Cezario post the version of JRS that you are using?

@ghost
Copy link

ghost commented Sep 24, 2013

We both thureos and me are trying community version to see if it is the solution we are a searching for

@thureos
Copy link

thureos commented Sep 24, 2013

We are on ubuntu 13.04 x64, PHP 5.4.9, Using the bundled Tomcat server.

Thanks

@thureos
Copy link

thureos commented Sep 24, 2013

jasperimageshtml

@thureos
Copy link

thureos commented Sep 24, 2013

Product Version: 5.2.0
Build: 20130708_1615

@zacharymarshal
Copy link
Author

Hey Guys, I figured out a way to get the images to work. Check out my example here:

https://github.com/zacharyrankin/JasperReportsExamplePHP

Let me know if it works for you and if you have any issues. Mariano, could you take a look at what I did and tell me if this is "right practice" or if there is a bug in the rest v2.

Thanks

@thureos
Copy link

thureos commented Sep 24, 2013

Thanks Zachary,

I tried it out but we are not using SSL so I tried this (DEMO Accounts):

http://jasperadmin:jasperadmin@localhost:8080/jasperserver and no success

Also I tried with this POST request, which if I paste into my browser it indeed logs in automatically, but I cant get any response.

http://localhost:8080/jasperserver/j_spring_security_check?j_password=jasperadmin&j_password_pseudo=jasperadmin&j_username=jasperadmin&userLocale=en_US&userTimezone=America%2FChihuahua

By the way, you have a script pointing to your domain. I dont know if you care about it, just let you know.

Thanks so much!

@zacharymarshal
Copy link
Author

Thanks, I took it out and moved around the js to fix a weird error with jquery not being loaded yet.

Couple of questions:

  1. Did you update the 'report_url' to point to your report?
  2. Make sure you change "https://your_username:your_password@jasper.yourdomain.com:8443/jasperserver/" to "http://jasperadmin:jasperadmin@localhost:8080/jasperserver/", slashes might be important there, in both report.php and report_asset.php.
  3. Open up the console in your browser, are you getting any errors or is php throwing any errors / exceptions?

Thanks for trying it out. I am no expert on the jasper side of things, this was just how I was able to get it to work on my localhost.

This is what you should see
screen shot 2013-09-24 at 2 53 01 pm

@thureos
Copy link

thureos commented Sep 24, 2013

Sure, I changed both url and report URI

I dont have that report unit in my jasper server.
I use this as test. /root/Reports/Samples/Gato and /Reports/Samples/Gato
screenshot from 2013-09-24 16 03 14
And got this.
screenshot from 2013-09-24 16 03 44

Thanks again!

@zacharymarshal
Copy link
Author

Looks like there are 2 slashes, don't put the first slash in your report_url. I need to make that better, let me know if it works if you change that.

'report_url' => 'Reports/Samples/Gato',

@thureos
Copy link

thureos commented Sep 24, 2013

Same result =(

@zacharymarshal
Copy link
Author

Wow, 😢 I wonder if it has something to do with passing parameters, the error is in the InputControlsContainer ... which is weird considering we are just trying to generate the report. Try setting parameters to array() and maybe checking the Gato report to see if it has any weird input control setup.

@thureos
Copy link

thureos commented Sep 25, 2013

Resource Not Found...

My guess is that is all about Initial URL.. It doesn't log you in actually.

I saw that you concatenate the auth url with the uri request.

Maybe by separating them and making one to get JSESSIONID and another one to request the report.

As I said in previous post the only URL that automatically logs me in is:

http://localhost:8080/jasperserver/j_spring_security_check?j_password=jasperadmin&j_password_pseudo=jasperadmin&j_username=jasperadmin

But I cannot do this:

http://localhost:8080/jasperserver/j_spring_security_check?j_password=jasperadmin&j_password_pseudo=jasperadmin&j_username=jasperadmin/rest_v2/reports/samples/Gato

Thanks for all your support

@zacharymarshal
Copy link
Author

I wouldn't think that it would work via the browser, but it should via curl, try this, you should get results from this:

curl --user jasperadmin:jasperadmin http://localhost:8080/jasperserver/rest_v2/reports/Reports/Samples/Gato.html

@thureos
Copy link

thureos commented Sep 25, 2013

I think I got it...

I changed URL to in both report.php and report_asset.php to:

Illuminate\Jasper::$url = 'http://localhost:8080/jasperserver/';

and in line 79 of IlluminateJasper.php

return "/rest_v2/reports/{$this->report_url}.{$this->format}?j_username=jasperadmin&j_password=jasperadmin&{$url_params}";

PDF and HTML works but XLS has no images.

Obviously user and password are coded right in it, we can store it into a variable and make it more ellegant.

We will continue testing it.

Thanks so much

@zacharymarshal
Copy link
Author

Sweet, well good news. I am not sure why the basic auth doesn't work for you, but at least you got it, nice work! The one thing I would suggest is passing the j_username & password in as parameters so you don't have to modify the IlluminateJasper.php, e.g.,

$report = new Report(array(
    'format'     => $format,
    'report_url' => 'Reports/Samples/Gato',
    'parameters' => array(
        'j_username' => 'jasperadmin',
        'j_password' => 'jasperadmin',
    ),
));

As for XLS, we have never seen graphs or charts in the xls, and we have used the software since it was using SOAP...so it could be a bug in the jasper renderer or just something that is not supported in xls...which someone from Jasper will have to weigh in on.

Hope all goes well, glad I could help

@thureos
Copy link

thureos commented Sep 27, 2013

It worked!

We will polish it and adapt it to our need. While waiting for @marianol to give us some news...

Thanks again @zacharyrankin

@marianol
Copy link
Owner

marianol commented Nov 6, 2013

Hey awesome that you have found a fix for this, I have been swamped so I was not able to touch this project in quite some time.

Anyway I have some good news regarding the images in the XLS export, that is actually a configuration setting, if you want the XLS to have the chart image just open WEB-INF/applicationContext.xml and search for the xlsExportParameters bean and in there you will find:

<property name="ignoreGraphics" value="true"/>

Set that to false and your charts will be exported as images in XLS

@zacharymarshal
Copy link
Author

Hi Guys,

I have abstracted this logic into a more reusable library that you can use: https://github.com/zacharyrankin/Douglas let me know what you think.

@thureos
Copy link

thureos commented Nov 20, 2013

Cool, thanks!
On Nov 19, 2013 9:54 PM, "Zachary Rankin" notifications@github.com wrote:

Hi Guys,

I have abstracted this logic into a more reusable library that you can
use: https://github.com/zacharyrankin/Douglas let me know what you think.


Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-28861884
.

@Actine
Copy link

Actine commented Dec 2, 2013

Hello.

I don't know if that might be related or not... There is a known bug/deficiency in Report Executions service that replaced Reports service in 5.2, I believe. Currently Reports service implicitly uses Report Executions in synchronous mode, and that you can tell by /reportExecutions/ path segment in report attachment URLs like in the first message.

The known deficiency is that Report Executions flow is not stateless. To work correctly it requires that the cookie JSESSIONID is the same for the request to create report and request to fetch attachments. Authentication with the same credentials either via basic http or parameters in URL will not work — the resources won't be found if the cookie doesn't match.

The correct way to get a report and its attachments using the client would be to get both the report and the attachments using the client and the same cookie (will probably require writing a method to get attachments). If it's required to then display this report to the user, your PHP application should retrieve from JRS and serve both report and attachments. In order to not have to perform str_replace on the output to replace default attachment paths (rest_v2/reportExecutions/{executionId}/exports/{exportId}/attachments/), you may use attachmentPrefix parameter upon running a report/execution to specify custom prefix (e.g. rest_v2/reports/reports/samples/AllAccounts.html?attachmentPrefix=http%3A%2F%2Fmyphpapp.com%2Freports%2Fattachment.php%3F%3D)

And actually I'd advise you to look at Report Executions service. It's described in Web Services Guide. It requires more steps to perform, but allows to get valuable metadata mid-air.

@zacharymarshal
Copy link
Author

Hi Actine,

Could you take a look at https://github.com/zacharyrankin/Douglas. I use the /rest_v2/reports/sample_report.html?parms_1=etc which from the docs is using the reportExecutions. Are there problems using this or should I just use the reportExecutions instead?

Thanks so much for your help, and for the information on the attachmentPrefix, I will give it a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants