dj_universe dj_universe - 2 months ago 17
Java Question

Xpages ExtLibUtil.getCurrentSessionAsSigner() returns null

I've some java code run on beforePageLoad event. I try to get sessionAsSigner object using ExtLibUtil class in the constructor but i receive null unfortunatelly. What may be a reason of it? Here is my 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(){...}
}


I use the following code to run it on beforePageLoad event:

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


I read it using following stack trace

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$1(JSExpression.java:424)
com.ibm.jscript.JSExpression$2.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$1(JSExpression.java:424)
com.ibm.jscript.JSExpression$2.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)

Answer

One thing to ensure is that all design elements in the NSF are signed with the same user. Otherwise sessionAsSigner can fail and, in some circumstances (definitely on 8.5.x server versions, possibly still), can crash the server.