Error creating javax.microedition.rms.RecordStore in NetBeans 6.0
I am trying to write an application with J2ME that uses javax.microedition.rms.RecordStore
persistent data storage. I am 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 cannot be created. Here's a sample of the 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 found a link to what I think is the source RecordStore
where the exception is being thrown: http://jcs.mobile-utopia.com/jcs/78052_RecordStore.java . The relevant line is at the bottom at the bottom, basically like this:
try {
...
}
catch (java.io.IOException ioe) {
...
throw new RecordStoreException("error opening record store " +
"file");
}
so it says that an IOException is thrown when NetBeans tries to create a recordstore file. But why does this happen? The output, unfortunately, doesn't say why the creation of the record store doesn't work. Does anyone know what could be going wrong, or anything about how NetBeans handles RecordStore
internally?
Here's a constructor from my code that triggers the error, if it matters:
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 replies after 10 hours? Really?
I launched
strace netbeans-6.0
and watched the filenames appear in the output around the time 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 a directory /opt/sun-j2me-bin-2.2/appdb/rms
and chmod
having it up to 0777 solve the problem.