[#14061] - Ajax call problem due to upgrade to JasperReport V6.19.0

Category:
Bug report
Priority:
High
Status:
New
Project: Severity:
Major
Resolution:
Open
Component: Reproducibility:
Always
Assigned to:

Update from JasperReport V6.18.1 to V6.19.0. Firing a ajax request from page to controller. I find that ajax function cannot receive data returning from controller. This issue did not occur when I downgrade back to V6.18.1 or even V6.17.0.

My dependency is:
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>6.19.0</version>
</dependency>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports-fonts</artifactId>
<version>6.19.0</version>
</dependency>

Js part:
$.ajax({
url : url,
success : function(data) {
if (data.status == 'success') {
$("#text").html(data.text);
} else {
$("#text").css("color", "red");
$("#text").html(data.message.toUpperCase());
alert(data.message);
}
},
error : function(error) {
alert(error.responseText);
}
});

controller part:

@GetMapping("...url")
public ResponseEntity<HashMap<String, Object>> getCurrentSystemYear() {
HashMap<String, Object> map = new HashMap<>();
map.put("status", "success");
map.put("message","testing...");

return new ResponseEntity<>(map, HttpStatus.OK);
}

jasper library
vl.work's picture
Joined: Mar 2 2022 - 8:32pm
Last seen: 9 months 1 week ago

7 Comments:

#1
  • Status:New» Feedback Requested
  • Assigned:nobody» teodord

Hi,

Not sure which controller are you talking about. JasperReports Library is not a web application.
Are you sure there is no error on the server side application where JRL is used?
Did you check the logs?

Thanks,
Teodor

#2

I am using spring boot. There is no error in back end in log.
An error captured at font end at browser debugger which indicated the data returned from backend is undefined.
There is no any update on coding. I just update the version of jasper report.

AttachmentSize
Image icon capture.png14.45 KB
#3

After I exclude jackson-dataformat-xml. The issue gone and without affect report generation. However, I don't know whether it would have adverse behavior to my ssystem.

<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>6.19.1</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports-fonts</artifactId>
<version>6.19.1</version>
</dependency>

AttachmentSize
Image icon capture2.png16.82 KB
#4
  • Status:Feedback Requested» New
  • Assigned:nobody»

The real problem here is that after upgrading to JasperReports 6.19 and also to 6.20 Spring controllers start to output XML instead of JSON nless you specify it (https://stackoverflow.com/questions/71351249/spring-rest-controller-retu...). Fixes from stackoverflow do not seem the correct way to fix it. Is there some configuration file in jasper overwriting the default output?

#5

I agree with borja.serrano ... this actually caused us a pretty significant issue, so I would appreciate if the severity was upgraded from Minor.

#6
  • Priority:Normal» High
  • Severity:Minor» Major
#7

When the JSON has special characters such as "&" because it is now treated as application/xhtml+xml in the response content type instead of application/json that causes errors processing the payload. Just to clarify these are REST endpoints that aren't even related to Jasper. It seems the change has done something globally to the Jackson configuration.

AttachmentSize
Image icon issue.png26.08 KB
Feedback
randomness