• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3401
  • Last Modified:

SMS Midlet for Razr V3 - keep getting a SecurityException

Hi
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: javax.microedition.io.Connector.sms 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:
<snippet>
MIDlet-1: SMS, SMS.png, SMS
MIDlet-Jar-Size: 2980
MIDlet-Jar-URL: SMS.jar
MIDlet-Name: SMS
MIDlet-Permissions-Opt: javax.microedition.io.Connector.sms,javax.wireless.messaging.sms.send,javax.wireless.messaging.sms.receive
MIDlet-Vendor: bowline
MIDlet-Version: 1.0
MicroEdition-Configuration: CLDC-1.0
MicroEdition-Profile: MIDP-2.0
</snippet>

The applicable source (I think):
<snippet>
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import javax.microedition.io.*;
import javax.wireless.messaging.*;
import java.util.*;
import java.io.*;
</snippet>
<snippet>
      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)Connector.open("sms://+1" + addr);
                              TextMessage txtMsg = (TextMessage)conn.newMessage(MessageConnection.TEXT_MESSAGE);
                              txtMsg.setPayloadText(msg);
                              conn.send(txtMsg);
                              conn.close();
                              System.out.println("Message Sent");
                              mForm.append("...Sent Message");
                              } catch (Exception e) {
                                    System.out.println(e);
                                    mForm.append("...ERROR - " + e);
                                    }
                        }
                  };
            th.start();
            }
</snippet>

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.

So...
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)
0
bowline
Asked:
bowline
  • 2
  • 2
1 Solution
 
bgloddeCommented:
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.*
0
 
bowlineAuthor Commented:
bglodde

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.

Thanks.
0
 
bgloddeCommented:
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 (http://www.motocoder.com/motorola/pcsHome.jsp?node_name=Innovate) and get it signed.
0
 
bowlineAuthor Commented:
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...
0

Featured Post

Granular recovery for Microsoft Exchange

With Veeam Explorer for Microsoft Exchange you can choose the Exchange Servers and restore points you’re interested in, and Veeam Explorer will present the contents of those mailbox stores for browsing, searching and exporting.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now