我只是想将我的本体添加到数据库存储库中……</p>
我的代码是:
oConnection = H2Db.getM_oConnection();
m_oSDBConnection = new SDBConnection(oConnection);
StoreDesc oStoreDesc = new StoreDesc(LayoutType.LayoutTripleNodesHash, DatabaseType.H2);
m_oStore = SDBFactory.connectStore(m_oSDBConnection, oStoreDesc);
m_oModel = SDBFactory.connectDefaultModel(m_oStore);
InputStream oInputStream = this.getClass().getResourceAsStream("/META-INF/betaas_context.owl");
m_oModel.read(oInputStream, null);
开头有以下依赖:
ID State Blueprint Level Name
[ 994] [Active ] [ ] [ 80] H2 Database Engine (1.3.170)
[1114] [Active ] [ ] [ 80] wrap_mvn_org.apache.jena_jena-iri_1.0.0 (0)
[1223] [Active ] [ ] [ 80] wrap_mvn_org.apache.jena_jena-arq_2.11.0 (0) -> contains package org.apache.jena.riot.adapters
[1279] [Active ] [ ] [ 80] wrap_mvn_org.apache.jena_jena-core_2.11.0 (0)
[1311] [Active ] [ ] [ 80] wrap_mvn_xerces_xercesImpl_2.7.1 (0)
[1314] [Active ] [ ] [ 80] wrap_mvn_com.ibm.icu_icu4j_3.4.4 (0)
我得到了这个例外:
java.lang.Exception: com.hp.hpl.jena.shared.ConfigException: Reader not found on classpath
Caused by: com.hp.hpl.jena.shared.ConfigException: Reader not found on classpath
Caused by: java.lang.ClassNotFoundException:
org.apache.jena.riot.adapters.JenaReadersWriters$RDFReaderRIOT_RDFXML
问题出在以下行:oModel.read(oInputStream, null);
编辑
然后,按照 AndyS 提到的建议(见下文),我更新了我的 Jena 库并使用了 2.11.1-SNAPSHOT:
[1511] [Active ] [ ] [ 80] wrap_mvn_org.apache.jena_jena-core_2.11.1-SNAPSHOT (0)
[1512] [Active ] [ ] [ 80] wrap_mvn_org.apache.jena_jena-arq_2.11.1-SNAPSHOT (0)
[1515] [Active ] [ ] [ 80] wrap_mvn_org.apache.jena_jena-sdb_1.4.1-SNAPSHOT (0)
[1516] [Resolved ] [ ] [ 80] wrap_mvn_xerces_xercesImpl_2.11.0 (0)
[1521] [Active ] [ ] [ 80] wrap_mvn_org.apache.jena_jena-iri_1.0.1-SNAPSHOT (0)
但例外是一样的: ClassNotFoundException: org.apache.jena.riot.adapters.JenaReadersWriters$RDFReaderRIOT_RDFXML