2 개의 데이터베이스가 있습니다. 하나는 XPage (Mobile Web App,이 데이터베이스를 A라고 함)와 다른 하나는 문서 (데이터베이스 b)를 포함합니다. 테스트 유닛에서는 모든 것이 잘 작동합니다. 모바일 웹 앱에 액세스하면 데이터베이스 B의 데이터에 완벽하게 액세스합니다. 그러나 클라이언트의 서버에 설치하면 웹 응용 프로그램은 데이터베이스 b에 액세스 할 수 없습니다. 나는 모든 ACL 항목을 검사했고 괜찮다고 생각합니다. 의 페이지에 오류 : 오류가 발생XPages에서 데이터베이스에 액세스 할 수 없습니다.
Error while executing JavaScript computed expression Script interpreter error, line=161, col=18: 'ecrDB' is null at [/sjs_common.jss].getCRViewDetails()
스크립트는 다음과 같습니다
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: }
이것은 내가 데이터베이스 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
나는 어떤이 없습니다 다른 아이디어는 데이터베이스에서 발생할 수있는 문제입니다. 데이터베이스 b에 성공적으로 액세스하기 위해 확인해야하는 요소는 무엇입니까? 고마워요! :)
XPage에서 다른 DB에 액세스하는 것은 약간 까다 롭습니다. 'sessionAsSigner.getDatabase'를 사용하거나 데이터베이스의 핸들을 얻기 위해 서버의 일부 설정을 변경해야 할 수도 있습니다. [this] (http://stackoverflow.com/questions/11863496/unable-to-reference-a-view-in-another-database-from-xpinc)에서 [this] (http : // stackoverflow .com/questions/10030470/how-to-use-dblookup-in-different-database), [this] (http://quintessens.wordpress.com/2010/05/17/xpages-unable-to-open- other-server /) 및 [this] (http://xpagesblog.com/XPagesHome.nsf/Entry.xsp?documentId=B21BE03574FE36AD852578CB0066B5AD)를 참조하십시오. – Naveen
설정 문서가 클라이언트 db 복사본에 확실히 있습니까? –