gpt4 book ai didi

java - 在 NetBeans 6.0 中创建 javax.microedition.rms.RecordStore 时出错

转载 作者:行者123 更新时间:2023-12-04 07:04:42 24 4
gpt4 key购买 nike

我正在尝试使用 J2ME 编写一个应用程序,该应用程序使用 javax.microedition.rms.RecordStore来存储持久数据。我正在 Gentoo 上的 NetBeans 6.0 和 J2ME 2.2 中开发这个项目。当我尝试运行该项目时,出现错误,因为显然无法创建记录存储。这是包括堆栈跟踪的输出示例:

jar:pre-run:cldc-run:Copying 1 file to /home/dzaslavs/ellipsix/programming/cataschedule/dist/nbrun1623864904410254936Copying 1 file to /home/dzaslavs/ellipsix/programming/cataschedule/dist/nbrun1623864904410254936Jad URL for OTA execution: http://localhost:8082/servlet/org.netbeans.modules.mobility.project.jam.JAMServlet/home/dzaslavs/ellipsix/programming/cataschedule/dist//CATASchedule.jadStarting emulator in execution modeRunning with storage root rmsjavax.microedition.rms.RecordStoreException: error opening record store file        at javax.microedition.rms.RecordStore.(RecordStore.java:2150)        at javax.microedition.rms.RecordStore.openRecordStore(RecordStore.java:208)        at net.ellipsix.cata.StopRecordStore.(StopRecordStore.java:48)        at net.ellipsix.cata.CATAMIDlet.getStopList(CATAMIDlet.java:169)        at net.ellipsix.cata.CATAMIDlet.startMIDlet(CATAMIDlet.java:64)        at net.ellipsix.cata.CATAMIDlet.startApp(CATAMIDlet.java:449)        at javax.microedition.midlet.MIDletProxy.startApp(MIDletProxy.java:44)        at com.sun.midp.midlet.Scheduler.schedule(Scheduler.java:372)        at com.sun.midp.main.Main.runLocalClass(Main.java:461)        at com.sun.midp.main.Main.main(Main.java:126)

I've found a link to what I think is the source of RecordStore, where the exception is being thrown: http://jcs.mobile-utopia.com/jcs/78052_RecordStore.java. The relevant line is down near the bottom, basically like this:

try {
...
}
catch (java.io.IOException ioe) {
...
throw new RecordStoreException("error opening record store " +
"file");
}

这表明当 NetBeans 尝试创建记录存储文件时触发了 IOException。但为什么会这样呢?不幸的是,输出没有说明记录存储创建失败的确切原因。有谁知道可能出了什么问题,或者有关 NetBeans 如何处理的任何信息 RecordStore s 内部?

这是我的代码中触发错误的构造函数(如果相关):
public StopRecordStore() throws RecordStoreException {
this.store = RecordStore.openRecordStore("freqstops", true);
if (store.getNumRecords() == 0) {
try {
byte[] collegeAllen = new StopRecord((short)1, "College & Allen").toBytes();
store.addRecord(collegeAllen, 0, collegeAllen.length);
}
catch(IOException ioe) {
ioe.printStackTrace();
} // do nothing
}
}

编辑:...10 小时后没有答案?真的吗?

最佳答案

我运行了 strace netbeans-6.0 并观察了在应用程序抛出错误时出现在输出中的文件名。

[pid 10593] stat64("/opt/sun-j2me-bin-2.2/bin/./../appdb/rms/run_by_class_storage_freqstops.db", 0xbfa475c0) = -1 ENOENT (没有这样的文件或目录)
[pid 10593] open("/opt/sun-j2me-bin-2.2/bin/./../appdb/rms", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|0x80000) = -1 ENOENT (没有那个文件或目录)
[pid 10593] stat64("/opt/sun-j2me-bin-2.2/bin/./../appdb/rms", 0xbfa475d0) = -1 ENOENT (没有这样的文件或目录)
[pid 10593] mkdir("/opt/sun-j2me-bin-2.2/bin/./../appdb/rms", 0777) = -1 EACCES (权限被拒绝)

手动创建目录 /opt/sun-j2me-bin-2.2/appdb/rmschmod将其定为 0777 解决了问题。

关于java - 在 NetBeans 6.0 中创建 javax.microedition.rms.RecordStore 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1298018/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com