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

Support non-blocking XML Marshalling with jackson-dataformat-xml #9581

Open
jwalgemoed opened this issue Jun 23, 2017 · 8 comments
Open

Support non-blocking XML Marshalling with jackson-dataformat-xml #9581

jwalgemoed opened this issue Jun 23, 2017 · 8 comments
Labels
status: blocked An issue that's blocked on an external project change type: enhancement A general enhancement

Comments

@jwalgemoed
Copy link

jwalgemoed commented Jun 23, 2017

Hi,

Jackson-xml marshalling seems to be broken in the 2.0.0 M2 milestone release for Spring boot (with web-flux). I tried both with functional web routers and a 'classic' (simple) annotation based controller (kotlin):

data class Hello(val one: String, val two: String)

@Bean
fun apiRouter() = router {
    GET("/hello") { req ->
        ok().contentType(MediaType.APPLICATION_XML)
                .body(BodyInserters.fromObject(Hello("Hello", "World")))
    }
}

And

data class Hello(val one: String, val two: String)

@RestController
class HelloController {
    @GetMapping("/hello") fun sayHello() = Hello("Hello", "World")
}

The jackson XML marshaller doesn't seem to be registered automatically anymore.

Steps to reproduce

  • Create a Spring Boot project (start.spring.io) -> 2.0.0 M2 with the reactive web dependency;
  • Add a restcontroller that returns a simple entity (see above);
  • Add jackson-dataformat-xml dependency.

Call the endpoint with the application/xml accept header. The sever will respond with a 406 - not acceptable response. In the logging this shows up:

2017-06-23 12:39:42.629 ERROR 26064 --- [ctor-http-nio-2] o.s.w.s.h.ResponseStatusExceptionHandler : Response status 406 with reason "Could not find acceptable representation"

Verification

I've tried a similar approach with Spring Boot 1.5.4 and there it works as expected, depending on the provided accept header (application/xml or application/json) the application responds with the response in the requested format.

@jwalgemoed jwalgemoed changed the title XML Marshalling with jackson-dataformat-xml in Spring Boot 2.0.0 M2 looks broken XML Marshalling with jackson-dataformat-xml in Spring Boot 2.0.0 M2 looks to be broken Jun 23, 2017
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 23, 2017
@jwalgemoed
Copy link
Author

Additional note, when using the routerfunction (webflux) the error is slightly different:

org.springframework.web.reactive.function.UnsupportedMediaTypeException: Content type 'application/xml' not supported
	at org.springframework.web.reactive.function.BodyInserters.lambda$null$16(BodyInserters.java:318) ~[spring-webflux-5.0.0.RC2.jar:5.0.0.RC2]
	at java.util.Optional.orElseGet(Optional.java:267) ~[na:1.8.0_66]
	at org.springframework.web.reactive.function.BodyInserters.lambda$bodyInserterFor$17(BodyInserters.java:314) ~[spring-webflux-5.0.0.RC2.jar:5.0.0.RC2]
	at org.springframework.web.reactive.function.server.DefaultServerResponseBuilder$BodyInserterServerResponse.writeTo(DefaultServerResponseBuilder.java:312) ~[spring-webflux-5.0.0.RC2.jar:5.0.0.RC2]
	at org.springframework.web.reactive.function.server.support.ServerResponseResultHandler.handleResult(ServerResponseResultHandler.java:98) ~[spring-webflux-5.0.0.RC2.jar:5.0.0.RC2]

@bclozel
Copy link
Member

bclozel commented Jun 23, 2017

I guess you can't really compare with MVC and Boot 1.5 in that case; jackson-dataformat-xml is supported in Spring MVC, but it's not (yet) the case in Spring WebFlux. We can't support that in Boot until the proper codecs are implemented in Spring Framework.

Could you create a Spring Framework issue and report back here once it's done?

Thanks!

@bclozel bclozel added status: on-hold We can't start working on this issue yet theme: webflux and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 23, 2017
@jwalgemoed
Copy link
Author

Apologies, I just assumed the issue would be limited to Spring Boot - but it actually makes a lot of sense that it doesn't. I'll create the issue for Spring Framework and will keep you posted on the results here.

@jwalgemoed
Copy link
Author

Issue for Spring Framework created here: https://jira.spring.io/browse/SPR-15697

@bclozel bclozel self-assigned this Jun 26, 2017
@bclozel bclozel changed the title XML Marshalling with jackson-dataformat-xml in Spring Boot 2.0.0 M2 looks to be broken Support XML Marshalling with jackson-dataformat-xml Jun 26, 2017
@philwebb philwebb added status: blocked An issue that's blocked on an external project change and removed status: on-hold We can't start working on this issue yet labels Jun 26, 2017
@Clockwork-Muse
Copy link

Excuse me, is there any update for this?

@bclozel
Copy link
Member

bclozel commented Apr 10, 2018

@Clockwork-Muse It's blocked - waiting on FasterXML/jackson-dataformat-xml#260

@Sergey80
Copy link

Sergey80 commented Feb 7, 2019

what is work-around?

@sdeleuze
Copy link
Contributor

sdeleuze commented Feb 7, 2019

@bclozel bclozel removed their assignment Aug 6, 2020
@wilkinsona wilkinsona changed the title Support XML Marshalling with jackson-dataformat-xml Support non-blocking XML Marshalling with jackson-dataformat-xml Jul 15, 2021
@wilkinsona wilkinsona added the type: enhancement A general enhancement label Jul 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: blocked An issue that's blocked on an external project change type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

8 participants