svn commit: r1132758 - in /ofbiz/branches/release11.04: ./ applications/order/script/org/ofbiz/order/customer/ applications/party/webapp/partymgr/WEB-INF/actions/party/ applications/product/script/org/ofbiz/product/test/ framework/common/widget/ framew...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1132758 - in /ofbiz/branches/release11.04: ./ applications/order/script/org/ofbiz/order/customer/ applications/party/webapp/partymgr/WEB-INF/actions/party/ applications/product/script/org/ofbiz/product/test/ framework/common/widget/ framew...

jleroux@apache.org
Author: jleroux
Date: Mon Jun  6 20:43:50 2011
New Revision: 1132758

URL: http://svn.apache.org/viewvc?rev=1132758&view=rev
Log:
"Applied fix from trunk for revision: 1132749"
------------------------------------------------------------------------
r1132749 | jleroux | 2011-06-06 22:26:35 +0200 (lun., 06 juin 2011) | 19 lines

Closes "Login out on a cluster handled by DeltaManager causes a NPE" https://issues.apache.org/jira/browse/OFBIZ-4289

It works locally but not on clusters. You simply get a NPE.

Problem
    When we logout we cross an issue due to Tomcat sessions persistence.
    Because we set distributable to true, to allow sessions failover,
    and use and DeltaManager for replication.
    Delegator and other main Classes (notably Dispatcher) are not serialized in OFBiz. This is the origin of the problem

Tried solutions
By default DeltaManager save active sessions on disk. It uses a private String variable pathname for that (default to "SESSIONS.ser"). You can set it to null, to avoid session persistence, using a context.xml file in the WEB-INF folder with content like below. But I tried it in webtools app on staging qs001 (only) and it did not work (with distributable set to false). And we have no other means to set it from OFBiz (OOTB).

<Context>
     <Manager className="org.apache.catalina.session.DeltatManager" pathname="">
     </Manager>
</Context>


------------------------------------------------------------------------


Modified:
    ofbiz/branches/release11.04/   (props changed)
    ofbiz/branches/release11.04/applications/order/script/org/ofbiz/order/customer/CheckoutMapProcs.xml   (props changed)
    ofbiz/branches/release11.04/applications/party/webapp/partymgr/WEB-INF/actions/party/PartyFinancialHistory.groovy   (props changed)
    ofbiz/branches/release11.04/applications/product/script/org/ofbiz/product/test/InventoryTests.xml   (props changed)
    ofbiz/branches/release11.04/framework/common/widget/HelpScreens.xml   (props changed)
    ofbiz/branches/release11.04/framework/security/data/PasswordSecurityData.xml   (props changed)
    ofbiz/branches/release11.04/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java
    ofbiz/branches/release11.04/specialpurpose/ebaystore/lib/   (props changed)
    ofbiz/branches/release11.04/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/Facilities.groovy   (props changed)
    ofbiz/branches/release11.04/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductList.groovy   (props changed)
    ofbiz/branches/release11.04/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductStockTake.groovy   (props changed)

Propchange: ofbiz/branches/release11.04/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jun  6 20:43:50 2011
@@ -2,4 +2,4 @@
 /ofbiz/branches/dojo1.4:951708-952957
 /ofbiz/branches/jquery:952958-1044489
 /ofbiz/branches/multitenant20100310:921280-927264
-/ofbiz/trunk:1100197,1100880,1104423,1131144,1131396,1132496
+/ofbiz/trunk:1100197,1100880,1104423,1131144,1131396,1132496,1132749

Propchange: ofbiz/branches/release11.04/applications/order/script/org/ofbiz/order/customer/CheckoutMapProcs.xml
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jun  6 20:43:50 2011
@@ -2,4 +2,4 @@
 /ofbiz/branches/dojo1.4/applications/order/script/org/ofbiz/order/customer/CheckoutMapProcs.xml:951708-952957
 /ofbiz/branches/jquery/applications/order/script/org/ofbiz/order/customer/CheckoutMapProcs.xml:952958-1044489
 /ofbiz/branches/multitenant20100310/applications/order/script/org/ofbiz/order/customer/CheckoutMapProcs.xml:921280-927264
-/ofbiz/trunk/applications/order/script/org/ofbiz/order/customer/CheckoutMapProcs.xml:1100197,1100880,1104423,1131144,1131396,1132496
+/ofbiz/trunk/applications/order/script/org/ofbiz/order/customer/CheckoutMapProcs.xml:1100197,1100880,1104423,1131144,1131396,1132496,1132749

Propchange: ofbiz/branches/release11.04/applications/party/webapp/partymgr/WEB-INF/actions/party/PartyFinancialHistory.groovy
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jun  6 20:43:50 2011
@@ -2,4 +2,4 @@
 /ofbiz/branches/dojo1.4/applications/party/webapp/partymgr/WEB-INF/actions/party/PartyFinancialHistory.groovy:951708-952957
 /ofbiz/branches/jquery/applications/party/webapp/partymgr/WEB-INF/actions/party/PartyFinancialHistory.groovy:952958-1044489
 /ofbiz/branches/multitenant20100310/applications/party/webapp/partymgr/WEB-INF/actions/party/PartyFinancialHistory.groovy:921280-927264
-/ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/PartyFinancialHistory.groovy:1100197,1100880,1104423,1131144,1131396,1132496
+/ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/PartyFinancialHistory.groovy:1100197,1100880,1104423,1131144,1131396,1132496,1132749

Propchange: ofbiz/branches/release11.04/applications/product/script/org/ofbiz/product/test/InventoryTests.xml
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jun  6 20:43:50 2011
@@ -2,4 +2,4 @@
 /ofbiz/branches/dojo1.4/applications/product/script/org/ofbiz/product/test/InventoryTests.xml:951708-952957
 /ofbiz/branches/jquery/applications/product/script/org/ofbiz/product/test/InventoryTests.xml:952958-1044489
 /ofbiz/branches/multitenant20100310/applications/product/script/org/ofbiz/product/test/InventoryTests.xml:921280-927264
-/ofbiz/trunk/applications/product/script/org/ofbiz/product/test/InventoryTests.xml:1100197,1100880,1104423,1131144,1131396,1132496
+/ofbiz/trunk/applications/product/script/org/ofbiz/product/test/InventoryTests.xml:1100197,1100880,1104423,1131144,1131396,1132496,1132749

Propchange: ofbiz/branches/release11.04/framework/common/widget/HelpScreens.xml
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jun  6 20:43:50 2011
@@ -2,4 +2,4 @@
 /ofbiz/branches/dojo1.4/framework/common/widget/HelpScreens.xml:951708-952957
 /ofbiz/branches/jquery/framework/common/widget/HelpScreens.xml:952958-1044489
 /ofbiz/branches/multitenant20100310/framework/common/widget/HelpScreens.xml:921280-927264
-/ofbiz/trunk/framework/common/widget/HelpScreens.xml:1100197,1100880,1104423,1131144,1131396,1132496
+/ofbiz/trunk/framework/common/widget/HelpScreens.xml:1100197,1100880,1104423,1131144,1131396,1132496,1132749

Propchange: ofbiz/branches/release11.04/framework/security/data/PasswordSecurityData.xml
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jun  6 20:43:50 2011
@@ -2,4 +2,4 @@
 /ofbiz/branches/dojo1.4/applications/securityext/data/PasswordSecurityData.xml:951708-952957
 /ofbiz/branches/jquery/applications/securityext/data/PasswordSecurityData.xml:952958-1044489
 /ofbiz/branches/multitenant20100310/applications/securityext/data/PasswordSecurityData.xml:921280-927264
-/ofbiz/trunk/framework/security/data/PasswordSecurityData.xml:1100197,1100880,1104423,1131144,1131396,1132496
+/ofbiz/trunk/framework/security/data/PasswordSecurityData.xml:1100197,1100880,1104423,1131144,1131396,1132496,1132749

Modified: ofbiz/branches/release11.04/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release11.04/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java?rev=1132758&r1=1132757&r2=1132758&view=diff
==============================================================================
--- ofbiz/branches/release11.04/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java (original)
+++ ofbiz/branches/release11.04/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java Mon Jun  6 20:43:50 2011
@@ -39,6 +39,8 @@ import javolution.util.FastList;
 import javolution.util.FastMap;
 
 import org.ofbiz.base.component.ComponentConfig;
+import org.ofbiz.base.container.ContainerConfig;
+import org.ofbiz.base.container.ContainerException;
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.GeneralException;
 import org.ofbiz.base.util.KeyStoreUtil;
@@ -435,7 +437,7 @@ public class LoginWorker {
         if (ModelService.RESPOND_SUCCESS.equals(result.get(ModelService.RESPONSE_MESSAGE))) {
             if (setupNewDelegatorEtc) {
                 // now set the delegator and dispatcher in a bunch of places just in case they were changed
-                setWebContextObjects(request, response, delegator, dispatcher);
+                setWebContextObjects(request, response, delegator, dispatcher, true);
             }
             
             // check to see if a password change is required for the user
@@ -466,33 +468,46 @@ public class LoginWorker {
         }
     }
     
-    private static void setWebContextObjects(HttpServletRequest request, HttpServletResponse response, Delegator delegator, LocalDispatcher dispatcher) {
+    /*         persistSerialized is set at false in the context of a cluster when using (at least) DeltaManager.
+            Because we have no easy ways to set DeltaManager.pathname to null from OFBiz
+           So persistSerialized is set to true when login out. This prevent a NPE due to non serialized objects put in session*/
+    private static void setWebContextObjects(HttpServletRequest request, HttpServletResponse response, Delegator delegator, LocalDispatcher dispatcher, Boolean persistSerialized) {
         HttpSession session = request.getSession();
         
         // NOTE: we do NOT want to set this in the servletContet, only in the request and session
         session.setAttribute("delegatorName", delegator.getDelegatorName());
         
         request.setAttribute("delegator", delegator);
-        session.setAttribute("delegator", delegator);
+        if (!persistSerialized) {
+            session.setAttribute("delegator", null);
+        } else {
+            session.setAttribute("delegator", delegator);
+        }
         
         request.setAttribute("dispatcher", dispatcher);
-        session.setAttribute("dispatcher", dispatcher);
-        
-        // we also need to setup the security and authz objects since they are dependent on the delegator
-        try {
-            Security security = SecurityFactory.getInstance(delegator);
-            request.setAttribute("security", security);
-            session.setAttribute("security", security);
-        } catch (SecurityConfigurationException e) {
-            Debug.logError(e, module);
+        if (!persistSerialized) {
+            session.setAttribute("dispatcher", null);
+        } else {
+            session.setAttribute("dispatcher", dispatcher);
         }
         
-        try {
-            Authorization authz = AuthorizationFactory.getInstance(delegator);
-            request.setAttribute("authz", authz);
-            session.setAttribute("authz", authz);
-        } catch (SecurityConfigurationException e) {
-            Debug.logError(e, module);
+        if (persistSerialized) {
+            // we also need to setup the security and authz objects since they are dependent on the delegator
+            try {
+                Security security = SecurityFactory.getInstance(delegator);
+                request.setAttribute("security", security);
+                session.setAttribute("security", security);
+            } catch (SecurityConfigurationException e) {
+                Debug.logError(e, module);
+            }
+            
+            try {
+                Authorization authz = AuthorizationFactory.getInstance(delegator);
+                request.setAttribute("authz", authz);
+                session.setAttribute("authz", authz);
+            } catch (SecurityConfigurationException e) {
+                Debug.logError(e, module);
+            }
         }
         
         // get rid of the visit info since it was pointing to the previous database, and get a new one
@@ -628,7 +643,22 @@ public class LoginWorker {
 
             delegator = DelegatorFactory.getDelegator(delegatorName);
             LocalDispatcher dispatcher = ContextFilter.makeWebappDispatcher(session.getServletContext(), delegator);
-            setWebContextObjects(request, response, delegator, dispatcher);
+            // get the container configuration          
+            String ofbizHome = System.getProperty("ofbiz.home");
+            String configFile = ofbizHome + "/framework/base/config/ofbiz-containers.xml";
+            ContainerConfig.Container cc = null;
+            String mgrClassName = null;
+            try {
+                cc = ContainerConfig.getContainer("catalina-container", configFile);
+                mgrClassName = ContainerConfig.getPropertyValue(cc, "manager-class", "org.apache.catalina.ha.session.DeltaManager");
+            } catch (ContainerException e) {
+                Debug.logError(e, "No catalina-container configuration found in container config!");
+            }
+            if ("org.apache.catalina.ha.session.DeltaManager".equals(mgrClassName)) {
+                setWebContextObjects(request, response, delegator, dispatcher, false);
+            } else {
+                setWebContextObjects(request, response, delegator, dispatcher, true);
+            }
         }
         
         // DON'T save the cart, causes too many problems: if (shoppingCart != null) session.setAttribute("shoppingCart", new WebShoppingCart(shoppingCart, session));
@@ -942,7 +972,7 @@ public class LoginWorker {
             if (!oldDelegatorName.equals(userLogin.getDelegator().getDelegatorName())) {
                 delegator = DelegatorFactory.getDelegator(userLogin.getDelegator().getDelegatorName());
                 dispatcher = ContextFilter.makeWebappDispatcher(servletContext, delegator);
-                setWebContextObjects(request, response, delegator, dispatcher);
+                setWebContextObjects(request, response, delegator, dispatcher, true);
             }
             // found userLogin, do the external login...
 

Propchange: ofbiz/branches/release11.04/specialpurpose/ebaystore/lib/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jun  6 20:43:50 2011
@@ -2,4 +2,4 @@
 /ofbiz/branches/dojo1.4/specialpurpose/ebaystore/lib:951708-952957
 /ofbiz/branches/jquery/specialpurpose/ebaystore/lib:952958-1044489
 /ofbiz/branches/multitenant20100310/specialpurpose/ebaystore/lib:921280-927264
-/ofbiz/trunk/specialpurpose/ebaystore/lib:1100197,1100880,1104423,1131144,1131396,1132496
+/ofbiz/trunk/specialpurpose/ebaystore/lib:1100197,1100880,1104423,1131144,1131396,1132496,1132749

Propchange: ofbiz/branches/release11.04/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/Facilities.groovy
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jun  6 20:43:50 2011
@@ -2,4 +2,4 @@
 /ofbiz/branches/dojo1.4/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/Facilities.groovy:951708-952957
 /ofbiz/branches/jquery/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/Facilities.groovy:952958-1044489
 /ofbiz/branches/multitenant20100310/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/Facilities.groovy:921280-927264
-/ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/Facilities.groovy:1100197,1100880,1104423,1131144,1131396,1132496
+/ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/Facilities.groovy:1100197,1100880,1104423,1131144,1131396,1132496,1132749

Propchange: ofbiz/branches/release11.04/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductList.groovy
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jun  6 20:43:50 2011
@@ -2,4 +2,4 @@
 /ofbiz/branches/dojo1.4/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductList.groovy:951708-952957
 /ofbiz/branches/jquery/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductList.groovy:952958-1044489
 /ofbiz/branches/multitenant20100310/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductList.groovy:921280-927264
-/ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductList.groovy:1100197,1100880,1104423,1131144,1131396,1132496
+/ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductList.groovy:1100197,1100880,1104423,1131144,1131396,1132496,1132749

Propchange: ofbiz/branches/release11.04/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductStockTake.groovy
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jun  6 20:43:50 2011
@@ -2,4 +2,4 @@
 /ofbiz/branches/dojo1.4/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductStockTake.groovy:951708-952957
 /ofbiz/branches/jquery/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductStockTake.groovy:952958-1044489
 /ofbiz/branches/multitenant20100310/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductStockTake.groovy:921280-927264
-/ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductStockTake.groovy:1100197,1100880,1104423,1131144,1131396,1132496
+/ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductStockTake.groovy:1100197,1100880,1104423,1131144,1131396,1132496,1132749