This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

Hmm. for some reason it seems the DeviceWebArgumentResolver is not getting picked up. Make sure you don't have any other AnnotationMethodHandlerAdapter beans floating around from your existing app. You might want to set a breakpoint on setCustomWebArgumentResolvers method of that class and see what gets injected there. Also I'd recommend referring to the lite-showcase sample app.

Comment

If you're using mvc:annotation-driven, you should not have DefaultAnnotationHandlerMapping or AnnotationMethodHandlerAdapter registered manually: this element registers them for you. Please refer to the wurfl-showcase sample and test it out and see how it's different then yours.

Comment

Well, the WURFL showcase shows injection of a SitePreference, which is done using the same WebArgumentResolver machinery that the DeviceWebArgumentResolver uses. Something has to be wrong with your configuration. Fundamentally, a DeviceWebArgumentResolver MUST be registered with the AnnotationMethodHandlerAdapter that is used to invoke @Controllers dispatched by the DispatcherServlet. Having a duplicate AnnotationMethodHandlerAdapter floating around in your context that is not configured properly can definitely cause this problem.

You might want to try the following test:
- Take wurfl-showcase and try injecting a Device into a @Controller method. It should fail.
- Add DeviceWebArgumentResolver to the set of web-argument-resolvers, alongside SitePreferenceWebArgumentResolver, and try your @Controller test again. It should work.

Comment

WurflDevice is not required there, a org.springframework.mobile.Device reference will work fine as long as the DeviceWebArgumentResolver is registered properly. You can review the code of DeviceWebArgumentResolver to see this for yourself. Of course, if you need a WurflDevice, you can inject it as well.

Keith

Comment

Looking back at this thread, it looks like you were trying to import net.sourceforge.wurf.core.Device. This will definitely NOT work, as this is part of the WURFL library. You can only import implementations of the Spring Mobile Device abstraction: org.springframework.mobile.Device, which includes the interface itself as well as the specific WurflDevice implementation, which is a Spring Mobile wrapper around net.sourceforge.wurfl.core.Device.

Keith

Comment

Just out of curiosity, did you actually test out the LiteDeviceResolver from a iPad User Agent and you ended up with a non-mobile version of your site? If so, that would be a defect in the LiteDeviceResolver implementation. If you could open a JIRA reporting the problem, that would be helpful.