2015-09-07 28 views
1

我使用wildfly 9.0.1.Final無法找到類型的上下文數據:java.ws.rs.container.ContainerRequest(Wildfly誤差)

我部署具有這樣定義端點的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 
} 

當應用程序運行時,上下文被注入,即'request'非空。

當我嘗試雖然找回我回去錯誤的性質:

executing GET /complaints/view/products:   
org.jboss.resteasy.spi.LoggableFailure: Unable to find contextual data  
of type: javax.ws.rs.container.ContainerRequestContext 

請注意,該應用程序,而不在GlassFish /球衣問題上運行,並出現了問題,當我試圖將它移動到wildfly /高枕無憂。

任何想法?

回答

3

我回答我的問題,因爲它似乎RestEasy的不支持ContainerRequestContext的注射,至少根據本

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.

我注入了javax.ws.rs。 core.HttpHeaders,而我以前添加了我需要的所有信息。

相關問題