【问题标题】:Sesame API call throwing an IOExceptionSesame API 调用引发 IOException
【发布时间】:2015-01-22 07:04:52
【问题描述】:

我正在用 Java 编写一个程序来使用 Sesame 的服务,但是当我调用 Login 时:

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {        
     try {

    URL sesameurl = new URL("http://localhost:8080/openrdf-sesame");
    SesameService service = Sesame.getService(sesameurl);         
        service.login("username", "password");
        service.getRepositoryList();            
               } 
    catch (UnknownRepositoryException ex) {
        Logger.getLogger(Sparqlquery.class.getName()).log(Level.SEVERE, null, ex);
    } catch (ConfigurationException ex) {
        Logger.getLogger(Sparqlquery.class.getName()).log(Level.SEVERE, null, ex);
    }        catch (AccessDeniedException ex) {
        Logger.getLogger(Sparqlquery.class.getName()).log(Level.SEVERE, null, ex);
    }      
    PrintWriter write = response.getWriter();         
} 

它会抛出以下错误:

HTTP Status 500 -

输入异常报告

消息

描述服务器遇到了一个内部错误(),导致它无法完成这个请求。

异常

java.io.IOException: http://localhost:8080/openrdf-sesame/servlets/login: 未找到

note GlassFish Server Open Source Edition 3.1.1 日志中提供了异常的完整堆栈跟踪及其根本原因。 GlassFish Server 开源版 3.1.1

【问题讨论】:

  • 请出示相关代码。
  • “相关代码”是指创建和初始化 Sesame Repository 对象的部分。另外:你能显示异常的完整堆栈跟踪吗?请edit your question添加这些详细信息。
  • 顺便说一句,由于您在这里相对较新:我注意到您已经提出了几个问题,但从未赞成和/或接受您给出的任何答案。当然这不是必需的,但如果某人的回答对您有帮助,这是感谢某人的好方法。看看这个:What should I do when someone answers my question?
  • 我已经添加了代码和如上所示的错误

标签: tomcat jakarta-ee netbeans sesame


【解决方案1】:

我不确定您从哪里获得此代码示例,但 Sesame 2 中不存在 SesameServiceSparqlqueryUnknownRepositoryException 类。

您正在使用 非常 旧版本的 Sesame(1.x,不再受支持,至少从 2007 年起就不再支持),或者您正在使用一些第三方包装库.

确保您使用的是最新版本的 Sesame(最新稳定版本可在 website 上找到)。

连接芝麻服务器的正确/当前方式如下:

 // connect to the server
 String serverUrl = "http://localhost:8080/openrdf-sesame";
 RepositoryManager manager = RepositoryProvider.getRepositoryManager(serverUrl);

 // get a list of the ids of all existing repositories
 List<String> ids = manager.getRepositoryIDs();

 // open a repository with a known identifier, e.g. "test"
 Repository rep = manager.getRepository("test");

等等。有关如何使用 Sesame 的更多详细信息,请参阅Sesame website 上提供的文档,尤其是tutorial"Programming with Sesame" 章节和API Javadoc

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-24
    相关资源
    最近更新 更多