问题描述
我正在使用Jena TDB加载RDF数据集并对其进行SPARQL查询。我正在使用以下maven依赖:
I'm using Jena TDB for loading an RDF dataset and making SPARQL queries against it. I'm using the following maven dependency:
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>apache-jena-libs</artifactId>
<type>pom</type>
<version>3.0.1</version>
</dependency>
这里是我试图创建TDB数据集的java代码:
And here's the java code where I'm trying to create a TDB dataset:
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) ,并出现以下错误消息:
It's failing on the first line of the function: TDBFactory.createDataset( directoryPath ) with the following error message:
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)
推荐答案
POM使用shade插件。它需要使用ServicesResourceTransformer转换器管理服务文件(META_INF / services /)。 org.apache.maven.plugins.shade.resource.ServicesResourceTransformer
The POM uses the shade plugin. It needs to manage services files (META_INF/services/) with a ServicesResourceTransformer transformer. org.apache.maven.plugins.shade.resource.ServicesResourceTransformer
参见例如:
这篇关于Jena TDB java.lang.ExceptionInInitializerError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!