Getting the Server Name from the session

丶灬走出姿态 提交于 2019-12-13 05:01:57

问题


In a managed bean that resides in a Database on the server Development I have this code:

s = ExtLibUtil.getCurrentSession();
theMap.put("Server Name", s.getServerName());

when I look at theMap after this has run I see Server Name and the value is blank. After this I get a datbase RepID and then try to open the database by RepID with

appDB = s.getDbDirectory(null).openDatabaseByReplicaID(repID);
                if (appDB.isOpen()){
                    theMap.put(thisKey, repID); 
                }else{
                    theMap.put("DB " + thisKey, "Is Not Open");
                }

if I have a rep copy of the database locally it opens it, if I remove the local Replica the open fails. If I change the line to:

appDB = s.getDbDirectory("Development").openDatabaseByReplicaID(repID);

the proper appDB opens. So it looks like the session thinks it is running locally because it return null for the server name. This is really strange, am I missing something? For the moment i have just hard coded the server name in the getDbDirectory but that wont work in the real world.


回答1:


Is this XPiNC? That would consider the database to be running locally unless you've set the application property "Run server-based XPages on server"




回答2:


String serverName = s.getEnvironmentString("ServerName", true);
or
String serverName = s.getEnvironmentString("ServerKeyFileName_Owner", true);


来源:https://stackoverflow.com/questions/24620094/getting-the-server-name-from-the-session

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!