我正在使用 Jena TDB 加载 RDF 数据集并对它进行 SPARQL 查询。我正在使用以下 Maven 依赖项:
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>apache-jena-libs</artifactId>
<type>pom</type>
<version>3.0.1</version>
</dependency>
这是我试图创建 TDB 数据集的 java 代码:
public void loadDirectory(String outputFile){
Dataset dataset = TDBFactory.createDataset(directoryPath);
Model tdb = dataset.getDefaultModel();
FileManager.get().readModel(tdb, outputFile);
tdb.close();
dataset.close();
LOG.info("RDF dataset loaded to memory");
}
它在函数的第一行失败: TDBFactory.createDataset( directoryPath ) 并带有以下错误消息:
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.sdw.model.JenaModel.loadDirectory(JenaModel.java:69)
at org.sdw.Main.main(Main.java:75)
Caused by: java.lang.NullPointerException
at org.apache.jena.tdb.sys.EnvTDB.processGlobalSystemProperties(EnvTDB.java:33)
at org.apache.jena.tdb.TDB.init(TDB.java:250)
at org.apache.jena.tdb.sys.InitTDB.start(InitTDB.java:29)
at org.apache.jena.system.JenaSystem.lambda$init$40(JenaSystem.java:114)
at java.util.ArrayList.forEach(ArrayList.java:1249)
at org.apache.jena.system.JenaSystem.forEach(JenaSystem.java:179)
at org.apache.jena.system.JenaSystem.forEach(JenaSystem.java:156)
at org.apache.jena.system.JenaSystem.init(JenaSystem.java:111)
at org.apache.jena.tdb.TDBFactory.<clinit>(TDBFactory.java:40)