• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I can not execute openRecordStore function in RMS

 
Jeru Liu
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It print out the following error message when execute the openRecordStore function:
Uncaught exception java/lang/SecurityException
I am using a Nokia Emulator
Thanks
[This message has been edited by Jeru Liu (edited December 19, 2001).]
 
john muchow
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you wrapping the code inside a try/catch block?
try
{
// The second parameter indicates that the record store
// should be created if it does not exist
rs = RecordStore.openRecordStore(REC_STORE, true );
}
catch (Exception e)
{
// do something
}
John Muchow
Author: Core J2ME Technology
 
Jeru Liu
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply
In fact,I test the code from CodeCamp from Sun.
here is the source code:
=========================================================
/**
* The constuctor opens the underlying record store,
* creating it if necessary.
*/
public RMSGameScores()
{
// Create a new record store for this example
try
{
System.out.println(" Counstructor starting now......");
recordStore = RecordStore.openRecordStore( "scores", true );
System.out.println(" Counstructor starting end......");
}
catch ( RecordStoreException rse )
{
System.out.println( "Record Store Exception in the ctor." + rse );
rse.printStackTrace();
}
}
 
Jeru Liu
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How ever,these piece of code can pass,
but when i want to construct this class,error occor,
I will post two block here,the first one is code,
the second one is debug info:
/**
* startApp()
*/
public void startApp() throws MIDletStateChangeException
{
System.out.println(" StartApp go......");
RMSGameScores rmsgs = new RMSGameScores();
System.out.println(" StartApp fail......");
=============================================================
Counstructor starting now......
Counstructor starting end......
StartApp go......
Uncaught exception java/lang/SecurityException
destroyApp( )

You will notice that the programm stop after execute
RMSGameScores rmsgs = new RMSGameScores();
RMSGameScores is the name of this class
 
Jeru Liu
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I catch the exception now:
The Exception is MIDletManager ERROR: Illegal attempt to construct RMSGameScores@ea0ef881
 
liang gu
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeru:
Your code looks fine. And your debug printout has:
Counstructor starting now......
Counstructor starting end......
So, looks like the RMS has been successfully opened once. According to J2ME API, it should be fine if you want to open the same store for a second time. However, there could be some bugs on the emulators as well as on the actual devices. I personally experienced some J2ME features that doesn't work on HandSpring Visor/Edge device.
Just based on your post, the exception could be generated when you open the RMS for the second time or somewhere else.
 
Jeru Liu
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gu,
I agree with your viewpoint,I just changed the emulator,
and it can works now.But I still don't know what cause the
error,another RMS programm can work well on Nokia's emulator,
while this one can only work on Sun's emulator.
Thanks for your reply!
BTW: Had u got my letter yesterday?
 
dan moore
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
presumably you've fixed problem by now!
but just in case anyone has problems with this, have found that :

is thrown if you try to explicity construct a new MIDlet sub-class XXXX(system reckons only the environment should be allowed to do this, i guess). so maybe this problem is because the stores class extends MIDlet, or maybe some other reason it objects to instantiation, but i don't think it's an RMS problem.
cheers, dan.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic