[英]Apache Jena Error: Exception in thread “main” org.apache.jena.shared.PropertyNotFoundException
I'm currently working with Apache Jena. 我目前正在使用Apache Jena。 Actually i try to understand all tutorial that Apache Jena provide and found error like this on Tutorial06 -->
实际上,我尝试了解Apache Jena提供的所有教程,并在Tutorial06中发现了这样的错误->
Exception in thread "main" org.apache.jena.shared.PropertyNotFoundException: http://www.w3.org/2001/vcard-rdf/3.0#N at org.apache.jena.rdf.model.impl.ModelCom.getRequiredProperty(ModelCom.java:1281) at org.apache.jena.rdf.model.impl.ResourceImpl.getRequiredProperty(ResourceImpl.java:173) at belajar.Tutorial06.main(Tutorial06.java:38) C:\\AppData\\Local\\NetBeans\\Cache\\8.2\\executor-snippets\\run.xml:53: Java returned: 1 BUILD FAILED (total time: 2 seconds)
线程“主要” org.apache.jena.shared.PropertyNotFoundException中的异常:org.apache.jena.rdf.model.impl.ModelCom上的http://www.w3.org/2001/vcard-rdf/3.0#N 。 org.apache.jena.rdf.model.impl.ResourceImpl.getRequiredProperty(ResourceImpl.java:173)处的getRequiredProperty(ModelCom.java:1281)at belajar.Tutorial06.main(Tutorial06.java:38)C:\\ AppData \\ Local \\ NetBeans \\ Cache \\ 8.2 \\ executor-snippets \\ run.xml:53:Java返回:1个失败的日志(总时间:2秒)
Code: 码:
public class Tutorial06 extends Object {
static final String inputFileName = "vc-db-1.rdf";
static final String johnSmithURI = "http://somewhere/JohnSmith";
public static void main (String args[]) {
// create an empty model
Model model = ModelFactory.createDefaultModel();
// use the FileManager to find the input file
InputStream in = FileManager.get().open(inputFileName);
if (in == null) {
throw new IllegalArgumentException( "File: " + inputFileName + " not found");
}
// read the RDF/XML file
model.read(new InputStreamReader(in), "");
// retrieve the Adam Smith vcard resource from the model
Resource vcard = model.getResource(johnSmithURI);
// retrieve the value of the N property
Resource name = (Resource) vcard.getRequiredProperty(VCARD.N)
.getObject();
// retrieve the given name property
String fullName = vcard.getRequiredProperty(VCARD.FN)
.getString();
// add two nick name properties to vcard
vcard.addProperty(VCARD.NICKNAME, "Smithy")
.addProperty(VCARD.NICKNAME, "Adman");
// set up the output
System.out.println("The nicknames of \"" + fullName + "\" are:");
// list the nicknames
StmtIterator iter = vcard.listProperties(VCARD.NICKNAME);
while (iter.hasNext()) {
System.out.println(" " + iter.nextStatement().getObject()
.toString());
}
}
}
Please help me 请帮我
The URI you are querying for has a missing back slash. 您要查询的URI缺少反斜杠。
The current line in the tutorial: 本教程中的当前行:
static final String johnSmithURI = "http://somewhere/JohnSmith";
A line that you could replace it with: 您可以将其替换为的行:
static final String johnSmithURI = "http://somewhere/JohnSmith/";
This is what is defined in the provided file, vc-db-1.rdf, I don't believe there is a requirement for a / at the end of URIs or anything. 这是提供的文件vc-db-1.rdf中定义的内容,我认为URI或其他内容的末尾不需要/。 You could also change the URI in vc-db-1.rdf and it should work just as good.
您也可以在vc-db-1.rdf中更改URI,它应该也可以正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.