Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am using wildfly 9.0.1.Final

I am deploying a REST application which has an endpoint defined like this:

@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
}

When the application runs, the context is injected, i.e. 'request' is non null.

When I try though to retrieve the property I get back the error:

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

Please note that the application was running without problems on glassfish/jersey and the problem appeared when I tried to move it to wildfly/resteasy.

Any ideas?

like image 751
user2465039 Avatar asked Oct 17 '25 08:10

user2465039


1 Answers

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.

like image 177
Frank Neblung Avatar answered Oct 20 '25 14:10

Frank Neblung



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!