0

I have a mobile webapp with a single view index.xhtml. I change this view dynamicaly with POST request only. Basically all my ViewScopedBean are SessionScopedBean. I don't know if it is the best solution for mobile webapp but there it is (dynamic updating looks like faster than reload a whole new page).

All is fine on localhost, even in production when I use the ip of my remote server to acces the mobile webapp. When I use the domain name, on one on my dynamic views, if do something with a post request, I got this exception

  javax.faces.application.ViewExpiredException: viewId:/index2.xhtml - View /index2.xhtml could not be restored.

I know why this exception occurs but I don't why my view expired. Where should I look ? I could post my code but it's really messy.

  • So you don't understand how HTTP session is supposed to work? This is explained and linked in http://stackoverflow.com/questions/3642919/javax-faces-application-viewexpiredexception-view-could-not-be-restored/3642969#3642969 – BalusC Aug 19 '15 at 05:54
  • Well actually I saw this post, I will read it again then. Thanks –  Aug 19 '15 at 08:41
  • From 1st section: *"So, when the session is expired for some reason (either timed out in server or client side, or the session cookie is not maintained anymore for some reason in browser, or by calling `HttpSession#invalidate()` in server), then the serialized view state is not available anymore in the session and the enduser will get this exception. To understand the working of the session, see also [How do servlets work? Instantiation, shared variables and multithreading](http://stackoverflow.com/questions/3106452/how-do-servlets-work-instantiation-shared-variables-and-multithreading)."* – BalusC Aug 19 '15 at 08:45
  • After some of your reading I tried to debug myself, pls check out my explanation. Thank you anyway ! –  Aug 19 '15 at 15:01

1 Answers1

0

Well I found the solution, I'm not sure why it happen.

In my bugged dynamic view I have a url(#{prom.imageUrl}) in some css. In my case #{prom.imageUrl} returns something like 167.xxx.xxx.xxx:8080/User/images/image.jpg. So here the thing, I have a apache server on port 80 who redirects the adress domain.com to 167.xxx.xxx.xxx:8080/User/. When I go on this dynamic view via 167.xxx.xxx.xxx:8080/User all is fine but if I access the view via domain.com , my session is reset ! My guess is calling this #{prom.imageUrl} call a connexion to 167.xxx.xxx.xxx:8080/User/ and since the server think it's a first connexion (cause I am connected via domain.com), he create a new session and then I got the viewexpired exception. But all of this need to be confirmed.