Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/401.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Can';无法从XPage-Version10.0.1调用java中的openNTF会话_Java_Xpages_Lotus Domino - Fatal编程技术网

Can';无法从XPage-Version10.0.1调用java中的openNTF会话

Can';无法从XPage-Version10.0.1调用java中的openNTF会话,java,xpages,lotus-domino,Java,Xpages,Lotus Domino,我正在尝试从XPage调用java中的会话。版本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

我正在尝试从XPage调用java中的会话。版本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();
我已经使用更新站点安装了OpenNTFAPI,并确认它们已加载“tellHTTPOSGiSSOpenNTF”命令。我有一个初始问题,它无法解决工厂问题,因此我将四个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

我还试图在Factory.startup()调用中提交一个Domino会话,但仍然没有成功

谢谢, 斯科特

Domino 10.0.1 FP1
openntfapi:openNTF-Domino-API-10.0.1.zip

问题所在的代码。这是从XPage调用的。电话是:

<xp:label value="#{javascript:sessionBean.getCoreUser().getUserId();}"/>

现在我在servlet插件中实现这一点的方法是在
服务(HttpServletRequest,HttpServletResponse)
方法中实现这一点:

Factory.setSessionFactory(()->AppUtil.getSession(),SessionType.CURRENT);
其中,
AppUtil.getSession()
是一种尝试为当前上下文查找会话的方法,检查XPages环境(如果可用),然后
ContextInfo.getUserSession()
,如果找不到任何内容,则最后调用
NotesFactory.createSession()


设置之后,
Factory.getSession()
将使用提供的覆盖,而不是其正常行为。

我现在在servlet插件中执行此操作的方式是在
服务(HttpServletRequest,HttpServletResponse)
方法中:

Factory.setSessionFactory(()->AppUtil.getSession(),SessionType.CURRENT);
其中,
AppUtil.getSession()
是一种尝试为当前上下文查找会话的方法,检查XPages环境(如果可用),然后
ContextInfo.getUserSession()
,如果找不到任何内容,则最后调用
NotesFactory.createSession()


设置之后,
Factory.getSession()
将使用提供的覆盖,而不是其正常行为。

最简单的方法是Jesse建议的方法。使用变量解析器。我的申请将获得类似的ODA会话。以下是获取ODA会话或domino会话的更新代码:

public static Session getSessionAsSigner() {
    Session s = (Session) ExtLibUtil.resolveVariable(FacesContext.getCurrentInstance(), "openSessionAsSigner");
    if (null == s) {
        s = (Session) Factory.getWrapperFactory().fromLotus((lotus.domino.Session)ExtLibUtil.resolveVariable(FacesContext.getCurrentInstance(), "sessionAsSigner"), Session.SCHEMA, null);
    }
    return s;
}

public static Session getSession() {
    Session s = (Session) ExtLibUtil.resolveVariable(FacesContext.getCurrentInstance(), "openSession");
    if (null == s) {
        s = (Session) Factory.getWrapperFactory().fromLotus((lotus.domino.Session)ExtLibUtil.resolveVariable(FacesContext.getCurrentInstance(), "session"), Session.SCHEMA, null);
    }
    return s;
}

我创建了一个带有静态函数的Utils类,仅用于此目的。

最简单的方法是Jesse建议的方法。使用变量解析器。我的申请将获得类似的ODA会话。以下是获取ODA会话或domino会话的更新代码:

public static Session getSessionAsSigner() {
    Session s = (Session) ExtLibUtil.resolveVariable(FacesContext.getCurrentInstance(), "openSessionAsSigner");
    if (null == s) {
        s = (Session) Factory.getWrapperFactory().fromLotus((lotus.domino.Session)ExtLibUtil.resolveVariable(FacesContext.getCurrentInstance(), "sessionAsSigner"), Session.SCHEMA, null);
    }
    return s;
}

public static Session getSession() {
    Session s = (Session) ExtLibUtil.resolveVariable(FacesContext.getCurrentInstance(), "openSession");
    if (null == s) {
        s = (Session) Factory.getWrapperFactory().fromLotus((lotus.domino.Session)ExtLibUtil.resolveVariable(FacesContext.getCurrentInstance(), "session"), Session.SCHEMA, null);
    }
    return s;
}


我创建了一个带有静态函数的Utils类,仅用于此目的。

您是否尝试过仅使用工厂.getSession()?@Per Henrik Lausten我最初尝试了平面的'getSession()'调用,但收到了一个'Factory未为此线程初始化'错误,这使我开始使用'Factory.isStarted(),'Factory.isInitialized()'... path.您是否尝试过仅使用工厂.getSession()?@Per Henrik Lausten我最初尝试了平面“getSession()”调用,但收到了“工厂未为此线程初始化”错误,这使我开始执行“Factory.isStarted(),“Factory.isInitialized()”。。。另请参见ODA Starter Servlet,以便在插件中获取它Hey Jesse,我在查找AppUtil类时遇到了问题。正如Paul所建议的,我确实查看了ODA Starter Servlet,但是在其中的搜索没有返回任何AppUtil。我也尝试了Arun的建议,但仍然将会话显示为空。莲花的单线工厂被移除有什么原因吗?谢谢,Scott。“AppUtil”是我在客户端项目中使用的一个实用程序类的匿名名称,在本例中是一个占位符名称。其要点是,您可以将当前SessionFactory设置为可以做您想要做的事情的东西,在您的示例中,通过NotesFactory。另请参阅ODA Starter Servlet,以在插件中获得它。Hey Jesse,我在查找AppUtil类时遇到了困难。正如Paul所建议的,我确实查看了ODA Starter Servlet,但是在其中的搜索没有返回任何AppUtil。我也尝试了Arun的建议,但仍然将会话显示为空。莲花的单线工厂被移除有什么原因吗?谢谢,Scott。“AppUtil”是我在客户端项目中使用的一个实用程序类的匿名名称,在本例中是一个占位符名称。要点是,您可以将当前SessionFactory设置为可以完成您想要的事情的东西,在您的示例中,您可以通过NotesFactory.Hi Arun,我尝试了这些,但仍然得到session=null。我错过了什么。我添加了grant{permission java.security.AllPermission;};在我收到一个安全错误时,我很早就访问了策略文件,所以不是这样。谢谢你的帮助,ScottCan你能提供一些代码吗?你在哪里尝试?在安装插件时,还要检查设计器帮助-->支持-->查看跟踪以了解任何问题。在跟踪查看器的OP.中添加了代码,我看到一个严重错误:com.ibm.rcp.personality.framework.internal.RCPWorkbenchAdvisor eventLoopException:java.lang.NullPointerException位于org.eclipse.ui.internal.EditorSiteDragAndDropServiceImpl$MergedDropTarget$1.dragLeave(未知源代码),我认为这不适用于这个问题。请检查我上面回答中的更新代码。它检查ODA会话是否可用。如果没有,它将domino会话包装到ODA会话中(由Jesse创建的frostillicus框架提供)