Я пытаюсь получить сеанс в Java, вызываемый из XPage. Старая школа способ с версии 3.0 использовать, чтобы работать отлично:
(Session) Factory.fromLotus(NotesFactory.createSession(), Session.class, null);
Но это больше не доступно. Я попробовал приведенный ниже код, но обнаружил следующую ошибку:
***NO STACK TRACE*** - A session of type CURRENT was requested but no Factory has been defined for that type in this thread.
***NO STACK TRACE*** - Unable to get the session of type CURRENT from the session factory of type null. This probably means that you are running in an unsupported configuration or you forgot to set up your context at the start
of the operation. If you're running in XPages, check the xsp.properties of your database. If you are running in an Agent, make sure you start with a call to Factory.setSession() and pass in your lotus.domino.Session
java.lang.RuntimeException
at org.openntf.domino.utils.Factory.getSession(Factory.java:1012)
at org.openntf.domino.utils.Factory.getSession(Factory.java:859)
«Убедитесь, что вы начинаете с вызова Factory.setSession () и передаете свой lotus.domino.Session», вводит в заблуждение, поскольку setSession () также больше не доступен.
if(!Factory.isStarted()) {
Factory.startup();
}
if (!Factory.isInitialized()) {
System.out.println("Factory.initThread");
Factory.initThread(new Factory.ThreadConfig(new Fixes[0], AutoMime.WRAP_32K, true));
}
Session session = Factory.getSession();
Я установил OpenNTF API с помощью сайта обновлений и подтвердил, что они загружены с помощью команды "Tell http osgi ss openntf". У меня была первоначальная проблема, когда она не могла решить Factory, поэтому я скопировал четыре файла jar в каталог ext, и он решил эту проблему:
org.openntf.domino.rest_10.0.1.201905061230.jar
org.openntf.domino.xsp_10.0.1.201905061230.jar
org.openntf.domino_10.0.1.201905061230.jar
org.openntf.formula_10.0.1.201905061230.jar
Я также пытался передать сеанс Domino в вызове Factory.startup (), но он все еще не работал.
Спасибо,
Скотт
Domino 10.0.1 FP1
openNTF API: OpenNTF-Domino-API-10.0.1.zip
Код, в котором проблема. Это вызывается из XPage. Вызов:
<xp:label value="#{javascript:sessionBean.getCoreUser().getUserId();}"/>
При этом запускается конструктор SessionBean, который вызывает метод startLogging. Этот метод проверяет, включен ли «DebugMode». Если да, все операторы отладки записываются в OpenLog.
private void startLogging() {
System.out.println("Start OpenLog Logging");
Session session = (Session) ExtLibUtil.resolveVariable(FacesContext.getCurrentInstance(), "openSession");
System.out.println("Session: " + session);
try {
ViewEntry valueEntry = session.getCurrentDatabase().getView("SystemConfig").getFirstEntryByKey("DebugMode");
if (valueEntry != null)
SessionBean.debugMode = ("true".equalsIgnoreCase((String) valueEntry.getColumnValue("SetupValue")) ? Boolean.TRUE : Boolean.FALSE);
System.out.println("Debug Mode set to: " + debugMode);
} catch(Exception e) {
System.out.println("Exception in Start OpenLog Logging");
e.printStackTrace();
}
}