我正在尝试用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/nbrun1623864904410254936
Copying 1 file to /home/dzaslavs/ellipsix/programming/cataschedule/dist/nbrun1623864904410254936
Jad URL for OTA execution: http://localhost:8082/servlet/org.netbeans.modules.mobility.project.jam.JAMServlet/home/dzaslavs/ellipsix/programming/cataschedule/dist//CATASchedule.jad
Starting emulator in execution mode
Running with storage root rms
javax.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)
我找到了一个链接
认为
是
RecordStore
,如果引发异常:
http://jcs.mobile-utopia.com/jcs/78052_RecordStore.java
. 相关的线在底部附近,基本上是这样的:
try {
...
}
catch (java.io.IOException ioe) {
...
throw new RecordStoreException("error opening record store " +
"file");
}
因此,这意味着当NetBeans试图创建记录存储文件时,会触发IOException。但为什么会这样呢?不幸的是,输出对创建记录存储失败的确切原因保持沉默。有人知道可能出了什么问题,或者关于NetBeans如何处理的问题吗?
记录存储
内部的?
下面是我的代码中触发错误的构造函数,如果相关的话:
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小时后没有答案?真的?