代码之家  ›  专栏  ›  技术社区  ›  teleman

在Java库中,lotus.domino.Session类方法createDateTime()抛出NullPointerException

  •  0
  • teleman  · 技术社区  · 6 年前

    当从XPage SSJS调用Domino Designer Java library文件夹中的Java文件(而不是Agents文件夹中的Java代理)时,对于标准方法(如 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中用'Now'设置NotesDateTime字段,而不必使用session.createDateTime()方法?

    AgentBase是扩展的还是在使用Java库(不是代理)时要使用另一个扩展?

    还有哪些其他方法可以帮助创建lotus.domino.Session?

    更新: ,我补充道 com.ibm.xsp.extlib 附属国 ,并且编译的Java类没有错误。

    ,页生成Xpage库 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
    

    注意日志上写着

    那是什么意思?我还向服务器添加了updatesite.nsf文件,并用 OSGI\u HTTP\u DYNAMIC\u BUNDLES=install\update-site.nsf .

    启动HTTP时,没有任何消息表明OSGI正在加载到运行时。

    尝试设置会话时出现的错误:

    Domino9.0.1FP10服务器中是否已经包含了此类?

    1 回复  |  直到 6 年前
        1
  •  1
  •   Knut Herrmann    6 年前

    获取会话

    Session s = ExtLibUtil.getCurrentSession();
    

    随后的代码行将工作。

    public class Tools  {
      ...
      public void yourMethod() {
        Session s   = ExtLibUtil.getCurrentSession();
        DateTime dt = s.createDateTime("Today");
        String n    = s.getEffectiveUserName();
        ...
      }
    }
    

    getSession() 您只对Java代理使用works。

    enter image description here