Unable to find contextual data of type: java.ws.rs.container.ContainerRequest (Wildfly error)

烂漫一生 提交于 2019-12-06 13:19:48

I am answering my own question, since it seems that RestEasy does not support injection of a ContainerRequestContext, at least according to this

https://docs.jboss.org/resteasy/docs/1.1.GA/userguide/html_single/#_Context

The @Context annotation allows you to inject instances of javax.ws.rs.core.HttpHeaders, javax.ws.rs.core.UriInfo, javax.ws.rs.core.Request, javax.servlet.HttpServletRequest, javax.servlet.HttpServletResponse, javax.servlet.ServletConfig, javax.servlet.ServletContext, and javax.ws.rs.core.SecurityContext objects.

I injected a javax.ws.rs.core.HttpHeaders instead, where I had previously added all the information I needed.

I also had the error RESTEASY003880: Unable to find contextual data of type: javax.ws.rs.core.HttpHeaders

It was caused by accessing the headers in a different thread.

Hopefully the answer will help when googling the problem.

In my case, it was simply an invalid Content-Type header. Error certainly was misleading.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!