WURFL and Spring DispatcherServlet issue

WURFL and Spring DispatcherServlet issue

Postby buckolas » Fri Mar 23, 2012 3:53 pm

I am using wurfl-1.3.1.1.jar Java API with the Spring configuration running in a war deployed to Tomcat 7. I have WURFL configured in Spring's application context file as follows:

Code: Select all
<bean id="wurflModel" class="net.sourceforge.wurfl.spring.SpringWURFLModel">
       <property name="wurfl" value="file:C:/wurfl-2.3.xml.zip"/>
</bean>


The server starts fine and the logging indicates the WURFL repository file was loaded successfully. In my controller method, I have the following:

Code: Select all
WURFLHolder wurflHolder = (WURFLHolder)request.getSession().getServletContext().getAttribute("net.sourceforge.wurfl.core.WURFLHolder");
WURFLManager wurfl = wurflHolder.getWURFLManager();
Device device = wurfl.getDeviceForRequest(request);


On the line where I attempt to call getDeviceForRequest() method, I get the following stack trace:

Code: Select all
org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.StackOverflowError
   org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:839)
   org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
   org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
   org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
........
java.lang.StackOverflowError
   net.sourceforge.wurfl.spring.SpringWurflManager.getDeviceForRequest(SpringWurflManager.java:366)
   net.sourceforge.wurfl.spring.SpringWurflManager.getDeviceForRequest(SpringWurflManager.java:366)
   net.sourceforge.wurfl.spring.SpringWurflManager.getDeviceForRequest(SpringWurflManager.java:366)
   net.sourceforge.wurfl.spring.SpringWurflManager.getDeviceForRequest(SpringWurflManager.java:366)
   net.sourceforge.wurfl.spring.SpringWurflManager.getDeviceForRequest(SpringWurflManager.java:366)
   net.sourceforge.wurfl.spring.SpringWurflManager.getDeviceForRequest(SpringWurflManager.java:366)
   net.sourceforge.wurfl.spring.SpringWurflManager.getDeviceForRequest(SpringWurflManager.java:366)
   net.sourceforge.wurfl.spring.SpringWurflManager.getDeviceForRequest(SpringWurflManager.java:366)
.........


The root cause seems to indicate that WURFL's getting routed through Spring's DispatcherServlet and ends up in an infinite loop, but I don't know how to resolve this. Any ideas would be appreciated. Let me know if I need to provide more info.
buckolas
 
Posts: 2
Joined: Fri Mar 23, 2012 3:41 pm

Re: WURFL and Spring DispatcherServlet issue

Postby fulvio.crivellaro » Mon Mar 26, 2012 2:41 am

Hello.

Does this happen with ANY user agent, or maybe you have tried a particular one?
If yes, please provide us the UA so that it could be a good starting point to find the problem.

Otherwise, if this exception always happens when you first call "getDeviceFromRequest" method, it is probably generated during the initialization phase.
Especially if you have deployed more WARs on the same JVM, try to increase the available stack memory, and see if it solves your problem. The JVM parameter is -Xss (e.g. -Xss4m sets the available stack size to 4 MB).
I expect it to happen because of the big wurfl.xml file parsing, since we have never experienced stack issues or infinite loop bugs.

Let us know if it solves your problem.
Fulvio
fulvio.crivellaro
 
Posts: 33
Joined: Tue Jan 31, 2012 10:27 am

Re: WURFL and Spring DispatcherServlet issue

Postby buckolas » Mon Mar 26, 2012 7:39 am

This happens in IE, Firefox, and Chrome. My chrome User-Agent string is:

User-Agent:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.83 Safari/535.11

This worked when I configured WURFL directly in the web.xml and put the wurfl.xml.zip file in the WEB-INF folder. However, once I moved the zip file out of the WAR and switched to the Spring configuration, then I started seeing this problem.
buckolas
 
Posts: 2
Joined: Fri Mar 23, 2012 3:41 pm

Re: WURFL and Spring DispatcherServlet issue

Postby luca.passani » Mon Mar 26, 2012 8:05 am

Buckolas, we are very very close to releasing version 1.4 of the API.

How would you like to receive a Release Candidate and try that instead?

I don't think it make much sense to run after a potential bug for which the solution would be to upgrade to version 1.4 of the WURFL API anyway.

If you are interested, please contact us offline. luca.passani @ scientiamobile

Thanks

Luca
luca.passani
 
Posts: 61
Joined: Thu May 19, 2011 2:49 pm


Return to Java API

Who is online

Users browsing this forum: Google [Bot] and 2 guests

cron