Open xhayot opened 4 days ago
I figured a workaround by forcing MappingJackson2HttpMessageConverter as the only message converter in my rest template configuration :
public RestTemplate getRestTemplate() { return new RestTemplateBuilder().messageConverters(Collections.singletonList(new MappingJackson2HttpMessageConverter())).build(); }
vaadin-grid-exporter works fine after that adjustment, I'm going to test a bit more to make sure but it seems to be ok.
Tested with all export formats :
This is likely a Spring Boot specific problem.
By default RestTemplate
automatically searches for available "converters" by checking if the classes are present.
This is also documented on the default constructor:
Create a new instance of the RestTemplate using default settings. Default HttpMessageConverters are initialized.
GridExporter brings dynamicreports-core -> jasperreports -> jackson-dataformat-xml
which then enables the XML converter when using the default constructor.
Depending on how you get the RestTemplate
you can simply - as you have already written above - create a RestTemplate
using the List<HttpMessageConverter<?>>
-constructor which is the solution to this problem.
Spring does exactly this e.g. inside the spring-security-oauth2-client
.
You can also try to exclude the jackson-dataformat-xml
however this might break JasperReports and through that the exports.
Tested with all export formats :
- No idea if it could be related (don't think so) but I'm unable to get any export preview.
- Final exports are fine
Exports should be unaffected since the component does not use any Spring specific stuff.
Tested with all export formats :
- No idea if it could be related (don't think so) but I'm unable to get any export preview.
- Final exports are fine
Exports should be unaffected since the component does not use any Spring specific stuff.
Exports are fine, what could explain the fact that I can't get any preview though ?
Exports are fine, what could explain the fact that I can't get any preview though?
This depends on what the browser can render/preview. PDFs can usually be previewed however Office specific formats like Excel, Word or PowerPoint documents are usually not supported.
Checklist
What is/are your question(s)?
Since I added vaadin-grid-exporter to my project, my RestTemplate adds XML format in accept headers. With vaadin-grid-exporter in my dependencies :
o.s.web.client.RestTemplate : Accept=[application/xml, text/xml, application/json, application/*+xml, application/*+json]
Without vaadin-grid-exporter in my dependencies :o.s.web.client.RestTemplate : Accept=[application/json, application/*+json]
I don't understand why and it's problematic when I'm pushing data to my Webservice.
"status":415,"error":"Unsupported Media Type","message":"Content-Type 'application/xml;charset=UTF-8' is not supported."
Is there any workaround I could implement to prevent this or would it be blocking for vaadin-grid-exporter ?
Thanks in advance !
Additional information
No response