Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.lang.SecurityException

 
Jari Kemppinen
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am getting an annoying security exception using the J2ME wireless toolkit and the Nokia Prototype_2_0_S60_MIDP_Emulator.
When I try to connect to the memory using jsr75 I get the following error.

java.lang.SecurityException: Application not authorized to access the restricted API

I tried setting the permissions to trusted but that didn't work. Is there any thing that I am missing?
 
Jari Kemppinen
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Found a solution, had to manually edit security constraints xml within the emulator, just thought I would post solution up if anyone else had same problem.
 
Michael Yuan
author
Ranch Hand
Posts: 1427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jari for posting the solution. It sounds like a bug in the emulator. I think Nokia licenses the Sun emulator for their prototype and they just added a new skin ...
 
jyothi gopu
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jari,

I have the same problem..Can you please tell me what should I change the security constraints means what should I add or delete in the xml file for the emulator?

thanks
Jyothi
 
Jari Kemppinen
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Goto this following xml file within the emulator. Probably be different on your machine but you should find the file.

C:\WTK22\wtklib\devices\Nokia_Prototype_SDK_2_0\devices\
Prototype_2_0_S60_MIDP_Emulator\bin\security_config.xml

Within the <function name="Read User Data Access"> tag and the <function name="Write User Data Access"> tag you will find a setting that says "untrusted mode=0". Change it to "untrusted mode=4". I think that is right from what I can remember

Good luck.
 
jyothi gopu
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jari,
Thank you so much
Jyothi
 
Krishna Nimishakavi
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jyothi,

That worked for you? I am using Nokia emulator and I didnt found the specified tag in security_config.xml file. I tried to add that tag to this file. I am still getting the same error "java.lang.SecurityException: Application not authorized to access the restricted API" where else I have to configure? Please help me.

Thanks,
Krishna
 
jyothi gopu
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Please go thru this link ...
Understanding MIDP 2.0's Security Architecture
http://developers.sun.com/techtopics/mobility/midp/articles/permissions/

If you deny the connection, Connector.open() throws a SecurityException. So you should handle them gracefully.

Thanks
Jyothi
 
Santhana Lakshmi.S
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i had the same Security Exception pbm while writing a file in the nokia emulator after changing the untrusted mode=0 to 4 it is working fine in emulator.now i'm having one doubt whether this security exception occurs only in emulator r also in mobile.If it occurs in mobile then how can i change the security_config tags?
reply ASAP
thanx a lot
 
gnans info
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys,
Iam new one to mobile, and writing now an application in that i tried to
call second MIDlet present in same pack.
with all of your previous chat, i got some idea to communicate MIDlets.
In my WTK22 Toolkit there is no Nokia s60. So i tried with Nokia developer tool s60 Emulator, in that also security_config.xml contains nothing like <function name="Read User Data Access">
<function name="Write User Data Access"> so i put it myself in that file changed.
I got connection ,no security Exception ,but one more problem....
condition goes to second midlet constructor and return back to first midlet.
what is the problem my one...please
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic