SMS Midlet for Razr V3 - keep getting a SecurityException

Posted on 2006-04-22
Last Modified: 2008-01-09
I've kind of hacked my way through my first midlet to send an SMS and I keep getting the following error:

java.lang.SecurityException: was denied

The phone is a Razr V3, CLDC 1.0, MIDP 2.0.  The Java App Loader is unlocked so I've been transfering the app with Midway.  It runs through Sun's emulator but I've had some other issues with the Motorola one, so I cannot say whether or not it's working there.

From the JAD:
MIDlet-1: SMS, SMS.png, SMS
MIDlet-Jar-Size: 2980
MIDlet-Jar-URL: SMS.jar
MIDlet-Name: SMS
MIDlet-Vendor: bowline
MIDlet-Version: 1.0
MicroEdition-Configuration: CLDC-1.0
MicroEdition-Profile: MIDP-2.0

The applicable source (I think):
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import javax.wireless.messaging.*;
import java.util.*;
      public void sendMessage(final String addr, final String msg) {
            System.out.println("Message Start");
            Thread th = new Thread() {
                  public void run() {
                        try {
                              MessageConnection conn = (MessageConnection)"sms://+1" + addr);
                              TextMessage txtMsg = (TextMessage)conn.newMessage(MessageConnection.TEXT_MESSAGE);
                              System.out.println("Message Sent");
                              mForm.append("...Sent Message");
                              } catch (Exception e) {
                                    mForm.append("...ERROR - " + e);

I've done some reading on the api and the implementation of it on this version of my phone, and from what I can tell JSR 120 is supported, and I should just have to deal with prompts asking me if it's okay that the app sends a message.  I've gone into the permissions on the application, and there's not even an option for messaging, just data access.  I feel like something is getting lost in translation - like when the application is installed, the phone does not know that it is going to try to access this api.  I've tried messing around (blindly) with the different types of permissions and opt-permissions on the midlet's settings with no luck so far.

1.  Can I send SMS messages with a Midlet on this version of my phone?
2.  Do I have to have a signed application to access the api? (this is just a personal project, so I'd rather not spend the money)
3.  What am I doing wrong?

Thanks in advance for any help!

(and I can post more code if necessary, but it mostly just has a text box where you type in the phone number and press send - just enough to test right now)
Question by:bowline
    LVL 13

    Expert Comment

    1. Yes.
    2. It has to be signed to operate on the device. No way around it. You are accessing a protected API - it's like that in JSR 120
    3. Probably nothing wrong with your code.

    Excerpt From JSR 120:
    For sending messages, the MessageConnection object provides factory methods for creating Message objects. For receiving messages, the MessageConnection supports an event listener-based receive mechanism, in addition to a synchronous blocking receive() method. *The methods for sending and receiving messages can throw a SecurityException if the application does not have the permission to perform these operations.*
    LVL 2

    Author Comment


    Thanks for the reply, but I seem to be getting conflicting information from different sources.  According to the documentation on the Razr V3, when dealing with unsigned/untrusted midlets, the phone will prompt the user for approval when a midlet tries to access the WMA.  The only API's that are outright denied access seem to be those that deal with personal information and contact management.  I've contacted Motorola support and they've told me that it works as documented but said that some carriers will put further restrictions on phones to prevent access to the API.  I contacted T-Mobile (my carrier) to see if this was the case and they said that they don't do anything additional.  Do you have any

    So if I do have to go with the signing - is there a cheap/easy way to go through this?  Especially since this is a personal project and I'm hacking my way through it - I've got no idea how the signing would work.

    LVL 13

    Accepted Solution

    What the SecurityException is saying is that the application doesn't have sufficient permission to perform the operation.
    I don't know the Razr very well; perhaps you can manually allow the application to make these calls (app permissions perhaps?). Otherwise, you'd have to go through Motorola ( and get it signed.
    LVL 2

    Author Comment

    Sorry - I thought this was already deleted...tried to get to it a couple of weeks ago.

    I'll award the points, but the solution was actually to flex the phone.  T-Mobile apparently locks down access to a lot of API's - so I reloaded the phone with another carrier's package (Orange) and it worked...

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    In this article I will describe how to setup a Cisco WLC 5508 to work with Apple's Bonjour protocol across VLANs.  I will also discuss using screen mirroring and Airplay on an AppleTV v3.  This article covers the wireless network only and requires m…
    This paper addresses the security of Sennheiser DECT Contact Center and Office (CC&O) headsets. It describes the DECT security chain comprised of “Pairing”, “Per Call Authentication” and “Encryption”, which are all part of the standard DECT protocol.
    This Micro Tutorial will show you how to maximize your wireless card to its maximum capability. This will be demonstrated using Intel(R) Centrino(R) Wireless-N 2230 wireless card on Windows 8 operating system.
    Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now