I have 2 database, one containing XPages (Mobile Web App, let's call this database A) and another one containing the documents (database b). In my test unit, everything works fine. When I access the mobile web app, it access data from database B flawlessly. But when I install them in the client's server, the web app cannot access database b. I checked all ACL entries and I think it's fine. The error on the page in:
Error while executing JavaScript computed expression Script interpreter error, line=161, col=18: 'ecrDB' is null at [/sjs_common.jss].getCRViewDetails()
The script that causes the error is:
function getCRViewDetails(){
158:
159: var ecrDB:NotesDatabase = ECR().mainDB;
160: var viewDetails:Array = new Array();
161: if(ecrDB.isOpen()){ //----- HERE IS THE ERROR LINE!
162: //var vw:NotesView = ecrDB.getView("Drafts");
163: var vw:NotesView = ecrDB.getView(mainConstants.VIEW_MAIN);
164: var docs:NotesDocumentCollection = vw.getAllDocumentsByKey(session.getEffectiveUserName(), true)
165: //var doc:NotesDocument = vw.getFirstDocument();
166: var doc:NotesDocument = docs.getFirstDocument();
167: while(doc != null){
168: viewDetails.push([
169: doc.getItemValueString("ProjectTitle"),
170: doc.getItemValueString("CRNumber"),
171: doc.getUniversalID()
172: ]);
173: //print(doc.getItemValueString("ProjectTitle") + ">>" + doc.getItemValueString("CRNumber"));
174: //doc = vw.getNextDocument(doc);
175: doc = docs.getNextDocument(doc);
176: }
177: }
This is how I access database b (ECRDB):
function ECR(){
34:
35: //private properties and methods ---------------------------------
36:
37: //Setup document
38: var SetupDoc:NotesDocument = database.getProfileDocument("(Setup)","");
39:
40: // try to connect to Main DB if the sessionScope.ECRMainDBPath has been set
41: if(sessionScope.containsKey("ECRMainDBPath") && sessionScope.containsKey("ECRDataRepPath")){
42: try{
43: var ECRDB:NotesDatabase = session.getDatabase(
44: SetupDoc.getItemValueString("ECRMainServer"),
45: sessionScope.get("ECRMainDBPath"),
46: false);
47: var DataRep:DataRepository = new DataRepository(
48: session.getDatabase(SetupDoc.getItemValueString("ECRMainServer"),
49: sessionScope.get("ECRDataRepPath"),
50: false));
51:
52: var ecrSettingsDoc:NotesDocument = ECRDB.getProfileDocument("eCRSettings","");
53: }catch(e){
54: print(e.message);
55: print("Error: Cannot access eCR Main. Please check if Anonymous is at least Reader Access");
56: ECRDB = null;
57: }
58: }else{
59: //TODO put this in init()
60: if(!(view.getPageName().equals("/login.xsp") || view.getPageName().equals("/selectDivision.xsp"))){
61: context.redirectToPage("selectDivision.xsp");
62: }
63: }
64:
65: return {
66: test : "Hello Orga!",
67:
68: setupDoc : SetupDoc, //get Setup Document
69:
70: getSetupValue : function(fieldName){
71: return this.setupDoc.getItemValueString(fieldName);
72: },
73:
74: //get ECR Main database (content database)
75: mainDB : ECRDB,
76:
77: //get eCRSettings doc from the Main DB
78: mainSettings : ecrSettingsDoc,
79:
80: //get full database path (with server)
81: getFullDBPath : function(){
82: return this.mainDB.getServer() + "!!" + this.mainDB.getFilePath();
83: },
84:
85: //get Data Repositoy Object
86: getDataRep : function(){ return DataRep; },
87:
88: //get Data Repository //TODO remove this
89: //dataRep : DataRep.getDatabase(),
90:
91: //get URL for Data Repository
92: //getDataRepURLPath : DataRep.getURLPath,
93:
94: getDBURL : function(){
95: return context.getUrl().toString().split(view.getPageName())[0];
96: },
97:
98: getSplittedOrder : function(){
99: return this.mainSettings.getItemValueString("SplittedOrder");
100: }
101: };
102: }// end of ECR declaration
I have no other idea what is the possible problem with the databases. Can you tell me what are the factors that I need to check in order to successfully access database b? Thank you very much! :)
sessionAsSigner.getDatabaseor change some settings on server to get handle of the database. Have a look at this, this, this and this. - Naveen