title: Spring Mobile - Interceptor not applied? Device is null
body: <p>I'm experimenting with Spring Mobile but I can't seem to get the basic example working.  I have a feeling I'm missing something stupidly simple but I can't figure out what it is. Here is what I have in place...</p>
  
  <p>In web.xml</p>
  
  <pre><code>&lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;
          /WEB-INF/applicationContext.xml
      &lt;/param-value&gt;
  &lt;/context-param&gt; 
  &lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
  &lt;/listener&gt;
  &lt;filter&gt;
      &lt;filter-name&gt;deviceResolverRequestFilter&lt;/filter-name&gt;
      &lt;filter-class&gt;org.springframework.mobile.device.DeviceResolverRequestFilter&lt;/filter-class&gt;
  &lt;/filter&gt;
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;deviceResolverRequestFilter&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  </code></pre>
  
  <p>In applicationContext.xml</p>
  
  <pre><code>&lt;beans:beans xmlns="http://www.springframework.org/schema/mvc"
          xmlns:beans="http://www.springframework.org/schema/beans"
          xmlns:device="http://www.springframework.org/schema/mobile/device"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xsi:schemaLocation="http://www.springframework.org/schema/mvc 
                  http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
                  http://www.springframework.org/schema/beans 
                  http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                  http://www.springframework.org/schema/mobile/device 
                  http://www.springframework.org/schema/mobile/device/spring-mobile-device-1.0.xsd"&gt;
  
      &lt;!-- Interceptors that execute common control logic across multiple requests --&gt;
      &lt;interceptors&gt;
          &lt;!-- Detects the client's Device --&gt;
          &lt;beans:bean class="org.springframework.mobile.device.DeviceResolverHandlerInterceptor" /&gt;
      &lt;/interceptors&gt;
  
  &lt;/beans:beans&gt;
  </code></pre>
  
  <p>In my Java class:</p>
  
  <pre><code>public class TestAction extends ActionSupport implements ServletRequestAware {
  
      // So that we can lookup the current Device 
      private HttpServletRequest request;
  
      public void setServletRequest(HttpServletRequest request) {
          this.request = request;
      }
  
      @Override
      public String execute() {
          Device currentDevice = DeviceUtils.getCurrentDevice(request);
          if (currentDevice.isMobile()) // &lt;-- fails here with NPE
  </code></pre>
  
  <p><strong>Why is the device not set and resulting as null?</strong></p>
  
  <p>EDIT: 
  Log files seem to indicate a problem with setting the interceptor but I'm still not sure where I went wrong.</p>
  
  <blockquote>
    <p>2012-05-29 09:36:36,696 DEBUG [ConstructorResolver.java:201] : 
    Ignoring constructor [public
    org.springframework.web.servlet.handler.MappedInterceptor(java.lang.String[],org.springframework.web.context.request.WebRequestInterceptor)]
    of bean 'org.springframework.web.servlet.handler.MappedInterceptor#0':
    org.springframework.beans.factory.UnsatisfiedDependencyException:
    Error creating bean with name
    'org.springframework.web.servlet.handler.MappedInterceptor#0':
    Unsatisfied dependency expressed through constructor argument with
    index 1 of type
    [org.springframework.web.context.request.WebRequestInterceptor]: Could
    not convert constructor argument value of type
    [org.springframework.mobile.device.DeviceResolverHandlerInterceptor]
    to required type
    [org.springframework.web.context.request.WebRequestInterceptor]:
    Failed to convert value of type
    'org.springframework.mobile.device.DeviceResolverHandlerInterceptor'
    to required type
    'org.springframework.web.context.request.WebRequestInterceptor';
    nested exception is java.lang.IllegalStateException: Cannot convert
    value of type
    [org.springframework.mobile.device.DeviceResolverHandlerInterceptor]
    to required type
    [org.springframework.web.context.request.WebRequestInterceptor]: no
    matching editors or conversion strategy found</p>
  </blockquote>