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ドメインのはFrameクラスですが、範囲はintです。

返信ありがとうございます!

4

1 に答える 1

2

null以下の2行のいずれかがポインタを返しているようです。

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

既存のURIを探していることを確認します。

于 2012-06-25T10:59:04.423 に答える