I am having an issue getting RESTEasy to implement a conditional GET
when deployed to JBoss 7.1.1 with a WEB-INF/beans.xml present in the
WAR. If I run it within a local Jetty/JUnit/Maven/Spring environment
it works. If I deploy the application to JBoss AS 7.1.1 *without* a
WEB-INF/beans.xml file -- it works. If I include a skeletal beans.xml
file the conditional GET always fails and I have noticed key headers
missing within the header processing.

Here is an example POST
GET /jaxrs-scale-dmv-war6/caching/conditional HTTP/1.1
Accept: application/xml
Via: 1.1 localhost (Apache-HttpClient/4.1.3 (cache))
If-Modified-Since: Sun, 20 May 2012 17:08:26 GMT
foo: bar
Via: 1.1 localhost (Apache-HttpClient/4.1.3 (cache))
Host: 127.0.0.1:8080
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.3 (java 1.5)

Here is a snippet of debug code that is present in the resource method
@Path("caching")
@Singleton
public class CachingRS {
    private @Context Request request;
    private @Context HttpHeaders headers;
    private @Context HttpServletRequest httpRequest;
...
    @GET
    @Path("conditional")
    @Produces(MediaType.APPLICATION_XML)
    @Formatted
    public Response getConditional()  {
        log.info("called: {} {}", request.getMethod(), uriInfo.getRequestUri());

        for (String key : headers.getRequestHeaders().keySet()) {
            List<String> value = headers.getRequestHeader(key);
            log.info("jaxrs.header {} = {}", key, value);
        }

        for (Enumeration<String> e=httpRequest.getHeaderNames();
e.hasMoreElements();) {
            String key = e.nextElement();
            String value = httpRequest.getHeader(key);
            log.info("httpRequest.header {} = {}", key, value);
        }
        ResponseBuilder response = request.evaluatePreconditions(valueDate);

The jaxrs HttpHeaders is missing the if-modified-since and dummy foo header
13:08:26,774 called: GET
http://127.0.0.1:8080/jaxrs-scale-dmv-war6/caching/conditional
13:08:26,775 jaxrs.header connection = [Keep-Alive]
13:08:26,776 jaxrs.header host = [127.0.0.1:8080]
13:08:26,776 jaxrs.header via = [1.1 localhost
(Apache-HttpClient/4.1.3 (cache))]
13:08:26,777 jaxrs.header accept = [application/xml]
13:08:26,778 jaxrs.header user-agent = [Apache-HttpClient/4.1.3 (java 1.5)]

The HttpServletRequest has the missing headers
13:08:26,778 httpRequest.header accept = application/xml
13:08:26,779 httpRequest.header via = 1.1 localhost
(Apache-HttpClient/4.1.3 (cache))
13:08:26,779 httpRequest.header if-modified-since = Sun, 20 May 2012
17:08:26 GMT
13:08:26,780 httpRequest.header foo = bar
13:08:26,780 httpRequest.header host = 127.0.0.1:8080
13:08:26,781 httpRequest.header connection = Keep-Alive
13:08:26,781 httpRequest.header user-agent = Apache-HttpClient/4.1.3 (java 1.5)

If I remove the WEB-INF/beans.xml file ...
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
   xsi:schemaLocation="
        http://java.sun.com/xml/ns/javaee
        http://java.sun.com/xml/ns/javaee/beans_1_0.xsd";>
</beans>

The jaxrs HttpHeader object gets populated with the missing headers
and my conditional GET works deployed to JBoss 7.1.1
13:16:44,064 called: GET
http://127.0.0.1:8080/jaxrs-scale-dmv-war6/caching/conditional
13:16:44,065 jaxrs.header connection = [Keep-Alive]
13:16:44,066 jaxrs.header if-modified-since = [Sun, 20 May 2012 17:16:43 GMT]
13:16:44,066 jaxrs.header host = [127.0.0.1:8080]
13:16:44,067 jaxrs.header via = [1.1 localhost
(Apache-HttpClient/4.1.3 (cache)), 1.1 localhost
(Apache-HttpClient/4.1.3 (cache))]
13:16:44,068 jaxrs.header accept = [application/xml]
13:16:44,069 jaxrs.header user-agent = [Apache-HttpClient/4.1.3 (java 1.5)]
13:16:44,069 jaxrs.header foo = [bar]

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users

Reply via email to