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

标签 jax-rs wildfly resteasy

我正在使用 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/

相关文章:

java - 在 Websphere 中获取 500 NullPointerException - Apache Wink Rest 服务

java - Spring Data JPA CDI 集成因 Wildfly Swarm 而失败

java - 如何在 Java 中识别监视器锁的所有者

java - ContainerRequestFilter 在 JAX-RS 服务方法中导致 NPE

java - 处理无正文的 POST

JAVA接收: use @PathParam and application/x-www-form-urlencoded body in the same method

java - Resteasy 如何更新/添加查询参数?

java - @JsonView 注解如何用于嵌套实体?

java - 如何在 JAX-RS 上返回没有父标签的 JSON?

javax.ws.rs.NotFoundException : RESTEASY003210: Could not find resource for full path: using RestEASY, Intellij IDEA 16.1,Tomcat 8.0.33