0

On an xpage I run the following code:

function setPersonInfoCommon(x) {   
    //print("test printing to console value:  " + x)
    var serv = getPreferenceField("tx_server");
//e.g. "Development1";
    var dbname = getPreferenceField("tx_loc_personal_common");
//e.g. "CustomerX\\Personnel.nsf"
    var db:NotesDatabase = session.getDatabase(serv,dbname);    
    if (db == null) {
        requestScope.status = "Database not found.";    
        return;
    }
    var vw:NotesView = db.getView("LookUpUsersUNID");
    if (vw == null) {
        requestScope.status = "View not found.";    
        return;
    }   
    var doc:NotesDocument = vw.getDocumentByKey(x);
    if (doc == null) {
        requestScope.status = "Document not found.";
        return;
    }
    else{
        requestScope.status = "Document created:" + getCreated();
    }   
}

This freezes my XPage and in the log I see the following notation: 2014-08-19 12:46:11 HTTP JVM: com.ibm.xsp.webapp.FacesServlet$ExtendedServletException: com.ibm.xsp.FacesExceptionEx: java.io.NotSerializableException: lotus.domino.local.DateTime 2014-08-19 12:46:11 HTTP JVM: CLFAD0134E: Exception processing XPage request. For more detailed information, please consult error-log-0.xml located in E:/Domino/data/domino/workspace/logs

The XPage resides in a different NSF than the one I perform the getDocumentByKey method in. However I do not get any indication that the database (db) or view (vw) can not be found. If I check it by outputting the filepath or something I get the correct values returned.

I tested to run the code from within the NSF I perform the getDocumentByKey method and then the code runs just fine.

What can be the cause?

I am logged in via the web and have the proper rights.

Patrick Kwinten
  • 1,988
  • 2
  • 14
  • 26

1 Answers1

9

Please always look at those more detailed logs in the location specified before posting a question. Those messages give much more information which will help identify the code causing the problem and usually a more detailed explanation.

In this particular case, the message on the console logs includes "java.io.NotSerializableException: lotus.domino.local.DateTime". Assuming this is relating to the line requestScope.status = "Document created:" + getCreated(); (the detailed logs will confirm) and that getCreated() is actually doc.getCreated(), that returns a NotesDateTime object.

NotesDateTime objects and any other Domino objects cannot be put in any scoped variable (there are various blogs explaining that Domino objects are not serializable).

If you want to put a date/time in a scope, you can get the Java date equivalent using NotesDateTime.toJavaDate(), so doc.getCreated().toJavaDate().

Paul Stephen Withers
  • 15,699
  • 1
  • 15
  • 33