Getting the Server Name from the session

2019-09-09 00:49发布

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.

2条回答
甜甜的少女心
2楼-- · 2019-09-09 00:57
String serverName = s.getEnvironmentString("ServerName", true);
or
String serverName = s.getEnvironmentString("ServerKeyFileName_Owner", true);
查看更多
太酷不给撩
3楼-- · 2019-09-09 01:21

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"

查看更多
登录 后发表回答