Lotus notes 尝试从DominoJava代理使用SBT失败,错误为NoSuchMethodError:org/apache/http/protocol/BasicHttpContext。<;初始化>;()V

Lotus notes 尝试从DominoJava代理使用SBT失败,错误为NoSuchMethodError:org/apache/http/protocol/BasicHttpContext。<;初始化>;()V,lotus-notes,javaagents,ibm-sbt,Lotus Notes,Javaagents,Ibm Sbt,10月30日更新,见问题底部 我已经在Eclipse中创建了一个独立java应用程序的工作示例(基于SBT的SBT.sample.app GetAllCommunitiesApp.java)。我唯一的更改是手动创建BasicEndpoint,以跳过对端点配置使用托管Bean(从而读取托管Bean.xml)如前所述,这一切都在Eclipse中运行得很好 将代码移动到本地Notes Java代理(代理放在本地数据库中),我首先将SBT jar文件复制到我的C:\Program files(x86)\

10月30日更新,见问题底部

我已经在Eclipse中创建了一个独立java应用程序的工作示例(基于SBT的SBT.sample.app GetAllCommunitiesApp.java)。我唯一的更改是手动创建BasicEndpoint,以跳过对端点配置使用托管Bean(从而读取托管Bean.xml)如前所述,这一切都在Eclipse中运行得很好

将代码移动到本地Notes Java代理(代理放在本地数据库中),我首先将SBT jar文件复制到我的C:\Program files(x86)\IBM\Lotus\Notes\jvm\lib\ext目录中。这些文件的列表见下文。当我运行Java代理时,我得到以下堆栈跟踪

更新日期2013年10月30日-找到一个可能与此类似的示例。以下代码是一个完整的Notes Java代理,核心代码直接来自Apache.org HttpClient 4.2示例代码。这也会生成NoSuchMethodError,并且可能比SBT更容易调试

 /*
 * Sample retrieved from 
 * http://hc.apache.org/httpcomponents-client-4.2.x/httpclient/examples/org/apache/http/examples/client/ClientWithResponseHandler.java
 */
import java.io.IOException;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
import lotus.domino.*;

public class JavaAgent extends AgentBase {

    public void NotesMain() {

      try {
          Session session = getSession();
          AgentContext agentContext = session.getAgentContext();

          HttpClient httpclient = new DefaultHttpClient();
          try {
              HttpGet httpget = new HttpGet("http://www.google.com/");

              System.out.println("executing request " + httpget.getURI());

              // Create a response handler
              ResponseHandler<String> responseHandler = new BasicResponseHandler();
              String responseBody = httpclient.execute(httpget, responseHandler);
              System.out.println("----------------------------------------");
              System.out.println(responseBody);
              System.out.println("----------------------------------------");

          } finally {
              // When HttpClient instance is no longer needed,
              // shut down the connection manager to ensure
              // immediate deallocation of all system resources
              httpclient.getConnectionManager().shutdown();
          }


          // Notes Exception catcher
      } catch(Exception e) {
          e.printStackTrace();
       }
   }
}
/*
*从中检索到的样本
* http://hc.apache.org/httpcomponents-client-4.2.x/httpclient/examples/org/apache/http/examples/client/ClientWithResponseHandler.java
*/
导入java.io.IOException;
导入org.apache.http.client.ResponseHandler;
导入org.apache.http.client.HttpClient;
导入org.apache.http.client.methods.HttpGet;
导入org.apache.http.impl.client.BasicResponseHandler;
导入org.apache.http.impl.client.DefaultHttpClient;
导入lotus.domino.*;
公共类JavaAgent扩展了AgentBase{
公共无效注释main(){
试一试{
Session=getSession();
AgentContext AgentContext=session.getAgentContext();
HttpClient HttpClient=新的DefaultHttpClient();
试一试{
HttpGet HttpGet=新的HttpGet(“http://www.google.com/");
System.out.println(“正在执行请求”+httpget.getURI());
//创建一个响应处理程序
ResponseHandler ResponseHandler=新BasicResponseHandler();
字符串responseBody=httpclient.execute(httpget,responseHandler);
System.out.println(“--------------------------------------------------------”;
系统输出打印LN(响应库);
System.out.println(“--------------------------------------------------------”;
}最后{
//当不再需要HttpClient实例时,
//关闭连接管理器以确保
//立即释放所有系统资源
httpclient.getConnectionManager().shutdown();
}
//注释异常捕捉器
}捕获(例外e){
e、 printStackTrace();
}
}
}

首先,您的代理从哪里运行? 笔记?那是个好地方 或者在服务器上?如果在服务器上,您应该确保库也在那里

一个伟大的测试是将库放入代理的代码中

在Designer中打开数据库

展开数据库>代码>代理

打开你的代理

点击存档

单击导入>存档

单击浏览(查找包含引用JAR的文件夹)

选择你想要的罐子

单击“完成”

单击保存(让它编译)

关闭并测试

如果这行得通,那就是路径问题了

----更新--

我将com.ibm.sbt.core/com.ibm.commons.xml com.ibm.commons.runtime com.ibm.commons httpcore httpclient commons日志jar作为归档文件添加到代理中

我使用了您的代码,并将工作区兼容性更改为Java1.5

然后我将安全性更改为3级……您应该尝试同样的方法,如果失败,您应该查看冲突的java类

import lotus.domino.AgentBase;
import lotus.domino.AgentContext;
import lotus.domino.Session;

import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;



public class JavaAgent extends AgentBase {

    public void NotesMain() {

        try {
            Session session = getSession();
            AgentContext agentContext = session.getAgentContext();
            lotus.domino.Log log = session.createLog("SampleAgentSBT");
            log.openAgentLog();

            HttpClient httpclient = new DefaultHttpClient();
            try {
                HttpGet httpget = new HttpGet("http://www.google.com/");

                log.logAction("executing request " + httpget.getURI());

                // Create a response handler
                ResponseHandler<String> responseHandler = new BasicResponseHandler();
                String responseBody = httpclient.execute(httpget,
                        responseHandler);
                log.logAction("----------------------------------------");
                log.logAction(responseBody);
                log.logAction("----------------------------------------");

            } finally {
                // When HttpClient instance is no longer needed,
                // shut down the connection manager to ensure
                // immediate deallocation of all system resources
                httpclient.getConnectionManager().shutdown();
            }
            log.close();

        } catch (Exception e) {
            e.printStackTrace();
        } finally {

        }
    }
}
导入lotus.domino.AgentBase;
导入lotus.domino.AgentContext;
导入lotus.domino.Session;
导入org.apache.http.client.HttpClient;
导入org.apache.http.client.ResponseHandler;
导入org.apache.http.client.methods.HttpGet;
导入org.apache.http.impl.client.BasicResponseHandler;
导入org.apache.http.impl.client.DefaultHttpClient;
公共类JavaAgent扩展了AgentBase{
公共无效注释main(){
试一试{
Session=getSession();
AgentContext AgentContext=session.getAgentContext();
lotus.domino.Log Log=session.createLog(“SampleAgentSBT”);
log.openAgentLog();
HttpClient HttpClient=新的DefaultHttpClient();
试一试{
HttpGet HttpGet=新的HttpGet(“http://www.google.com/");
logAction(“正在执行请求”+httpget.getURI());
//创建一个响应处理程序
ResponseHandler ResponseHandler=新BasicResponseHandler();
字符串responseBody=httpclient.execute(httpget,
负责人);
log.logAction(“---------------------------------------------------”;
log.logAction(responseBody);
log.logAction(“---------------------------------------------------”;
}最后{
//当不再需要HttpClient实例时,
//关闭连接管理器以确保
//立即释放所有系统资源
httpclient.getConnectionManager().shutdown();
}
log.close();
}捕获(例外e){
e、 printStackTrace();
}最后{
}
}
}

BTW;我刚刚尝试用SBT的com.ibm.SBT.libs.domino\lib目录中的文件替换httpclient、httpcore等。不幸的是,同样的结果我是Paul,谢谢你的回复。代理从Lotus Notes客户端运行,java代理放在本地数据库中。目前还没有涉及到服务器。是的,我还尝试包括all直接在Java代理中使用上述JAR
 /*
 * Sample retrieved from 
 * http://hc.apache.org/httpcomponents-client-4.2.x/httpclient/examples/org/apache/http/examples/client/ClientWithResponseHandler.java
 */
import java.io.IOException;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
import lotus.domino.*;

public class JavaAgent extends AgentBase {

    public void NotesMain() {

      try {
          Session session = getSession();
          AgentContext agentContext = session.getAgentContext();

          HttpClient httpclient = new DefaultHttpClient();
          try {
              HttpGet httpget = new HttpGet("http://www.google.com/");

              System.out.println("executing request " + httpget.getURI());

              // Create a response handler
              ResponseHandler<String> responseHandler = new BasicResponseHandler();
              String responseBody = httpclient.execute(httpget, responseHandler);
              System.out.println("----------------------------------------");
              System.out.println(responseBody);
              System.out.println("----------------------------------------");

          } finally {
              // When HttpClient instance is no longer needed,
              // shut down the connection manager to ensure
              // immediate deallocation of all system resources
              httpclient.getConnectionManager().shutdown();
          }


          // Notes Exception catcher
      } catch(Exception e) {
          e.printStackTrace();
       }
   }
}
import lotus.domino.AgentBase;
import lotus.domino.AgentContext;
import lotus.domino.Session;

import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;



public class JavaAgent extends AgentBase {

    public void NotesMain() {

        try {
            Session session = getSession();
            AgentContext agentContext = session.getAgentContext();
            lotus.domino.Log log = session.createLog("SampleAgentSBT");
            log.openAgentLog();

            HttpClient httpclient = new DefaultHttpClient();
            try {
                HttpGet httpget = new HttpGet("http://www.google.com/");

                log.logAction("executing request " + httpget.getURI());

                // Create a response handler
                ResponseHandler<String> responseHandler = new BasicResponseHandler();
                String responseBody = httpclient.execute(httpget,
                        responseHandler);
                log.logAction("----------------------------------------");
                log.logAction(responseBody);
                log.logAction("----------------------------------------");

            } finally {
                // When HttpClient instance is no longer needed,
                // shut down the connection manager to ensure
                // immediate deallocation of all system resources
                httpclient.getConnectionManager().shutdown();
            }
            log.close();

        } catch (Exception e) {
            e.printStackTrace();
        } finally {

        }
    }
}