I am working working with XPages from quite a long time and have always ignored this error but would like to understand the reason (and/or solution if possible).
So, my XPage agent when called from my web works perfectly fine. However, adding a JAVA script library to the agent would throw the error mentioned in my question title. I have seen this error many times and the obvious reason I am aware is the document being null but in this case I am sure document is not null (since, it runs without the additional script). Please find below the code for each of it.
// Javascript: default.js
var uId = myList.get(0); // this contains the document unique id
var doc:NotesDocument = database.getDocumentByUNID(uId);
var agentName = "groupRobot" ;
var agent:NotesAgent = database.getAgent(agentName);
if (agent != null)
{
if(doc == null){
// do nothing
}else{
agent.runWithDocumentContext(doc);
}
}
else {
getComponent("warningmessageBox").setValue("Failed to run the agent");
}
// Agent : groupRobot
public class JavaAgent extends AgentBase {
Session session;
public void NotesMain() {
session = getSession();
// ExtractGroup extract_group = new ExtractGroup();
// extract_group.setSession(session);
// boolean populatePersons = extract_group.start(); // calling the attached script library to replace group by persons
if(true){
System.out.println("Script finished sucessfully");
}
} // End of Notes Main
} // End of Class
// JAVA SCRIPT LIBRARY : extract_group
public class ExtractGroup {
Session session;
Vector<String> users= new Vector<String>();
Vector<String> groups= new Vector<String>();
public void setSession(Session session) {
this.session = session;
}
public boolean start() {
return true; // removed original code for being more clear
}
} // End of Class
I am not able to understand the reason for this. Any help would really be appreciated.
Thanks!
P.S. I have allowed restricted operations with administrator rights for the agent and also "Run as web user" option is selected
Edit 1: Based on the suggestion Knut Herrmann, I tried producing the same libraries and files on a new database and turns out that it works. Well, now the problem is the same thing ain't working my production database and I am not able to reproduce the error on the new database. Any suggestions in producing this error on new database and or removing this error from old database would be great. Thanks..!