question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Spring Web @RequestHeader(Map<String,String>) throws RuntimeException

See original GitHub issue

Describe the bug I’m trying to access all request headers using Spring @RequestHeader in the same way that @Context HttpHeaders headers would provide access to all request headers.

When starting the application with mvn quarkus:dev, I get the following exception

Caused by: java.lang.RuntimeException: RESTEASY003875: Unable to find a constructor that takes a String param or a valueOf() or fromString() method for javax.ws.rs.HeaderParam(“headers”) on public java.lang.String org.acme.SpringGreetingController.hello(java.util.Map) for basetype: java.util.Map

Expected behavior A populated Map with HTTP headers, preferably a MultiValuedMap.

Actual behavior Above exception.

To Reproduce

See reproducer. Note, I’d like to use the Spring MultiValueMap, although the reproducer uses a Map. The reproducer is literally a project generated from code.quarkus.io with the Spring Web extension, with the hello() method updated as follows;

    public String hello(@RequestHeader MultiValueMap<String, String> headers) {
        headers.forEach((key, value) -> {
            System.out.println(key + "->" + value);
        })

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
geoandcommented, Jul 26, 2021

I will likely work on this after the 2.2 stabilization release is out

0reactions
geoandcommented, Mar 21, 2022

@liangyuanpeng yup, as you mention one can mix and match the Spring and JAX-RS annotations and types.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to simplify REST controllers with same methods and ...
I found this answer on https://www.logicbig.com/tutorials/spring-framework/spring-web-mvc/spring-mvc-request-header.html.
Read more >
Spring MVC - @RequestHeader Examples - LogicBig
The @RequestHeader annotation is used to bind HTTP request header attributes values to controller method parameters.
Read more >
Web on Reactive Stack - Spring
The reactive-stack web framework, Spring WebFlux, was added later in ... When a @RequestHeader annotation is used on a Map<String, String> ...
Read more >
Spring @RequestHeader - binding method parameters to ...
@RequestHeader annotation binds request header values to method parameters. If the method parameter is Map<String, String> , MultiValueMap< ...
Read more >
Spring Boot Microservices and RESTful Web Services Tutorial ...
You will be able to develop and design RESTful web services · You will setup Centralized Microservice Configuration with Spring Cloud Config ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found