java - 在 Java 库中,lotus.domino.Session 类方法 createDateTime() 抛出 NullPointerException
问题描述
当从 XPage SSJS 调用时,Domino Designer Java 库文件夹中的 Java 文件(不是 Agents 文件夹中的 Java 代理)将为标准方法引发 NullPointerException,例如createDateTime()
:
import java.io.*;
import java.net.*;
import java.security.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import javax.faces.context.FacesContext;
import javax.net.ssl.HttpsURLConnection;
import com.ibm.commons.util.io.base64.Base64;
import lotus.domino.*;
public class Tools extends AgentBase {
...
public void getSession( ) throws IOException {
Session s = getSession();
DateTime dt = s.createDateTime("Today"); // NullPointerException
String n = s.getEffectiveUserName(); // NullPointerException
...
}
}
如果将 Java 代码保存为 Java 代理,则不会引发异常。
是否有另一种方法可以在 Java 中使用“Now”设置 NotesDateTime 字段,而无需使用 session.createDateTime() 方法?
使用 Java 库(不是代理)时,AgentBase 是扩展的还是有其他扩展可以使用?
还有什么其他方法可以创建一个可能有帮助的 lotus.domino.Session?
更新: 在plugin.xml中,我将com.ibm.xsp.extlib添加为Dependency,Java 类编译时没有错误。
XPages Properties , Page Generation Xpage Library com.ibm.xsp.extlib.library被选中。
从服务器控制台,告诉 http osgi ss com.ibm.xsp.extlib返回:
> tell http osgi ss com.ibm.xsp.extlib
osgi> "Framework is launched."
id State Bundle
114 RESOLVED com.ibm.xsp.extlib.controls.nl1_9.0.1.v10_00_20180115-1058
Master=117
115 RESOLVED com.ibm.xsp.extlib.controls.nl2_9.0.1.v10_00_20180115-1058
Master=117
116 RESOLVED com.ibm.xsp.extlib.controls.nl3_9.0.1.v10_00_20180115-1058
Master=117
117 STARTING com.ibm.xsp.extlib.controls_9.0.1.v10_00_20180115-1058
Fragments=116, 115, 114
118 RESOLVED com.ibm.xsp.extlib.core.nl1_9.0.1.v10_00_20180115-1058
Master=121
119 RESOLVED com.ibm.xsp.extlib.core.nl2_9.0.1.v10_00_20180115-1058
Master=121
120 RESOLVED com.ibm.xsp.extlib.core.nl3_9.0.1.v10_00_20180115-1058
Master=121
121 STARTING com.ibm.xsp.extlib.core_9.0.1.v10_00_20180115-1058
Fragments=119, 118, 120
122 RESOLVED com.ibm.xsp.extlib.domino.nl1_9.0.1.v10_00_20180115-1058
Master=125
123 RESOLVED com.ibm.xsp.extlib.domino.nl2_9.0.1.v10_00_20180115-1058
Master=125
124 RESOLVED com.ibm.xsp.extlib.domino.nl3_9.0.1.v10_00_20180115-1058
Master=125
125 STARTING com.ibm.xsp.extlib.domino_9.0.1.v10_00_20180115-1058
Fragments=123, 124, 122
126 RESOLVED com.ibm.xsp.extlib.mobile.nl1_9.0.1.v10_00_20180115-1058
Master=129
127 RESOLVED com.ibm.xsp.extlib.mobile.nl2_9.0.1.v10_00_20180115-1058
Master=129
128 RESOLVED com.ibm.xsp.extlib.mobile.nl3_9.0.1.v10_00_20180115-1058
Master=129
129 STARTING com.ibm.xsp.extlib.mobile_9.0.1.v10_00_20180115-1058
Fragments=127, 128, 126
130 RESOLVED com.ibm.xsp.extlib.oneui.nl1_9.0.1.v10_00_20180115-1058
Master=133
131 RESOLVED com.ibm.xsp.extlib.oneui.nl2_9.0.1.v10_00_20180115-1058
Master=133
132 RESOLVED com.ibm.xsp.extlib.oneui.nl3_9.0.1.v10_00_20180115-1058
Master=133
133 STARTING com.ibm.xsp.extlib.oneui_9.0.1.v10_00_20180115-1058
Fragments=132, 130, 131
134 RESOLVED com.ibm.xsp.extlib.relational.nl1_9.0.1.v10_00_20180115-1058
Master=137
135 RESOLVED com.ibm.xsp.extlib.relational.nl2_9.0.1.v10_00_20180115-1058
Master=137
136 RESOLVED com.ibm.xsp.extlib.relational.nl3_9.0.1.v10_00_20180115-1058
Master=137
137 STARTING com.ibm.xsp.extlib.relational_9.0.1.v10_00_20180115-1058
Fragments=135, 136, 134
138 STARTING com.ibm.xsp.extlib_9.0.1.v10_00_20180115-1058
请注意,日志显示STARTING com.ibm.xsp.extlib_9.0.1.v10_00_20180115-1058
这意味着什么?我还向服务器添加了一个 updatesite.nsf 文件,并使用OSGI_HTTP_DYNAMIC_BUNDLES=install\update-site.nsf更新了 Notes.ini 。
启动 HTTP 时,没有消息表明 OSGI 正在加载到运行时。
尝试设置会话时出现的错误:
NoClassDefFoundError:com/ibm/xsp/extlib/util/ExtLibUtil
这个类不是已经包含在 Domino 9.0.1FP10 服务器中了吗?
解决方案
推荐阅读
- javascript - Javascript 字谜算法
- javascript - 为什么我的何时滚动在以下代码中不起作用
- python - 如何将列表附加到列表中
- python - 如何使用python3修复日期格式
- java - 为什么即使 UUID 在 HashMap 中, containsKey() 也会返回 false?
- angular-material - 如何使用angulat6材料将登录表单放置在页面右侧
- php - 如何连接多个查询
- python - 如何将 MultipleChoiceField 添加到 Django Admin?
- wordpress - 在我从本地主机迁移到实时服务器后,WordPress 导航栏链接将不起作用
- amazon-web-services - 如何使用 amazon Rekognition 对流式视频执行人脸识别?