无法找到类型的上下文数据:java.ws.rs.container.ContainerRequest(Wildfly 错误)

use*_*039 3 jax-rs resteasy wildfly

我正在使用 Wildfly 9.0.1.Final

我正在部署一个 REST 应用程序,它的端点定义如下:

@GET
@Path("/view/products")
@Produces(MediaType.APPLICATION_JSON)
@CORSEnabled
@Protected
public String getConfiguredProducts(
    @Context ContainerRequestContext request) {
    if (request != null) {
        Integer companyId = (Integer) request.getProperty("company");
        if (companyId != null) {
             //do stuff
        }
    }
    // ... more staff
}
Run Code Online (Sandbox Code Playgroud)

当应用程序运行时,上下文被注入,即“请求”非空。

当我尝试检索该属性时,我得到了错误:

executing GET /complaints/view/products:        
org.jboss.resteasy.spi.LoggableFailure: Unable to find contextual data    
of type: javax.ws.rs.container.ContainerRequestContext
Run Code Online (Sandbox Code Playgroud)

请注意,该应用程序在 glassfish/jersey 上运行没有问题,当我尝试将其移动到 wildfly/resteasy 时出现了问题。

有任何想法吗?

Fra*_*ung 6

我也有错误 RESTEASY003880: Unable to find contextual data of type: javax.ws.rs.core.HttpHeaders

这是由访问不同线程中的标头引起的。

希望答案会在谷歌搜索问题时有所帮助。