我正在使用 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
}
当应用程序运行时,上下文被注入(inject),即“请求”不为空。
当我尝试检索该属性时,我得到了错误:
executing GET /complaints/view/products:
org.jboss.resteasy.spi.LoggableFailure: Unable to find contextual data
of type: javax.ws.rs.container.ContainerRequestContext
请注意,该应用程序在 glassfish/jersey 上运行没有问题,当我尝试将其移动到 wildfly/resteasy 时出现问题。
有任何想法吗?
最佳答案
我也有错误RESTEASY003880: Unable to find contextual data of type: javax.ws.rs.core.HttpHeaders
这是由访问不同线程中的标题引起的。
希望在谷歌搜索问题时答案会有所帮助。
关于jax-rs - 找不到 : java. ws.rs.container.ContainerRequest 类型的上下文数据(Wildfly 错误),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32436419/