From 4623148e1e6fdb10e0ff58cfb85cd380775c74b9 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Mon, 18 Nov 2013 10:44:08 +0800 Subject: [PATCH] 1003491 System logs filled with zkoss error for several hours. Fixed NPE when native session have been destroyed. --- .../webui/session/SessionContextListener.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/session/SessionContextListener.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/session/SessionContextListener.java index 68c0a7275e..a733c4d078 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/session/SessionContextListener.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/session/SessionContextListener.java @@ -65,6 +65,19 @@ public class SessionContextListener implements ExecutionInit, Session session = exec.getDesktop().getSession(); Properties ctx = (Properties)session.getAttribute(SESSION_CTX); HttpSession httpSession = (HttpSession)session.getNativeSession(); + //create empty context if there's no valid native session + if (httpSession == null) + { + ctx = new Properties(); + ctx.put(ServerContextURLHandler.SERVER_CONTEXT_URL_HANDLER, new ServerContextURLHandler() { + public void showURL(String url) { + SessionManager.getAppDesktop().showURL(url, true); + } + }); + ServerContext.setCurrentInstance(ctx); + return; + } + if (ctx != null) { //verify ctx @@ -283,7 +296,7 @@ public class SessionContextListener implements ExecutionInit, HttpSession httpSession = (HttpSession)session.getNativeSession(); //verify ctx String cacheId = ctx.getProperty(SERVLET_SESSION_ID); - if (cacheId == null || !cacheId.equals(httpSession.getId()) ) + if (cacheId == null || httpSession == null || !cacheId.equals(httpSession.getId()) ) { return false; }