-1

A Java EE 8/SE 8 web application in deployement runnnig on Glassfish 5 build 25 both production and development, uses jsf 2.3. users create accounts and login. there is a 'logout' button for loging out.

Problem: 'logout' button works as expected everywhere on the website. EXCEPT home page (example.com) & (example.com/home.xhtml). the problem does not exists on my local computer. only in production (example.com).

So I have a template called : index.xhtml . all pages use it, including home.xhtml:

<ui:composition template="index.xhtml">
    <ui:define name="top-bar">
        <c:if test="#{request.remoteUser ne null}">
            <h:form ><h:commandButton value="Log out" action="#{registerAdvanced.logout}"/></h:form>
        </c:if>
    </ui:define>

and

@Named
@RequestScoped
public class RegisterAdvanced extends BaseBacking implements Serializable {
    public String logout() {
        try {
            getRequest().logout();
            getContext().getExternalContext().getSessionMap().remove("user");
            return REDIRECT_PAGE;
        } catch (ServletException ex) {
            return REDIRECT_PAGE;
        }
    }
}

Users login & logout fairly easily until I noticied that clicking on logout on the home page (home.xhtml) prints a null pointer exception AND redirect to 404 error page.

[[/home.xhtml @450,77 value="#{passesTestBean.displayPassSummaryList}": java.lang.NullPointerException
javax.el.ELException: /home.xhtml @450,77 value="#{passesTestBean.displayPassSummaryList}": java.lang.NullPointerException
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:119)
at com.sun.faces.facelets.component.UIRepeat.getValue(UIRepeat.java:314)
at com.sun.faces.facelets.component.UIRepeat.getDataModel(UIRepeat.java:256)
at com.sun.faces.facelets.component.UIRepeat.setIndex(UIRepeat.java:507)
at com.sun.faces.facelets.component.UIRepeat.process(UIRepeat.java:557)
at com.sun.faces.facelets.component.UIRepeat.processDecodes(UIRepeat.java:861)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1258)....

part of jsf where there is a call to value="#{passesTestBean.displayPassSummaryList}" is 100% seperate to logout and PassesTestBean CDI is request scope.

so the problem is SOMEHOW when I click on logout button. PassesTestBean is called for no reason and not since jsf must Initialize (since Request Scoped). it ends up returning null.

Now remember this only happens in: production at example.com AND only home page of all pages.

I'm thinking of writing a page only for loging out: has a log out button only.

usertest
  • 2,140
  • 4
  • 32
  • 51
  • Just one hint... read http://www.stackoverflow.com/tags/jsf/info about [mcve] – Kukeltje Sep 15 '19 at 19:44
  • @Kukeltje removed unnecessary jsf tags. I tried to include max of info because I don't know where the problem is. so I won't have to add info per request. do you still think the question is badly written? – usertest Sep 15 '19 at 20:01
  • Yes, it is **not** a [mcve]. E.g. the jsf info page says question should not use a template. And nowhere in the question the problematic bean is used and more... It's not about max info, it is about [mcve]. See also (for info) http://www.idownvotedbecau.se/nomcve – Kukeltje Sep 15 '19 at 20:28
  • "reproducible example"? the problem only happens in production at example.com for a specific page. ALL other pages use THE EXACT SAME CODE. it is really hard to make it reproducible. since at my computer all works, and at website all pages are working perfectly using same code with no change in code what so ever (JSF or CDI). it's great to have a template for questions but obviously NOT ALL questions can be presented like that. just my opinion. – usertest Sep 15 '19 at 20:34
  • Then tell me, how are you going to test a suggestion or guestimate on your production environment? Are you going to deploy it in your full application? Just trusting a stranger not to mess with the production app? What I would do is start creating a a non customer facing copy of the application and start stripping out chunks untill I have a, yes a [mcve]. But in the process, you might alread find differences in server/network topology that plays a role. So yes, the 'template' still fits. Good luck – Kukeltje Sep 16 '19 at 05:20
  • Also used application data are likely different. And Context parameters like JSF ProjectStage Development/Production or others are different on both systems. Please add the full StackTrace. So far I only see an ELException **caused by** some NPE anywhere else without further hint. – Selaron Sep 16 '19 at 06:25

1 Answers1

-1

Check for null pointer exception

getRequest().logout(); //here
getContext().getExternalContext().getSessionMap().remove("user");//here
Armen Arzumanyan
  • 1,939
  • 3
  • 30
  • 56
  • the call to the method never happen because jsf fails at value="#{passesTestBean.displayPassSummaryList}" since passesTestBean is null. what's weired about this problem is that it happens only at production at one specific page. – usertest Sep 15 '19 at 20:23
  • Your context is null in that page – Armen Arzumanyan Sep 16 '19 at 07:33