Jump to content
Changes to the Jaspersoft community edition download ×

Problem with jsessionID for reportExecution


Recommended Posts

Hi everyone,

I have a problem with report execution from http client (4.5.9 http dependency) java, we use 7.1 version. We consume from java restAPI to jasperServer instance. This problem is about session , i think that problem occurs because the jsessionID for each request is different. this is structure from my request for export report.

request structure order

body from request:
        " <reportExecutionRequest>n" +
        "    <reportUnitUri>"+Const.PATH_UNIT_REPORT+"</reportUnitUri>n" +
        "    <async>true</async>n" +
        "    <freshData>false</freshData>n" +
        "    <outputFormat>pdf</outputFormat>n" +
        " </reportExecutionRequest>"; 

First request: sending Request to url: http://localhost:8080/reportservice/rest_v2/reportExecutions/

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

Second request for check status:

response: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><status>queued</status>

Third request for export :
http://localhost:8080/reportservice/rest_v2/reportExecutions/aa4bbbd8-f9ca-4c25-88da-cab221be3782 (requestId)

Fourth  request for output :

I send the cookie in two ways:

The documentation says: 
For optimal performance, the session ID from the cookie should be used to keep the session open. To do this, 
include the cookie in future requests to the other RESTful services. For example,
given the response to the POST request above, future requests to the repository services should include the following line in the header:

Cookie: $Version=0; JSESSIONID=52E79BCEE51381DF32637EC69AD698AE; $Path=/jasperserver

We work in this ways:


Const.HEADER_MODIFY_TO_HEADER_REQUEST is equivalent to : Cookie: $Version=0;
Const.PARAMETER_JSESSIONID+sessionId+Const.PARAMETER_JASPER_SESSION is equivalent to:JSESSIONID=XXXXX; $Path=/reportservice;

HttpClient client =  HttpClientBuilder.create().build();
http = client.execute(req, httpContext);   


 BasicCookieStore cookieStore = new BasicCookieStore();
 BasicClientCookie cookie = new BasicClientCookie("JSESSIONID", sessionId);
 cookie.setPath("Path=/reportservice; HttpOnly");
 cookie.setDomain("localhost"); (FOR TEST)
 HttpClient client =  HttpClientBuilder.create().setDefaultCookieStore(cookieStore).build();

But not work, the sessionID always change por each request. Maybe , i think for that issue is not working. so, somebody have idea about that. We dont use the rest client from jasper, its confuse and i cant find any example of a similar implementation.

thanks in advance

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...