Xpages ExtLibUtil.getCurrentSessionAsSigner() returns 空

Xpages ExtLibUtil.getCurrentSessionAsSigner() returns null

我在 beforePageLoad 事件上有一些 java 代码 运行。我尝试在构造函数中使用 ExtLibUtil class 获取 sessionAsSigner 对象,但不幸的是我收到 null。这可能是什么原因?这是我的 class。

package com.mycompany.activiti;

public class ActivitiWorkflow { 
    private Session sAsSigner = null;   
    private String currentUser = null;  
    private Database db

    public ActivitiWorkflow() throws NotesException {
        currentUser = DominoUtils.getCurrentSession().getEffectiveUserName();       
        sAsSigner = ExtLibUtil.getCurrentSessionAsSigner();

        db = sAsSigner.getCurrentDatabase();
        //...
    }

    public void foo(){...}
}

我在 beforePageLoad 事件中使用以下代码运行它:

importPackage(com.mycompany.activiti);
var workflow:ActivitiWorkflow = new ActivitiWorkflow();
workflow.foo();

我使用以下堆栈跟踪阅读它

com.ibm.xsp.exception.EvaluationExceptionEx: Error while executing JavaScript action expression
    com.ibm.xsp.binding.javascript.JavaScriptMethodBinding.invoke(JavaScriptMethodBinding.java:126)
    com.ibm.xsp.component.UIIncludeComposite.initBeforePageContents(UIIncludeComposite.java:672)
    com.ibm.xsp.page.compiled.AbstractCompiledPage.initComponent(AbstractCompiledPage.java:339)
    com.ibm.xsp.page.compiled.AbstractCompiledPage.createTree(AbstractCompiledPage.java:256)
    com.ibm.xsp.page.compiled.AbstractCompiledPage.addComponent(AbstractCompiledPage.java:389)
    com.ibm.xsp.component.UIIncludeComposite.buildContents(UIIncludeComposite.java:453)
    com.ibm.xsp.page.compiled.AbstractCompiledPage.initComponent(AbstractCompiledPage.java:334)
    com.ibm.xsp.page.compiled.CompiledComponentBuilder.buildChildren(CompiledComponentBuilder.java:123)
    com.ibm.xsp.page.compiled.CompiledComponentBuilder.buildAll(CompiledComponentBuilder.java:84)
    com.ibm.xsp.component.UIViewRootEx.buildContents(UIViewRootEx.java:1649)
    com.ibm.xsp.component.UIViewRootEx2.buildContents(UIViewRootEx2.java:247)
    com.ibm.xsp.page.compiled.AbstractCompiledPage.initComponent(AbstractCompiledPage.java:334)
    com.ibm.xsp.page.compiled.AbstractCompiledPage.createTree(AbstractCompiledPage.java:256)
    com.ibm.xsp.page.compiled.AbstractCompiledPage.createViewRoot(AbstractCompiledPage.java:167)
    com.ibm.xsp.application.ViewHandlerExImpl._createViewRoot(ViewHandlerExImpl.java:521)
    com.ibm.xsp.application.ViewHandlerExImpl.createViewRoot(ViewHandlerExImpl.java:567)
    com.ibm.xsp.application.ViewHandlerExImpl.doCreateView(ViewHandlerExImpl.java:142)
    com.ibm.xsp.application.ViewHandlerEx.createView(ViewHandlerEx.java:90)
    com.ibm.xsp.webapp.FacesServlet.serviceView(FacesServlet.java:251)
    com.ibm.xsp.webapp.FacesServletEx.serviceView(FacesServletEx.java:157)
    com.ibm.xsp.webapp.FacesServlet.service(FacesServlet.java:160)
    com.ibm.xsp.webapp.FacesServletEx.service(FacesServletEx.java:138)
    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:1335)
    com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(ComponentModule.java:853)
    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:1319)
    com.ibm.domino.xsp.module.nsf.NSFService.doServiceInternal(NSFService.java:662)
    com.ibm.domino.xsp.module.nsf.NSFService.doService(NSFService.java:482)
    com.ibm.designer.runtime.domino.adapter.LCDEnvironment.doService(LCDEnvironment.java:357)
    com.ibm.designer.runtime.domino.adapter.LCDEnvironment.service(LCDEnvironment.java:313)
    com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.service(XspCmdManager.java:272)
com.ibm.jscript.InterpretException: Script interpreter error, line=141, col=45: Error while calling java constructor 'com.mycompany.activiti.ActivitiWorkflow()' (java.lang.reflect.InvocationTargetException).
    com.ibm.jscript.types.JavaAccessObject.construct(JavaAccessObject.java:262)
    com.ibm.jscript.types.JavaWrapperObject.construct(JavaWrapperObject.java:1)
    com.ibm.jscript.ASTTree.ASTNew.interpret(ASTNew.java:109)
    com.ibm.jscript.ASTTree.ASTVariableDecl.interpret(ASTVariableDecl.java:82)
    com.ibm.jscript.ASTTree.ASTDebug.interpret(ASTDebug.java:148)
    com.ibm.jscript.std.FunctionObject._executeFunction(FunctionObject.java:261)
    com.ibm.jscript.std.FunctionObject.executeFunction(FunctionObject.java:185)
    com.ibm.jscript.std.FunctionObject.call(FunctionObject.java:171)
    com.ibm.jscript.types.FBSObject.call(FBSObject.java:161)
    com.ibm.jscript.ASTTree.ASTCall.interpret(ASTCall.java:197)
    com.ibm.jscript.ASTTree.ASTArgumentList.interpretArguments(ASTArgumentList.java:65)
    com.ibm.jscript.types.FBSObject.call(FBSObject.java:153)
    com.ibm.jscript.ASTTree.ASTCall.interpret(ASTCall.java:197)
    com.ibm.jscript.ASTTree.ASTDebug.interpret(ASTDebug.java:148)
    com.ibm.jscript.ASTTree.ASTBlock.interpret(ASTBlock.java:100)
    com.ibm.jscript.ASTTree.ASTDebug.interpret(ASTDebug.java:148)
    com.ibm.jscript.ASTTree.ASTIf.interpret(ASTIf.java:85)
    com.ibm.jscript.ASTTree.ASTDebug.interpret(ASTDebug.java:148)
    com.ibm.jscript.std.FunctionObject._executeFunction(FunctionObject.java:261)
    com.ibm.jscript.std.FunctionObject.executeFunction(FunctionObject.java:185)
    com.ibm.jscript.std.FunctionObject.call(FunctionObject.java:171)
    com.ibm.jscript.types.FBSObject.call(FBSObject.java:161)
    com.ibm.jscript.ASTTree.ASTCall.interpret(ASTCall.java:197)
    com.ibm.jscript.ASTTree.ASTDebug.interpret(ASTDebug.java:148)
    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(JSExpression.java:424)
    com.ibm.jscript.JSExpression.run(JSExpression.java:414)
    java.security.AccessController.doPrivileged(AccessController.java:448)
    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:222)
    com.ibm.xsp.binding.javascript.JavaScriptMethodBinding.invoke(JavaScriptMethodBinding.java:111)
    com.ibm.xsp.component.UIIncludeComposite.initBeforePageContents(UIIncludeComposite.java:672)
    com.ibm.xsp.page.compiled.AbstractCompiledPage.initComponent(AbstractCompiledPage.java:339)
    com.ibm.xsp.page.compiled.AbstractCompiledPage.createTree(AbstractCompiledPage.java:256)
    com.ibm.xsp.page.compiled.AbstractCompiledPage.addComponent(AbstractCompiledPage.java:389)
    com.ibm.xsp.component.UIIncludeComposite.buildContents(UIIncludeComposite.java:453)
    com.ibm.xsp.page.compiled.AbstractCompiledPage.initComponent(AbstractCompiledPage.java:334)
    com.ibm.xsp.page.compiled.CompiledComponentBuilder.buildChildren(CompiledComponentBuilder.java:123)
    com.ibm.xsp.page.compiled.CompiledComponentBuilder.buildAll(CompiledComponentBuilder.java:84)
    com.ibm.xsp.component.UIViewRootEx.buildContents(UIViewRootEx.java:1649)
    com.ibm.xsp.component.UIViewRootEx2.buildContents(UIViewRootEx2.java:247)
    com.ibm.xsp.page.compiled.AbstractCompiledPage.initComponent(AbstractCompiledPage.java:334)
    com.ibm.xsp.page.compiled.AbstractCompiledPage.createTree(AbstractCompiledPage.java:256)
    com.ibm.xsp.page.compiled.AbstractCompiledPage.createViewRoot(AbstractCompiledPage.java:167)
    com.ibm.xsp.application.ViewHandlerExImpl._createViewRoot(ViewHandlerExImpl.java:521)
    com.ibm.xsp.application.ViewHandlerExImpl.createViewRoot(ViewHandlerExImpl.java:567)
    com.ibm.xsp.application.ViewHandlerExImpl.doCreateView(ViewHandlerExImpl.java:142)
    com.ibm.xsp.application.ViewHandlerEx.createView(ViewHandlerEx.java:90)
    com.ibm.xsp.webapp.FacesServlet.serviceView(FacesServlet.java:251)
    com.ibm.xsp.webapp.FacesServletEx.serviceView(FacesServletEx.java:157)
    com.ibm.xsp.webapp.FacesServlet.service(FacesServlet.java:160)
    com.ibm.xsp.webapp.FacesServletEx.service(FacesServletEx.java:138)
    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:1335)
    com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(ComponentModule.java:853)
    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:1319)
    com.ibm.domino.xsp.module.nsf.NSFService.doServiceInternal(NSFService.java:662)
    com.ibm.domino.xsp.module.nsf.NSFService.doService(NSFService.java:482)
    com.ibm.designer.runtime.domino.adapter.LCDEnvironment.doService(LCDEnvironment.java:357)
    com.ibm.designer.runtime.domino.adapter.LCDEnvironment.service(LCDEnvironment.java:313)
    com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.service(XspCmdManager.java:272)
java.lang.reflect.InvocationTargetException
    sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:56)
    sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:39)
    java.lang.reflect.Constructor.newInstance(Constructor.java:527)
    com.ibm.jscript.types.JavaAccessObject.construct(JavaAccessObject.java:260)
    com.ibm.jscript.types.JavaWrapperObject.construct(JavaWrapperObject.java:1)
    com.ibm.jscript.ASTTree.ASTNew.interpret(ASTNew.java:109)
    com.ibm.jscript.ASTTree.ASTVariableDecl.interpret(ASTVariableDecl.java:82)
    com.ibm.jscript.ASTTree.ASTDebug.interpret(ASTDebug.java:148)
    com.ibm.jscript.std.FunctionObject._executeFunction(FunctionObject.java:261)
    com.ibm.jscript.std.FunctionObject.executeFunction(FunctionObject.java:185)
    com.ibm.jscript.std.FunctionObject.call(FunctionObject.java:171)
    com.ibm.jscript.types.FBSObject.call(FBSObject.java:161)
    com.ibm.jscript.ASTTree.ASTCall.interpret(ASTCall.java:197)
    com.ibm.jscript.ASTTree.ASTArgumentList.interpretArguments(ASTArgumentList.java:65)
    com.ibm.jscript.types.FBSObject.call(FBSObject.java:153)
    com.ibm.jscript.ASTTree.ASTCall.interpret(ASTCall.java:197)
    com.ibm.jscript.ASTTree.ASTDebug.interpret(ASTDebug.java:148)
    com.ibm.jscript.ASTTree.ASTBlock.interpret(ASTBlock.java:100)
    com.ibm.jscript.ASTTree.ASTDebug.interpret(ASTDebug.java:148)
    com.ibm.jscript.ASTTree.ASTIf.interpret(ASTIf.java:85)
    com.ibm.jscript.ASTTree.ASTDebug.interpret(ASTDebug.java:148)
    com.ibm.jscript.std.FunctionObject._executeFunction(FunctionObject.java:261)
    com.ibm.jscript.std.FunctionObject.executeFunction(FunctionObject.java:185)
    com.ibm.jscript.std.FunctionObject.call(FunctionObject.java:171)
    com.ibm.jscript.types.FBSObject.call(FBSObject.java:161)
    com.ibm.jscript.ASTTree.ASTCall.interpret(ASTCall.java:197)
    com.ibm.jscript.ASTTree.ASTDebug.interpret(ASTDebug.java:148)
    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(JSExpression.java:424)
    com.ibm.jscript.JSExpression.run(JSExpression.java:414)
    java.security.AccessController.doPrivileged(AccessController.java:448)
    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:222)
    com.ibm.xsp.binding.javascript.JavaScriptMethodBinding.invoke(JavaScriptMethodBinding.java:111)
    com.ibm.xsp.component.UIIncludeComposite.initBeforePageContents(UIIncludeComposite.java:672)
    com.ibm.xsp.page.compiled.AbstractCompiledPage.initComponent(AbstractCompiledPage.java:339)
    com.ibm.xsp.page.compiled.AbstractCompiledPage.createTree(AbstractCompiledPage.java:256)
    com.ibm.xsp.page.compiled.AbstractCompiledPage.addComponent(AbstractCompiledPage.java:389)
    com.ibm.xsp.component.UIIncludeComposite.buildContents(UIIncludeComposite.java:453)
    com.ibm.xsp.page.compiled.AbstractCompiledPage.initComponent(AbstractCompiledPage.java:334)
    com.ibm.xsp.page.compiled.CompiledComponentBuilder.buildChildren(CompiledComponentBuilder.java:123)
    com.ibm.xsp.page.compiled.CompiledComponentBuilder.buildAll(CompiledComponentBuilder.java:84)
    com.ibm.xsp.component.UIViewRootEx.buildContents(UIViewRootEx.java:1649)
    com.ibm.xsp.component.UIViewRootEx2.buildContents(UIViewRootEx2.java:247)
    com.ibm.xsp.page.compiled.AbstractCompiledPage.initComponent(AbstractCompiledPage.java:334)
    com.ibm.xsp.page.compiled.AbstractCompiledPage.createTree(AbstractCompiledPage.java:256)
    com.ibm.xsp.page.compiled.AbstractCompiledPage.createViewRoot(AbstractCompiledPage.java:167)
    com.ibm.xsp.application.ViewHandlerExImpl._createViewRoot(ViewHandlerExImpl.java:521)
    com.ibm.xsp.application.ViewHandlerExImpl.createViewRoot(ViewHandlerExImpl.java:567)
    com.ibm.xsp.application.ViewHandlerExImpl.doCreateView(ViewHandlerExImpl.java:142)
    com.ibm.xsp.application.ViewHandlerEx.createView(ViewHandlerEx.java:90)
    com.ibm.xsp.webapp.FacesServlet.serviceView(FacesServlet.java:251)
    com.ibm.xsp.webapp.FacesServletEx.serviceView(FacesServletEx.java:157)
    com.ibm.xsp.webapp.FacesServlet.service(FacesServlet.java:160)
    com.ibm.xsp.webapp.FacesServletEx.service(FacesServletEx.java:138)
    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:1335)
    com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(ComponentModule.java:853)
    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:1319)
    com.ibm.domino.xsp.module.nsf.NSFService.doServiceInternal(NSFService.java:662)
    com.ibm.domino.xsp.module.nsf.NSFService.doService(NSFService.java:482)
    com.ibm.designer.runtime.domino.adapter.LCDEnvironment.doService(LCDEnvironment.java:357)
    com.ibm.designer.runtime.domino.adapter.LCDEnvironment.service(LCDEnvironment.java:313)
    com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.service(XspCmdManager.java:272)
java.lang.NullPointerException
    com.mycompany.activiti.ActivitiWorkflow.<init>(ActivitiWorkflow.java:88)
    sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:56)
    sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:39)
    java.lang.reflect.Constructor.newInstance(Constructor.java:527)
    com.ibm.jscript.types.JavaAccessObject.construct(JavaAccessObject.java:260)
    com.ibm.jscript.types.JavaWrapperObject.construct(JavaWrapperObject.java:1)
    com.ibm.jscript.ASTTree.ASTNew.interpret(ASTNew.java:109)
    com.ibm.jscript.ASTTree.ASTVariableDecl.interpret(ASTVariableDecl.java:82)
    com.ibm.jscript.ASTTree.ASTDebug.interpret(ASTDebug.java:148)
    com.ibm.jscript.std.FunctionObject._executeFunction(FunctionObject.java:261)
    com.ibm.jscript.std.FunctionObject.executeFunction(FunctionObject.java:185)
    com.ibm.jscript.std.FunctionObject.call(FunctionObject.java:171)
    com.ibm.jscript.types.FBSObject.call(FBSObject.java:161)
    com.ibm.jscript.ASTTree.ASTCall.interpret(ASTCall.java:197)
    com.ibm.jscript.ASTTree.ASTArgumentList.interpretArguments(ASTArgumentList.java:65)
    com.ibm.jscript.types.FBSObject.call(FBSObject.java:153)
    com.ibm.jscript.ASTTree.ASTCall.interpret(ASTCall.java:197)
    com.ibm.jscript.ASTTree.ASTDebug.interpret(ASTDebug.java:148)
    com.ibm.jscript.ASTTree.ASTBlock.interpret(ASTBlock.java:100)
    com.ibm.jscript.ASTTree.ASTDebug.interpret(ASTDebug.java:148)
    com.ibm.jscript.ASTTree.ASTIf.interpret(ASTIf.java:85)
    com.ibm.jscript.ASTTree.ASTDebug.interpret(ASTDebug.java:148)
    com.ibm.jscript.std.FunctionObject._executeFunction(FunctionObject.java:261)
    com.ibm.jscript.std.FunctionObject.executeFunction(FunctionObject.java:185)
    com.ibm.jscript.std.FunctionObject.call(FunctionObject.java:171)
    com.ibm.jscript.types.FBSObject.call(FBSObject.java:161)

需要确保的一件事是 NSF 中的所有设计元素都由同一用户签署。否则 sessionAsSigner 可能会失败,并且在某些情况下(肯定是在 8.5.x 服务器版本上,可能仍然如此)会使服务器崩溃。