【问题标题】:NoSuchMethodError when trying to connect to Sesame Repository尝试连接到 Sesame Repository 时出现 NoSuchMethodError
【发布时间】:2015-01-25 14:36:45
【问题描述】:

当我尝试访问芝麻服务器中的存储库时,我的项目中运行了以下代码:

   try{
    String serverUrl = "http://localhost:8080/openrdf-sesame";
    String repositoryID ="200"; 
     RepositoryProvider.getRepositoryManager(serverUrl);
     Repository myRepository =new HTTPRepository(serverUrl,repositoryID);
                myRepository.initialize();
                RepositoryConnection con= myRepository.getConnection();
    }

我什至使用调试来定位错误的来源,但它似乎来自:

    RepositoryConnection con= myRepository.getConnection();

当我运行代码时,出现以下错误。

HTTP Status 500 -

type Exception report

message

descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

exception

java.lang.NoSuchMethodError: org.openrdf.model.impl.ValueFactoryImpl.getInstance()Lorg/openrdf/model/impl/ValueFactoryImpl;

note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1.1 logs.

【问题讨论】:

标签: java repository sesame


【解决方案1】:

NoSuchMethodError 通常表示您运行程序使用的库版本与您用于编译它时使用的库版本不同。一个常见的原因是您的运行时类路径包含同一个库的多个版本,而 JRE 选择了“错误的”。

由于这种情况下的错误发生在服务器端,您应该查看您的 GlassFish 部署,并确保它不包含多个版本的 Sesame 库。

【讨论】:

  • 我已经尝试跟踪错误但是当我打开 org.openrdf.model.impl.ValueFactoryImpl 时没有 getInstance() 方法,我不知道为什么 getConnection() 正在调用 getInstance( )
  • 因为你使用了错误版本的芝麻库(或库)。 ValueFactoryImpl 确实有一个静态的getInstance()方法,如果你的副本没有,那意味着你使用的是一个非常旧的版本。
  • 一般来说,您应该好好看看您的项目设置,并检查您是否包含了正确版本的库(并且不包含任何旧/过时的版本)。
  • 我已经更新到最新版本的 sesame-model-2.8.0-beta2.jar 并且我已经检查过该方法确实存在。但我仍然收到相同的错误消息。
  • 您真的在检查 (Glassfish) 服务器上运行的 Sesame 的版本吗?因为正如我之前所说:这是导致错误的原因,根据错误消息,不是您在自己的(客户端)程序中使用的 Sesame 版本。重复一遍:您需要检查某处是否包含旧版本的 Sesame。类路径上同一库的不同版本是导致此错误的常见原因。
猜你喜欢
  • 2016-06-16
  • 2023-03-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-08-31
  • 1970-01-01
  • 2014-08-01
  • 2015-05-28
相关资源
最近更新 更多