[ 
https://issues.apache.org/jira/browse/OFBIZ-4289?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jacques Le Roux updated OFBIZ-4289:
-----------------------------------

    Attachment: OFBIZ-4289_Login_out_on_a 
cluster_handled_by_DeltaManager_causes_a_NPE.patch

OK, here is the plan:

from the delegatorName sets in session

session.setAttribute("delegatorName", delegatorName);

we can easily restitute, the 4 variables which are the problem:

// String delegatorName = session.getAttribute("delegatorName"); // set above, 
so always present
// Delegator delegator = DelegatorFactory.getDelegator(delegatorName);
// LocalDispatcher dispatcher = 
ContextFilter.makeWebappDispatcher(session.getServletContext(), delegator);
// Security security = SecurityFactory.getInstance(delegator)
// Authorization authz = AuthorizationFactory.getInstance(delegator)

I checked session.getAttribute() for each names in {*.java, *.groovy}, 
sessionAttributes.* in *.ftl, and in *een*.xml for the names themself, they are 
needed in 
# ControlServlet.doGet() (the 4)
# BirtWorker.setWebContextObjects() (delegator, dispatcher, security)
# ScrumEvents.timeSheetChecker() (delegator)

In ControlServlet.doGet(), getServletContext().getAttribute() is used to 
retrieve the 4 if missing => not a pb. Same for the others, if ever it's one 
then we can still use the lines of the snippet above in due places. I will not 
fix all OFBiz code for this issue, for instance I read in 
ScrumEvents.timeSheetChecker()

{code}
        Delegator delegator = (Delegator) session.getAttribute("delegator");
        [...]
        if (UtilValidate.isEmpty(delegator)) {
            delegator = (Delegator) request.getAttribute("delegator");
        }
{code}
Why not? (I guess it's C/P not refactored)
{code}
        Delegator delegator = (Delegator) request.getAttribute("delegator");
{code}
etc. 

So I believe we simply have to not put them in session when using distributable 
applications, see the attached patch . I refactored for easier/safer reading, 
and yes reversed the condition. I finally really wonder if they are usefull in 
session at all. I put a NOTE2 under the NOTE:
// NOTE: we do NOT want to set this in the servletContext, only in the request 
and session
// NOTE2: it would have been more helpful to know the why than the what (only 
few words)!



                
> Login out on a cluster handled by DeltaManager causes a NPE
> -----------------------------------------------------------
>
>                 Key: OFBIZ-4289
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-4289
>             Project: OFBiz
>          Issue Type: Bug
>          Components: framework
>    Affects Versions: Release Branch 4.0, Release Branch 09.04, Release Branch 
> 10.04, Release Branch 11.04, SVN trunk
>         Environment: Ubuntu
>            Reporter: Jacques Le Roux
>            Assignee: Jacques Le Roux
>            Priority: Critical
>              Labels: cluster, logout
>             Fix For: Release Branch 10.04, Release Branch 11.04, SVN trunk
>
>         Attachments: OFBIZ-4289_Login_out_on_a 
> cluster_handled_by_DeltaManager_causes_a_NPE.patch, OFBIZ-4289_Login_out_on_a 
> cluster_handled_by_DeltaManager_causes_a_NPE.patch, OFBIZ-4289_Login_out_on_a 
> cluster_handled_by_DeltaManager_causes_a_NPE.patch, OFBIZ-4289_Login_out_on_a 
> cluster_handled_by_DeltaManager_causes_a_NPE.patch, OFBIZ-4289_Login_out_on_a 
> cluster_handled_by_DeltaManager_causes_a_NPE.patch, OFBIZ-4289_Login_out_on_a 
> cluster_handled_by_DeltaManager_causes_a_NPE.patch, OFBIZ-4289_Login_out_on_a 
> cluster_handled_by_DeltaManager_causes_a_NPE.patch, changeset_2510.diff
>
>
> It works locally but not on clusters. You simply get a NPE.
> h3. 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 
> h3. 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).
> {code}
>     <Context>
>      <Manager className="org.apache.catalina.session.DeltatManager" 
> pathname="">
>      </Manager>
>     </Context>
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to