voyent
Session Timeout - Again  XML
Forum Index -> General Help Go to Page: Previous  1, 2, 3
Author Message
dspeed

Joined: 04/Mar/2011 03:32:32
Messages: 10
Offline


After a little more testing I've discovered that my fix works in Chrome and Firefox but not IE8 :-(

I'll post back when I get it working on IE.
jbrice

Joined: 02/Mar/2011 19:19:37
Messages: 16
Offline


Hi guys,

The banit's solution even with your modification does not work for me.

Boolean newSession = (sessionMap == null) || (sessionMap.isEmpty()) && (! session.isNew());

timedout is always false!!erf!

dspeed

Joined: 04/Mar/2011 03:32:32
Messages: 10
Offline


jbrice wrote:
Hi guys,

The banit's solution even with your modification does not work for me.

Boolean newSession = (sessionMap == null) || (sessionMap.isEmpty()) && (! session.isNew());

timedout is always false!!erf!

 


Hi jbrice,

Did you change the following lines in Banits code

from

boolean postback = !ext.getRequestParameterMap().isEmpty();
boolean timedout = postback && newSession;

to

Boolean timeout = newSession;

In my debugging postback always came back as true so I removed that line and (lazily) just set timedout to newsession rather than throwing away the timedout variable.

If you have already done that I'm afraid I'm not sure what is different between our cases (or our cases and Banits for that matter)

Not sure if it will help but I am running my app in ecplise Helios with Tomcat 7 as the server on a Windows 7 machine.


iain.ibo

Joined: 14/Mar/2011 06:43:47
Messages: 4
Offline


I made the changes to add in the FilterSessionTimeout and when I test this with short timeout times (up to 30 mins) then I do drop in here and the timedout variable shows true and I can handle the timeout myself.

However, when I set it back up to an hour timeout when I click on the app I get the following error message still:


[window] error [status: emptyresponse code: 200]: an empty response was received from the server.
 


And the app is unresponsive. So I'm still getting the same behaviour. Hmm...it's a toughy.

dspeed

Joined: 04/Mar/2011 03:32:32
Messages: 10
Offline


I've to make a lot of changes to get this working on ie8.

I've had to change my PhaseListener to be a Filter as debugging showed that while the PhaseListener was triggered as expected by IE while the session was live, after the session expired it was never triggered in IE.

SessionTimeoutFilter now looks like this

Code:
 package uk.co.vianet.utilities;
 
 import java.io.IOException;
 
 import javax.faces.FacesException;
 import javax.faces.application.Application;
 import javax.faces.application.ViewHandler;
 import javax.faces.component.UIViewRoot;
 import javax.faces.context.FacesContext;
 import javax.servlet.Filter;
 import javax.servlet.FilterChain;
 import javax.servlet.FilterConfig;
 import javax.servlet.ServletException;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpSession;
 
 public class SessionTimeoutFilter implements Filter{
 	
 	private FilterConfig fc;
 	
 	public void destroy() {
 		
 	}
 
 	public void doFilter(ServletRequest request, ServletResponse response,
 			FilterChain chain) throws IOException, ServletException {
 		
 		
 		HttpServletRequest req = (HttpServletRequest)request;
 		HttpSession session = req.getSession(false);
 		FaceContextBuilder fcb = new FaceContextBuilder();
 		
 		if(session == null){
 			FacesContext context = fcb.getFacesContext(request, response);
 			Application app = context.getApplication();
 			ViewHandler viewHandler = app.getViewHandler();
 			UIViewRoot view = viewHandler.createView(context, "/vendexpert-login/.xhtml" );
 			context.setViewRoot(view);
 			context.renderResponse();
 			try {
 				viewHandler.renderView(context, view);
 				context.responseComplete();
 			} catch (Throwable t) {
 				throw new FacesException("Session timed out", t);
 			} finally {
 				fcb.removeFacesContext();
 			}
 		}else{
 			chain.doFilter(request,response);
 		}
 	}
 
 	public void init(FilterConfig config) throws ServletException {
 		fc = config;
 	}
 }
 


The code that allows me to access the FacesContext in a filter (FaceContextBuilder) comes from these links

The Builder class
[url]
http://ocpsoft.com/java/jsf-java/jsf-20-extension-development-accessing-facescontext-in-a-filter/
[/url]

An extension to the class to tidy up the context after use
[url]
http://ocpsoft.com/java/jsf-java/please-tell-your-developers-to-call-facescontextrelease/
[/url]

After removing the PhaseListener config from Faces-Config.xml and adding this Filter config to Web.xml

Code:
 <filter>
  	<filter-name>session</filter-name>
  	<filter-class>uk.co.vianet.utilities.SessionTimeoutFilter</filter-class>
   </filter>
 
   <filter-mapping>
 	<filter-name>session</filter-name>
 	<url-pattern>*.xhtml</url-pattern>  	
   </filter-mapping>
 


I had an issue where only the first of our filters ran after the session expired in IE, I'm not sure if this is a quirk of IE or an issue with our filters but I put the session filter first in web.xml so that it is run first.

The click here to reload message box now appears in both Chrome and IE.

I have ran tests with this code with the session expiring after 1minute which was successful on Chrome and IE.

I have also ran a test on chrome where the session was set to expire after 60 minutes which worked fine.

jbrice

Joined: 02/Mar/2011 19:19:37
Messages: 16
Offline


I have been struggling all day to find a solution and like you, I used Filter instead of Phase Listener class, but the redirecting with Code:
"Response.sendRedirect(response.encodeRedirectURL(timeoutUrl))"
has not worked at all.
So the other way for redirecting is using the FacesContext objet, but I didn't know how, I could get the value without PhaseEvent.
Thanks to you, now I have the answer, creating a new one with
Code:
FaceContextBuilder fcb = new FaceContextBuilder();

I'm gonna test your solution and hope it's gonna work, I,m really tired of this bug!PFiouuuuuuuu!!
Cheers
jbrice

Joined: 02/Mar/2011 19:19:37
Messages: 16
Offline


In the console I have a
Missing window ID attribute. Request map cleared prematurely.

Code:
UIViewRoot view = viewHandler.createView(context, "/login/newlogin.xhtml" );

What is the viewId paramter exactly? is it the path?
I'm using icefaces version 2, are you sure viewHandler works on this version?
dspeed

Joined: 04/Mar/2011 03:32:32
Messages: 10
Offline


jbrice wrote:
In the console I have a
Missing window ID attribute. Request map cleared prematurely.

Code:
UIViewRoot view = viewHandler.createView(context, "/login/newlogin.xhtml" );

What is the viewId paramter exactly? is it the path?
I'm using icefaces version 2, are you sure viewHandler works on this version? 


When I left work on Friday I left my app running in chrome and ie8 after setting the session expiry limit to be 300 minutes.

First thing this morning I tried to navigate the app in these browsers both of which displayed a connection lost button which redirected to our login page when I clicked on it.

So touch wood I think this is finally working for me.

I've checked the console I don't have any messages about a missing window attribute.

We are using Icefaces 2 as well with the Mojarra JSF 2.0 libraries.

Sadly the code you are referencing I took directly from Banitz's phase listener solution above and I'd be lying if I said I knew exactly what it does but I do agree with you that is the path to the page you want to go to if the session expires (This is certainly what I have set it to).

The only thing I can think of is in Banitzs original he escaped the . char in his path. I wasn't sure if this was intentional or some cut and paste issue but kept the escape in anyway. I doubt this will fix your issue but maybe worth a try if you are desperate.
jbrice

Joined: 02/Mar/2011 19:19:37
Messages: 16
Offline


PFFF, now I'm desperate, I have tried on tomcat 6,7, it does not work at all!
It's weird, why is it working for you but not for me?
May the problem is spring-security !

Could you send a copy of your web.xml please?
Cheers
dspeed

Joined: 04/Mar/2011 03:32:32
Messages: 10
Offline


I've included our web.xml, we are not using Spring in any way in this app so that is one difference.

Code:
 <?xml version="1.0" encoding="UTF-8"?>
 <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
   <display-name>VendExpertTest</display-name>
   <welcome-file-list>
     <welcome-file>index.html</welcome-file>
     <welcome-file>index.htm</welcome-file>
     <welcome-file>index.jsp</welcome-file>
     <welcome-file>default.html</welcome-file>
     <welcome-file>default.htm</welcome-file>
     <welcome-file>default.jsp</welcome-file>
   </welcome-file-list>
   <servlet>
     <servlet-name>Faces Servlet</servlet-name>
     <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
     <load-on-startup>1</load-on-startup>
   </servlet>
   <servlet-mapping>
     <servlet-name>Faces Servlet</servlet-name>
     <url-pattern>/faces/*</url-pattern>
     <url-pattern>/icefaces/*</url-pattern>
     <url-pattern>*.jsf</url-pattern>
   </servlet-mapping>
     <servlet>
         <servlet-name>PDFServlet</servlet-name>
         <servlet-class>uk.co.servlet.PDFServlet</servlet-class>		
     </servlet>    
     <servlet-mapping>
         <servlet-name>PDFServlet</servlet-name>
         <url-pattern>/PDFServlet/*</url-pattern>
         
     </servlet-mapping>  
   
   
   
   <context-param>
     <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
     <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
     <param-value>server</param-value>
   </context-param>
   <context-param>
     <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
     <param-value>resources.application</param-value>
   </context-param>
   
    <filter>
  	<filter-name>session</filter-name>
  	<filter-class>uk.co.vianet.utilities.SessionTimeoutFilter</filter-class>
   </filter>
 
   <filter-mapping>
 	<filter-name>session</filter-name>
 	<url-pattern>*.xhtml</url-pattern>  	
   </filter-mapping>
   
    <filter>
  	<filter-name>restrict</filter-name>
  	<filter-class>uk.co.vianet.utilities.RestrictPageFilter</filter-class>
  </filter>
 
  <filter-mapping>
 	<filter-name>restrict</filter-name>
 	<url-pattern>*.xhtml</url-pattern>  	
  </filter-mapping>
   
   <listener>
     <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
   </listener>
   
   <servlet>
     <servlet-name>Resource Servlet</servlet-name>
     <servlet-class>com.icesoft.faces.webapp.CompatResourceServlet</servlet-class>
     <load-on-startup>1</load-on-startup>
   </servlet>
   <servlet-mapping>
     <servlet-name>Resource Servlet</servlet-name>
     <url-pattern>/xmlhttp/*</url-pattern>
   </servlet-mapping>
   <session-config>
     <session-timeout>300</session-timeout>
   </session-config>
 </web-app>
 
downloadTest

Joined: 01/Oct/2009 00:00:00
Messages: 2
Offline


I have the same problem, any progress?

Thanks.
krokodylowy3

Joined: 01/Feb/2008 00:00:00
Messages: 42
Offline


The problem still exist?

Krashan Brahmanjara
bhuvan

Joined: 19/Aug/2012 23:12:19
Messages: 14
Offline


I am facing the same issue.
[1] session timeout
[2] user do a activity.
[3] error in firebug - empty respose from server
[4] UI hangs forever
[5] user hit F5
[6] redirect to login page
[7] user input credential
[8] redirect to a xml error page
Code:
<partial-response>
 <error>
 <error-name>
 class org.icefaces.application.SessionExpiredException
 </error-name>
 <error-message>
 <![CDATA[ Session has expired ]]>
 </error-message>
 </error>
 <changes>
 <extension aceCallbackParam="validationFailed">{"validationFailed":false}</extension>
 </changes>
 </partial-response>

[9] user hit refresh ..user redirect to a normal application

This use to work fine in 1.8... i am now trying it with 3.3
During the debuging i figured out one major difference between 1.8 and 3.3

in 1.8 when session timeout and user do a activity the response to this request is of the form:
response.status = 200
response.reponseXML = <sessionTimeOut><sessionTimeOut/>

where as in 3.3 when session timeout and user do a activity the response is:
reponse.status = 302 with response.header.location = login page
since status is 302 browser itself make a request for login page.
To icefaces javascript code the response that it got looks like
response.status=200
reponse.responseXML=null
response.reponseHTML=<HTML CODE OF LOGIN PAGE>

and in jsf.js the response handler just logs a error if reponseXML is null.

So thats why icefaces does not redirect or show popup.

The above details is just my observation and might help somebody to figure out the problem and solution.

I am using icefaces 3.3, glassfish 3.1, spring 3.0.1
OuuGiii

Joined: 12/Feb/2019 07:17:23
Messages: 1
Offline


This bug still exist.
ateequr@sg.ibm.com

Joined: 21/Apr/2016 02:41:12
Messages: 1
Offline


Hi All,

We recently migrated to the ICEFaces 3.3.0_P07 version from ICEFaces 1.8 GA.

Our application is running with compatibility mode and We are using the latest configuration which you using and the same issue is persist.

ICEFaces needs to give correct solution for this without workaround.

Configuration :
<context-param>
<param-name>org.icefaces.lazyPush</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>org.icefaces.strictSessionTimeout</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.icefaces.sessionTimeoutRedirectURI</param-name>
<param-value>login.jsp</param-value>
</context-param>
<context-param>
<param-name>org.icefaces.sessionExpiredRedirectURI</param-name>
<param-value>login.jsp</param-value>
</context-param>
<context-param>
<param-name>org.icefaces.connectionLostRedirectURI</param-name>
<param-value>login.jsp</param-value>
</context-param>

error showing in browser console like below :
[icefaces] the response does not contain XML data
[icefaces] Error : [status: emptyResponse code:200]: An empty response was received from the server.


Thanks
[Thumb - ICEPushTryingToRedirectOne.png]
 Filename ICEPushTryingToRedirectOne.png [Disk] Download
 Description
 Filesize 98 Kbytes
 Downloaded:  134 time(s)

 
Forum Index -> General Help Go to Page: Previous  1, 2, 3
Go to:   
Powered by JForum 2.1.7ice © JForum Team