我对Jena / TDB完全陌生。我要做的就是使用tdb脚本或通过Java api从一些示例rdf,N3等文件中加载数据。
我试图在Cygwin上使用tbdloader加载数据(在Windows XP和IBM Java 1.6上为tdb-0.9.0)。以下是我运行的命令:

$ export TDBROOT=/cygdrive/d/Project/Store_DB/jena-tdb-0.9.0-incubating
$ export PATH=$TDBROOT/bin:$PATH


tdbloader on Cygwin: java.lang.NoClassDefFoundError所述,我还在tdbloader脚本中更改了Java的类路径:

exec java $JVM_ARGS $SOCKS -cp "PATH_OF_JAR_FILES" "tdb.$TDB_CMD" $TDB_SPEC "$@"


因此,当我运行$ tdbloader --help时,它将正确显示帮助。
但是当我跑步时

$ tdbloader --loc /cygdrive/d/Project/Store_DB/data1


要么

$ tdbloader --loc /cygdrive/d/Project/Store_DB/data1 test.rdf


我收到以下异常:

        com.hp.hpl.jena.tdb.base.file.FileException: Failed to open: d:\cygdrive\d\Project\Store_DB\data1\node2id.idn (mode=rw)
        at com.hp.hpl.jena.tdb.base.file.ChannelManager.open$(ChannelManager.java:83)
        at com.hp.hpl.jena.tdb.base.file.ChannelManager.openref$(ChannelManager.java:58)
        at com.hp.hpl.jena.tdb.base.file.ChannelManager.acquire(ChannelManager.java:47)
        at com.hp.hpl.jena.tdb.base.file.FileBase.<init>(FileBase.java:57)
        at com.hp.hpl.jena.tdb.base.file.FileBase.<init>(FileBase.java:46)
        at com.hp.hpl.jena.tdb.base.file.FileBase.create(FileBase.java:41)
        at com.hp.hpl.jena.tdb.base.file.BlockAccessBase.<init>(BlockAccessBase.java:46)
        at com.hp.hpl.jena.tdb.base.block.BlockMgrFactory.createStdFile(BlockMgrFactory.java:98)
        at com.hp.hpl.jena.tdb.base.block.BlockMgrFactory.createFile(BlockMgrFactory.java:82)
        at com.hp.hpl.jena.tdb.base.block.BlockMgrFactory.create(BlockMgrFactory.java:58)
        at com.hp.hpl.jena.tdb.setup.Builder$BlockMgrBuilderStd.buildBlockMgr(Builder.java:196)
        at com.hp.hpl.jena.tdb.setup.Builder$RangeIndexBuilderStd.createBPTree(Builder.java:165)
        at com.hp.hpl.jena.tdb.setup.Builder$RangeIndexBuilderStd.buildRangeIndex(Builder.java:134)
        at com.hp.hpl.jena.tdb.setup.Builder$IndexBuilderStd.buildIndex(Builder.java:112)
        at com.hp.hpl.jena.tdb.setup.Builder$NodeTableBuilderStd.buildNodeTable(Builder.java:85)
        at com.hp.hpl.jena.tdb.setup.DatasetBuilderStd$NodeTableBuilderRecorder.buildNodeTable(DatasetBuilderStd.java:389)
        at com.hp.hpl.jena.tdb.setup.DatasetBuilderStd.makeNodeTable(DatasetBuilderStd.java:300)
        at com.hp.hpl.jena.tdb.setup.DatasetBuilderStd._build(DatasetBuilderStd.java:167)
        at com.hp.hpl.jena.tdb.setup.DatasetBuilderStd.build(DatasetBuilderStd.java:157)
        at com.hp.hpl.jena.tdb.setup.DatasetBuilderStd.build(DatasetBuilderStd.java:70)
        at com.hp.hpl.jena.tdb.StoreConnection.make(StoreConnection.java:132)
        at com.hp.hpl.jena.tdb.transaction.DatasetGraphTransaction.<init>(DatasetGraphTransaction.java:46)
        at com.hp.hpl.jena.tdb.sys.TDBMakerTxn._create(TDBMakerTxn.java:50)
        at com.hp.hpl.jena.tdb.sys.TDBMakerTxn.createDatasetGraph(TDBMakerTxn.java:38)
        at com.hp.hpl.jena.tdb.TDBFactory._createDatasetGraph(TDBFactory.java:166)
        at com.hp.hpl.jena.tdb.TDBFactory.createDatasetGraph(TDBFactory.java:74)
        at com.hp.hpl.jena.tdb.TDBFactory.createDataset(TDBFactory.java:53)
        at tdb.cmdline.ModTDBDataset.createDataset(ModTDBDataset.java:95)
        at arq.cmdline.ModDataset.getDataset(ModDataset.java:34)
        at tdb.cmdline.CmdTDB.getDataset(CmdTDB.java:137)
        at tdb.cmdline.CmdTDB.getDatasetGraph(CmdTDB.java:126)
        at tdb.cmdline.CmdTDB.getDatasetGraphTDB(CmdTDB.java:131)
        at tdb.tdbloader.loadQuads(tdbloader.java:163)
        at tdb.tdbloader.exec(tdbloader.java:122)
        at arq.cmdline.CmdMain.mainMethod(CmdMain.java:97)
        at arq.cmdline.CmdMain.mainRun(CmdMain.java:59)
        at arq.cmdline.CmdMain.mainRun(CmdMain.java:46)
        at tdb.tdbloader.main(tdbloader.java:53)
Caused by: java.io.FileNotFoundException: d:\cygdrive\d\Project\Store_DB\data1\node2id.idn (The system cannot find the path specified.)
        at java.io.RandomAccessFile.open(Native Method)
        at java.io.RandomAccessFile.<init>(RandomAccessFile.java:222)
        at java.io.RandomAccessFile.<init>(RandomAccessFile.java:107)
        at com.hp.hpl.jena.tdb.base.file.ChannelManager.open$(ChannelManager.java:80)
        ... 37 more


我不确定node2id.idn文件是什么,为什么会期望它呢?

最佳答案

文件node2id.idn是TDB的内部索引文件之一。您不必自己创建或管理。我刚刚在cygwin上尝试过tdbloader,对我来说效果很好。我可以想到两种基本的可能性:


您的磁盘已满
TDB索引已损坏


如果这是您要加载到另一个空的TDB中的第一个文件,则第二种可能性不太可能。如果要加载到非空的TDB中,请尝试删除TDB映像并重新开始。请注意,TDB本身并不管理并发写入:如果您有多个进程在向单个TDB映像进行写入,则必须在应用程序级别处理锁定,或者使用TDB的transactions

当然,最终的可能性是您的磁盘片状。您可能想在另一台机器上尝试您的代码。

如果这些建议均无帮助,请将完整的最小测试用例发送到Jena用户列表。

08-25 14:32