Xpages - 问题:'context.getUser()。getCommonName()'为空

时间:2012-09-22 14:27:39

标签: xpages xpages-ssjs

有没有人注意到这个问题:

'context.getUser()。getCommonName()'为null

我在一台特定服务器上遇到此问题,但无法在其他服务器上重现此问题。

任何帮助都将不胜感激。

这是问题的堆栈跟踪:

com.ibm.xsp.exception.EvaluationExceptionEx: Error while executing JavaScript computed expression
    com.ibm.xsp.binding.javascript.JavaScriptValueBinding.getValue(JavaScriptValueBinding.java:132)
    javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:451)
    com.ibm.xsp.component.UIDataPanelBase.isRenderedProp(UIDataPanelBase.java:81)
    com.ibm.xsp.component.UIDataPanelBase.fillShadowedFlags(UIDataPanelBase.java:231)
    com.ibm.xsp.component.UIDataPanelBase.encodeBegin(UIDataPanelBase.java:240)
    com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:840)
    com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)
    com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)
    com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)
    com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)
    com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)
    com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)
    com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)
    com.ibm.xsp.component.UIViewRootEx._renderView(UIViewRootEx.java:1317)
    com.ibm.xsp.component.UIViewRootEx.renderView(UIViewRootEx.java:1255)
    com.ibm.xsp.application.ViewHandlerExImpl.doRender(ViewHandlerExImpl.java:641)
    com.ibm.xsp.application.ViewHandlerExImpl._renderView(ViewHandlerExImpl.java:320)
    com.ibm.xsp.application.ViewHandlerExImpl.renderView(ViewHandlerExImpl.java:335)
    com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:103)
    com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:210)
    com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:120)
    com.ibm.xsp.controller.FacesControllerImpl.render(FacesControllerImpl.java:264)
    com.ibm.xsp.webapp.FacesServlet.serviceView(FacesServlet.java:248)
    com.ibm.xsp.webapp.FacesServletEx.serviceView(FacesServletEx.java:200)
    com.ibm.xsp.webapp.FacesServlet.service(FacesServlet.java:160)
    com.ibm.xsp.webapp.FacesServletEx.service(FacesServletEx.java:137)
    com.ibm.xsp.webapp.DesignerFacesServlet.service(DesignerFacesServlet.java:103)
    com.ibm.designer.runtime.domino.adapter.ComponentModule.invokeServlet(ComponentModule.java:576)
    com.ibm.domino.xsp.module.nsf.NSFComponentModule.invokeServlet(NSFComponentModule.java:1267)
    com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(ComponentModule.java:847)
    com.ibm.designer.runtime.domino.adapter.ComponentModule$ServletInvoker.doService(ComponentModule.java:796)
    com.ibm.designer.runtime.domino.adapter.ComponentModule.doService(ComponentModule.java:565)
    com.ibm.domino.xsp.module.nsf.NSFComponentModule.doService(NSFComponentModule.java:1251)
    com.ibm.domino.xsp.module.nsf.NSFService.doServiceInternal(NSFService.java:598)
    com.ibm.domino.xsp.module.nsf.NSFService.doService(NSFService.java:421)
    com.ibm.designer.runtime.domino.adapter.LCDEnvironment.doService(LCDEnvironment.java:341)
    com.ibm.designer.runtime.domino.adapter.LCDEnvironment.service(LCDEnvironment.java:297)
    com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.service(XspCmdManager.java:272)
com.ibm.jscript.InterpretException: Script interpreter error, line=1, col=35: 'context.getUser().getCommonName()' is null
    com.ibm.jscript.InterpretException.<init>(InterpretException.java:123)
    com.ibm.jscript.ASTTree.ASTMember.interpret(ASTMember.java:97)
    com.ibm.jscript.ASTTree.ASTCall.interpret(ASTCall.java:88)
    com.ibm.jscript.ASTTree.binaryop.ASTBinaryDefaultOp.interpret(ASTBinaryDefaultOp.java:49)
    com.ibm.jscript.ASTTree.ASTProgram.interpret(ASTProgram.java:119)
    com.ibm.jscript.ASTTree.ASTProgram.interpretEx(ASTProgram.java:139)
    com.ibm.jscript.JSExpression._interpretExpression(JSExpression.java:435)
    com.ibm.jscript.JSExpression.access$1(JSExpression.java:424)
    com.ibm.jscript.JSExpression$2.run(JSExpression.java:414)
    java.security.AccessController.doPrivileged(AccessController.java:284)
    com.ibm.jscript.JSExpression.interpretExpression(JSExpression.java:410)
    com.ibm.jscript.JSExpression.evaluateValue(JSExpression.java:251)
    com.ibm.jscript.JSExpression.evaluateValue(JSExpression.java:234)
    com.ibm.xsp.javascript.JavaScriptInterpreter.interpret(JavaScriptInterpreter.java:221)
    com.ibm.xsp.javascript.JavaScriptInterpreter.interpret(JavaScriptInterpreter.java:193)
    com.ibm.xsp.binding.javascript.JavaScriptValueBinding.getValue(JavaScriptValueBinding.java:78)
    javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:451)
    com.ibm.xsp.component.UIDataPanelBase.isRenderedProp(UIDataPanelBase.java:81)
    com.ibm.xsp.component.UIDataPanelBase.fillShadowedFlags(UIDataPanelBase.java:231)
    com.ibm.xsp.component.UIDataPanelBase.encodeBegin(UIDataPanelBase.java:240)
    com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:840)
    com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)
    com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)
    com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)
    com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)
    com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)
    com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)
    com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)
    com.ibm.xsp.component.UIViewRootEx._renderView(UIViewRootEx.java:1317)
    com.ibm.xsp.component.UIViewRootEx.renderView(UIViewRootEx.java:1255)
    com.ibm.xsp.application.ViewHandlerExImpl.doRender(ViewHandlerExImpl.java:641)
    com.ibm.xsp.application.ViewHandlerExImpl._renderView(ViewHandlerExImpl.java:320)
    com.ibm.xsp.application.ViewHandlerExImpl.renderView(ViewHandlerExImpl.java:335)
    com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:103)
    com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:210)
    com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:120)
    com.ibm.xsp.controller.FacesControllerImpl.render(FacesControllerImpl.java:264)
    com.ibm.xsp.webapp.FacesServlet.serviceView(FacesServlet.java:248)
    com.ibm.xsp.webapp.FacesServletEx.serviceView(FacesServletEx.java:200)
    com.ibm.xsp.webapp.FacesServlet.service(FacesServlet.java:160)
    com.ibm.xsp.webapp.FacesServletEx.service(FacesServletEx.java:137)
    com.ibm.xsp.webapp.DesignerFacesServlet.service(DesignerFacesServlet.java:103)
    com.ibm.designer.runtime.domino.adapter.ComponentModule.invokeServlet(ComponentModule.java:576)
    com.ibm.domino.xsp.module.nsf.NSFComponentModule.invokeServlet(NSFComponentModule.java:1267)
    com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(ComponentModule.java:847)
    com.ibm.designer.runtime.domino.adapter.ComponentModule$ServletInvoker.doService(ComponentModule.java:796)
    com.ibm.designer.runtime.domino.adapter.ComponentModule.doService(ComponentModule.java:565)
    com.ibm.domino.xsp.module.nsf.NSFComponentModule.doService(NSFComponentModule.java:1251)
    com.ibm.domino.xsp.module.nsf.NSFService.doServiceInternal(NSFService.java:598)
    com.ibm.domino.xsp.module.nsf.NSFService.doService(NSFService.java:421)
    com.ibm.designer.runtime.domino.adapter.LCDEnvironment.doService(LCDEnvironment.java:341)
    com.ibm.designer.runtime.domino.adapter.LCDEnvironment.service(LCDEnvironment.java:297)
    com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.service(XspCmdManager.java:272)

4 个答案:

答案 0 :(得分:1)

我仍然不确定为什么这会导致某个特定服务器上的错误,而不是其他服务器上的错误。我决定在平均时间内使用session.getEffectiveUserName()来解决这个问题。

答案 1 :(得分:1)

对于通过辅助多米诺通讯簿进行身份验证的用户,我们也遇到了这个问题(通过目录服务进行了解) 我们决定不再使用“ context.getUser()”:

  • 通过database.queryAccessRoles(session.getEffectiveUserName())替换context.getUser()。getRoles()
  • 用userBean.commonName替换context.getUser()。getFullName()
  • 用userBean.commonName替换context.getUser()。getCommonName()
  • (即使此方法可行)也可以将session.getEffectiveUserName()替换context.getUser()。getDistinguishedName()
  • 用_getUserGroupNameList()替换context.getUser()。getGroups() (不是由session.getUserGroupNameList()而是NotesName列表而不是字符串)

    function _getUserGroupNameList() {
        var lNotesName:java.util.Vector = session.getUserGroupNameList(); // list of NotesName
        var lString:java.util.Vector = new java.util.Vector();
        for (var i = 0; i < lNotesName.size(); i++) lString.add(lNotesName.get(i).getCanonical());
        return lString;
    }
    

答案 2 :(得分:0)

我构建了一个快速示例,无法重现错误

<xp:text escape="true" id="computedField1"
    value="#{javascript:context.getUser().getCommonName()}" />

你在做什么?

顺便说一下,你也可以使用EL

    <xp:text escape="true" id="computedField1"
    value="#{context.user.commonName}" />

答案 3 :(得分:0)

我目前有这个问题。它与此服务器上的用户ID和NAB有关。我不知道究竟是什么,但我的id密码摘要有问题。这意味着我在此特定服务器上的人员文档(名称)中的密码未与我的ID上的psw同步。所以在笔记客户端我得到了“抱歉你被锁定”的消息。我现在刷新了密码并可以登录,但之后就开始了。我无法获得用户名。既不是上下文,也不是会话。基本上它很有趣。