0

我编写了以下耶拿代码。但这是一个错误,我不知道如何解决这个问题。

这是代码

Resource   subject   = null;
Property   property  = null;
Statement  statement = null;

...

OntModel domainModel = ModelFactory.createOntologyModel(ProfileRegistry.OWL_DL_LANG);
domainModel.read((new FileInputStream(bootstrapInOwl)), null);

subject = domainModel.getIndividual(bootbase + "Frame" + frameNum);                     
property = domainModel.getOntProperty(bootbase + "hasDuration");                
statement = domainModel.createLiteralStatement(subject, property, 12000);
domainModel.add(statement);

这是错误消息

Exception in thread "main" java.lang.NullPointerException
    at com.hp.hpl.jena.rdf.model.impl.StatementImpl.<init>(StatementImpl.java:29)
    at com.hp.hpl.jena.rdf.model.impl.ModelCom.createStatement(ModelCom.java:1116)
    at com.hp.hpl.jena.rdf.model.impl.ModelCom.createLiteralStatement(ModelCom.java:626)
    at soctrace.Intology.manageOntologies2(Intology.java:217)
    at soctrace.Intology.main(Intology.java:56)

属性hasDuration域是FrameClass 而他的范围是int

感谢您的回复!

4

1 回答 1

2

以下两行之一似乎返回了一个null指针:

subject = domainModel.getIndividual(bootbase + "Frame" + frameNum);                     
property = domainModel.getOntProperty(bootbase + "hasDuration");

确认您正在查找现有的 URI。

于 2012-06-25T10:59:04.423 回答