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

发布于 2024-08-02 05:10:15 字数 2550 浏览 4 评论 0原文

我正在尝试使用 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 如何在内部处理 RecordStore?

这是我的代码中触发错误的构造函数(如果相关):

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 小时后没有答案?真的吗?

I'm trying to write an application with J2ME that uses javax.microedition.rms.RecordStore to store persistent data. I'm developing this project in NetBeans 6.0 and J2ME 2.2 on Gentoo. When I try to run the project, I get an error because apparently the record store can't be created. Here's a sample of output including the stack trace:

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)

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");
}

so that suggests that there is an IOException triggered when NetBeans tries to create the record store file. But why would that happen? The output is unfortunately silent on exactly why the record store creation is failing. Does anyone know what might be going wrong, or anything about how NetBeans handles RecordStores internally?

Here's the constructor from my code in which the error is triggered, if it's relevant:

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
    }
}

EDIT: ...no answers after 10 hours? Really?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

内心荒芜 2024-08-09 05:10:15

我跑了

strace netbeans-6.0

and watched for filenames appearing in the output around the time when the application threw an error.

[pid 10593] stat64("/opt/sun-j2me-bin-2.2/bin/./../appdb/rms/run_by_class_storage_freqstops.db", 0xbfa475c0) = -1 ENOENT (No such file or directory)
[pid 10593] open("/opt/sun-j2me-bin-2.2/bin/./../appdb/rms", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|0x80000) = -1 ENOENT (No such file or directory)
[pid 10593] stat64("/opt/sun-j2me-bin-2.2/bin/./../appdb/rms", 0xbfa475d0) = -1 ENOENT (No such file or directory)
[pid 10593] mkdir("/opt/sun-j2me-bin-2.2/bin/./../appdb/rms", 0777) = -1 EACCES (Permission denied)

手动创建目录 /opt/sun-j2me-bin-2.2/appdb/rms 并将其 chmod 修改为 0777 解决了问题。

I ran

strace netbeans-6.0

and watched for filenames appearing in the output around the time when the application threw an error.

[pid 10593] stat64("/opt/sun-j2me-bin-2.2/bin/./../appdb/rms/run_by_class_storage_freqstops.db", 0xbfa475c0) = -1 ENOENT (No such file or directory)
[pid 10593] open("/opt/sun-j2me-bin-2.2/bin/./../appdb/rms", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|0x80000) = -1 ENOENT (No such file or directory)
[pid 10593] stat64("/opt/sun-j2me-bin-2.2/bin/./../appdb/rms", 0xbfa475d0) = -1 ENOENT (No such file or directory)
[pid 10593] mkdir("/opt/sun-j2me-bin-2.2/bin/./../appdb/rms", 0777) = -1 EACCES (Permission denied)

Manually creating the directory /opt/sun-j2me-bin-2.2/appdb/rms and chmodding it to 0777 solved the problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文