2013-03-12 55 views
1

我們開發了一個jsf Web應用程序,其中包含一個由webapp以編程方式註冊的Jaspic/JSR196模塊。使用Jaspic/JSR196模塊的weblogic中的會話失效

我們遵循以下博客中的說明來實現:http://arjan-tijms.blogspot.pt/

解決方案的工作確定對用戶進行認證:我們有收到一個用戶名和密碼,並調用request.authenticate方法的bean。該請求在服務器身份驗證模塊(SAM)中進行驗證,並且該用戶已通過身份驗證。

問題是,當在webapp中導航時,會話似乎經常失效,這使得用戶被重定向到登錄頁面。當request.getUserPrincipal在訪問受保護資源時返回null時,SAM模塊實現將用戶重定向到登錄頁面。我們沒有發現這種行爲的模式。

雖然分析日誌,我們發現了一些異常被拋出: (有時這些異常都顯示在網頁上。)

HttpSession中是無效的

會話失效正在進行中與不同線程

<Feb 26, 2013 5:16:12 PM GMT> <Error> <HTTP> <BEA-101020> <[[email protected][app:web-richfaces module:web-richfaces path:null spec-version:3.0]] Servlet failed with an Exception 
    java.lang.IllegalStateException: Session invalidation is in progress with different thread 
    at weblogic.servlet.internal.session.SessionData.invalidate(SessionData.java:880) 
    at weblogic.servlet.internal.ServletRequestImpl$SessionHelper.updateSessionId(ServletRequestImpl.java:3215) 
    at weblogic.servlet.internal.ServletObjectsFacadeImpl.updateSessionId(ServletObjectsFacadeImpl.java:54) 
    at weblogic.servlet.security.internal.SecurityModule.generateNewSession(SecurityModule.java:265) 
    at weblogic.servlet.security.internal.SecurityModule.login(SecurityModule.java:253) 
    at weblogic.security.jaspic.servlet.JaspicSecurityModule.checkUserPerm(JaspicSecurityModule.java:85) 
    at weblogic.servlet.security.internal.SecurityModule.checkAccess(SecurityModule.java:95) 
    at weblogic.servlet.security.internal.SecurityModule.isAuthorized(SecurityModule.java:543) 
    at weblogic.servlet.security.internal.WebAppSecurity.checkAccess(WebAppSecurity.java:499) 
    at weblogic.servlet.security.internal.WebAppSecurity.checkAccess(WebAppSecurity.java:463) 
    at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2119) 
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2089) 
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2074) 
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1513) 
    at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:254) 
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256) 
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:221) 

響應已經承諾

<Feb 26, 2013 5:06:16 PM GMT> <Error> <HTTP> <BEA-101020> <[[email protected][app:web-richfaces module:web-richfaces path:null spec-version:3.0]] Servlet failed with an Exception 
java.lang.IllegalStateException: Response already committed 
at weblogic.servlet.internal.ServletResponseImpl.objectIfCommitted(ServletResponseImpl.java:1651) 
at weblogic.servlet.internal.ServletResponseImpl.sendError(ServletResponseImpl.java:658) 
at weblogic.security.jaspic.servlet.JaspicSecurityModule.checkUserPerm(JaspicSecurityModule.java:87) 
at weblogic.servlet.security.internal.SecurityModule.checkAccess(SecurityModule.java:95) 
at weblogic.servlet.security.internal.SecurityModule.isAuthorized(SecurityModule.java:543) 
at weblogic.servlet.security.internal.WebAppSecurity.checkAccess(WebAppSecurity.java:499) 
at weblogic.servlet.security.internal.WebAppSecurity.checkAccess(WebAppSecurity.java:463) 
at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2119) 
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2089) 
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2074) 
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1513) 
at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:254) 
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256) 
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221) 

以下日誌條目表明,一個有效的會話沒有找到,因此用戶被重定向到登錄頁面:

<[email protected] - /prototype-web-richfaces/pages/customer/customer.jsf: SessionID: MmGLRsrCKrVs2ms2ZYcJbxB1LLngk7pZcjPP4Fd071b1JJLPyLTg!1600091307 found in cookie header> 
<[email protected] - /prototype-web-richfaces/pages/customer/customer.jsf: SessionID= MmGLRsrCKrVs2ms2ZYcJbxB1LLngk7pZcjPP4Fd071b1JJLPyLTg found for [email protected][app:web-richfaces module:web-richfaces path:/prototype-web-richfaces spec-version:3.0]> 
<[email protected] - /prototype-web-richfaces/pages/customer/customer.jsf: Trying to find session: MmGLRsrCKrVs2ms2ZYcJbxB1LLngk7pZcjPP4Fd071b1JJLPyLTg!1600091307> 
<[email protected] - /prototype-web-richfaces/pages/customer/customer.jsf: Trying other contexts to find valid session for id: MmGLRsrCKrVs2ms2ZYcJbxB1LLngk7pZcjPP4Fd071b1JJLPyLTg!1600091307> 
<[email protected] - /prototype-web-richfaces/pages/customer/customer.jsf: Couldn't find valid session for id: MmGLRsrCKrVs2ms2ZYcJbxB1LLngk7pZcjPP4Fd071b1JJLPyLTg!1600091307> 
[[ACTIVE] ExecuteThread: '6' for queue: 'weblogic.kernel.Default (self-tuning)'] INFO authentication.jaspic.TestServerAuthModule - Request URI: /prototype-web-richfaces/pages/customer/customer.jsf 
[[ACTIVE] ExecuteThread: '6' for queue: 'weblogic.kernel.Default (self-tuning)'] DEBUG authentication.jaspic.TestServerAuthModule - Principal is null. Redirecting to login page. 

看來,容器無效Http會話。但我們不明白爲什麼。 有什麼幫助嗎?

+2

這是否發生在單個服務器環境或羣集環境中? – Lan 2013-03-12 19:53:17

+0

如果問題似乎與SAM有關,您應該也可以發佈其代碼? – 2013-03-20 13:51:50

回答

2

添加到Lan的問題;你在使用什麼版本的WebLogic?如果你不認證,你是否也有這些會話問題?

另外,你是否只有一個應用程序運行在WebLogic或許多?請注意,博客在註冊時提到了「空」解決方法;如果您完全按照該方法進行操作,那麼您將爲該模塊註冊全部在該WebLogic實例上運行的應用程序。或者,您可以嘗試模式server [space] [context path],例如"server /prototype-web-richfaces"(請參閱博客文章的第10步中的表格)。請注意,JASPIC MR for Java EE 7 fixes this

如果您打電話request.authenticate意識到您的SAM將在請求中間被調用(如果您只是請求受保護的資源,它將在請求開始時調用)。請注意,如果您嘗試創建新會話並且正在使用request.authenticate,那麼您還沒有向響應寫入任何內容。 JSF操作方法通常有效,但請注意您已安裝的任何可能在此之前寫入的Servlet過濾器。

如果「響應已提交」,它看起來像WebLogic正在嘗試發送錯誤頁面,但由於某些內容已寫入響應,因此無法發送該頁面。你可能想要檢查那個根錯誤是什麼。

對於OmniFaces項目(實際上是OmniSecurity子項目),我們有created a SAM,這可能會給你另一個例子。不幸的是,這個特定的SAM有點複雜,所以它可能不是最好的例子,但是如果你想看到它在實際應用中被使用;還有an example of that(我已經在其他WebLogic 12c上測試過)。