0
votes

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..!


3
Looks like your doc variable is null. Without the source where it came from and what you did to it, it is anybody's guessstwissel
No, it is not null..As I mentioned in my question, it works well without the Java script library. .Chintan Parekh
still you leave the audience to guess: look it works, but when I add something it stops working, but I neither tell where the document came from, nor what is inside the library that breaks my code. ROFLstwissel
I am sorry, if it was not clear. I will add the library in few minutes to make it even more clear.Chintan Parekh
Please check the improved question. Sorry, if it wasn't clear..!.. Thanks for the suggestion.Chintan Parekh

3 Answers

1
votes

Set "Run as Web User" in agents security tab.

Look here for more information.

0
votes

What is your Java source level? You have parameter in your new Vector() which is not available in Domino Java Library by default. Check both project and editor levels:

File --> Preferences --> Java --> Compiler --> Compiler compliance level

(2nd button click) --> Project properties --> Java compiler --> JDK compliance

This could cause the class initialization to fail before the constructor is ran.

0
votes

Java source files must match the class they contain. Your question suggests the file you import is extract_group while your class is ExtractGroup You however should get a warning or error at compile time.