Error while using sessionAsSigner calls

Yesterday, apparently for no reason, I started getting all errors in my XPage application. Investigating it more I found out that the root cause was a problem with the sessionAsSigner function. The error I was getting was:

‘sessionAsSigner’ not found

So I started thinking what changed in the last week and might have caused this error. I made no configuration changes and performed no updates. The only thing I changed was that I started using the server with another user ID. I looked into the security and authentication settings and found absolutely no differences between the user ID’s.

After some more investigating I stumbled across a tweet from a user called HinkyMinky:

I resigned the database with my new user ID and all problems were solved!

Putting your Xpage to sleep

I’m currently working on rewriting my multiple-file uploader using Xpages/ custom controls. I encountered a problem when embedding the control on an Xpage based form. When the “save” button on the form is called, the uploads are started but I needed the Xpage to wait until all files had been uploaded.

My first try was to implement a sleep function in Javascript, but the only way this seemed to work was using a while loop. The big problem with that is that it eats up all CPU cycles and “locks” your browser. Not a good solution.

One of the articles I read mentioned the Java sleep method. This gave me the idea of implementing the wait-until function on the Xpage itself.

In the querySaveDocument event of the datasource on the Xpage I make a (conditional) call to the Java sleep method:

while (!condition) {

 java.lang.Thread.currentThread().sleep(1000);
 //re-check condition here

}

This causes the Xpage to wait for (in this case) 1 second (1000 milliseconds) until it continues to save the document.

To make sure that the script doesn’t go in an infinite loop I have included a timeout period:

var startTime = new Date().getTime();
var elapsedTime = 0;
var timeOutSeconds = 60;

while (!condition && elapsedTime < timeOutSeconds) {

 java.lang.Thread.currentThread().sleep(1000);
 //re-check condition here

 elapsedTime = (new Date().getTime() - startTime) / 1024;

}