aspose file tools*
The moose likes Java Micro Edition and the fly likes ConnectionNotFoundException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "ConnectionNotFoundException" Watch "ConnectionNotFoundException" New topic
Author

ConnectionNotFoundException

Gurpreet Saini
Ranch Hand

Joined: Jun 09, 2002
Posts: 295
hi there,
When I compile this source code I get the following exception during run time.
public class SMS
{
private String smsc = "sms://+493206922000";
private String message = "HI there";
private MessageConnection conn;
public static void main(String args[])
{
new SMS();
}
public SMS()
{
try
{
conn = (MessageConnection) Connector.open(smsc);
sendMessage(conn, message);
}

catch(Exception e)
{
System.out.println(" Problem : " + e);
}
finally
{
try {
if (conn != null)
conn.close(); }
catch(Exception e) { System.out.println(e); }
}
}
public void sendMessage (MessageConnection conn, String message) throws IOException, InterruptedException
{
TextMessage msg = (TextMessage) conn.newMessage(conn.TEXT_MESSAGE);
msg.setAddress(smsc);
msg.setPayloadText(message);
conn.send(msg);
}
}
-------------------------------------
C:\sun>java SMS
Problem : javax.microedition.io.ConnectionNotFoundException: The requested proocol does not exist sms://+493206922000

The phone number is of simplewire.com. Which provides free virtual phone inbox to test sms applications. This exception I get when I work on Win95 platform.
Michael Yuan
author
Ranch Hand

Joined: Mar 07, 2002
Posts: 1427
You have several problems:
1. You are using a J2ME extension API on J2SE. That would not work since the J2ME WMA only works on supported handsets.
2. Simplewire is a serverside application that requires you to make a TCP/IP connection from your computer to their managed server. Then you can send messages to phone numbers via that connection. They have sample code in their Java SDK that shows you exactly how to use their server.
3. Your code might work if you change it to a J2ME MIDlet and run it on a WMA compatible handset.
Michael


Seam Framework: http://www.amazon.com/exec/obidos/ASIN/0137129394/mobileenterpr-20/
Ringful: http://www.ringful.com/
Gurpreet Saini
Ranch Hand

Joined: Jun 09, 2002
Posts: 295
hi there,
I had downloaded smplewire SMS sdk code. But it also have problems when I try to compile send_text.java file it gives me lot of erros saying the methods did not resolve for your references i am pasting code.
import com.simplewire.sms.*;
public class send_text
{
public static void main(String[] args) throws Exception
{
SMS sms = new SMS();
// Subscriber Settings
sms.setSubscriberID("123-456-789-12345");
sms.setSubscriberPassword("Password Goes Here");

// Optional Message Settings
// Specify source and destination ports that will appear
// in the GSM User-Data-Header
//sms.setSourcePort((short)0x0000);
//sms.setDestPort((short)0x0000);

// Message Settings
sms.setMsgPin("+11005101234");
sms.setMsgFrom("Demo");
sms.setMsgCallback("+11005551212");
sms.setMsgText("Hello World From Simplewire!");
System.out.println("Sending message to Simplewire...");
// Send Message
sms.msgSend();
// Check For Errors
if(sms.isSuccess())
{
System.out.println("Message was sent!");
}
else
{
System.out.println("Message was not sent!");
System.out.println("Error Code: " + sms.getErrorCode());
System.out.println("Error Description: " + sms.getErrorDesc());
System.out.println("Error Resolution: " + sms.getErrorResolution() + "\n");
}
}
}

------------------------------end of code -----------------
Not only this SMS.java file is also not given. Anyway, tell me if it is possible for you to write a short snippet about opening of an connection. Such that sms can be send. in the above code all the methods are not being resolved by the compiler. It gives an 11 errors. Here are the following errors:
symbol : method isSuccess ()
location: class SMS
if(sms.isSuccess())
^
send_text.java:73: cannot resolve symbol
symbol : method getErrorCode ()
location: class SMS
System.out.println("Error Code: " + sms.getErrorCode());
^
send_text.java:74: cannot resolve symbol
symbol : method getErrorDesc ()
location: class SMS
System.out.println("Error Description: " + sms.getErrorD
esc());
^
send_text.java:75: cannot resolve symbol
symbol : method getErrorResolution ()
location: class SMS
System.out.println("Error Resolution: " + sms.getErrorRe
solution() + "\n");
^
11 errors
Gurpreet Saini
Ranch Hand

Joined: Jun 09, 2002
Posts: 295
Please write me the snippet how can sms can be sent using socket connection. Write only that much code which opens socket connection and writes a message on the particular mobile phone or at smsc
Michael Yuan
author
Ranch Hand

Joined: Mar 07, 2002
Posts: 1427
You need to put the SDK jar files in your classpath when you compile that sample app.
Gurpreet Saini
Ranch Hand

Joined: Jun 09, 2002
Posts: 295
I had not only placed jar file but I had extracted all the files from it. Jar file do contain the SMS class but the instance methods called on SMS object gives the error. The file is there, path is O.K but still errors. It says it cannot resolve the methods. That means either those methods are not there in SMS class or the byte code is corrupted.
The main problem is there is no source code for sending sms text. If it would have been there I must have compiled as well as rectified the errors. As far as i remember there is utility in javac which can create source code from a class file but still it only mentions properties and flags of the class attributes and not the methods.
The one thing I dont understand is if I open an socket connection then how I will send text as well as phone number on that socket connection. Please write a short snippet for that.
thank you
Gurpreet Saini
Ranch Hand

Joined: Jun 09, 2002
Posts: 295
Running sample code is not the problem and nor it is an issue for me. My main problem is how to use TCP/IP connection in sending sms. Could you let me know the links which explain on this issue.
thanks in advance
Michael Yuan
author
Ranch Hand

Joined: Mar 07, 2002
Posts: 1427
You do not really use TCP/IP to send SMS message directly to the phone. Instead, you use TCP/IP to send the receiving phone number and the message text to a gateway server (like the one in simplewire's data center. The server has an agreement with the wireless carrier and can hook into the wireless network. It forwards your message to the specified phone number. Both the links from the gateway to the carrier and the carrier to the phone are proprietary.
In the case of simplewire SDK, I have used it for a couple of months. I vaguely remember that you need to sign up an eval account with them in order to access their server. But I am not sure why the SMS class has problem compiling. If I were you, I'd ask their tech support.
Gurpreet Saini
Ranch Hand

Joined: Jun 09, 2002
Posts: 295
I fully understand what you are saying. But my problem is that how can I send sms to simplewire server such that it can show in my account. I already have an account with them for testing my application. I once again write tell me how to send text message to thier server such that it can show me in my account with them.
There code might run but it does not help me because i want to write the code myself. And for your information they do not have source code.
Michael Yuan
author
Ranch Hand

Joined: Mar 07, 2002
Posts: 1427
You need to ask simplewire tech support about how to use their SDK correctly. Simplewire is just one of many server side SMS SDKs out there.
Gurpreet Saini
Ranch Hand

Joined: Jun 09, 2002
Posts: 295
Hey yuan answer my easy questions
1. I want to write a code from my PC to the simplewire account. Is it possible ?.
2. If yes, then which API shall I use. Because every time when I open an socket connection from my PC I get UnsatisfiedFieldError. The API which I used was javax.microedition.io.SocketConnection.
I am completely confused over this issue. you said WMA API can be sed only on Compatible handsets. Afer that I used javax.microedition.io.SocketConnction for the same reason to send sms to simplewire but it also resulted in same error. Please help me out of this problem i am not able to get sleeps at night.
Michael Yuan
author
Ranch Hand

Joined: Mar 07, 2002
Posts: 1427
Originally posted by Gurpreet Saini:
Hey yuan answer my easy questions
1. I want to write a code from my PC to the simplewire account. Is it possible ?.
2. If yes, then which API shall I use. Because every time when I open an socket connection from my PC I get UnsatisfiedFieldError. The API which I used was javax.microedition.io.SocketConnection.
I am completely confused over this issue. you said WMA API can be sed only on Compatible handsets. Afer that I used javax.microedition.io.SocketConnction for the same reason to send sms to simplewire but it also resulted in same error. Please help me out of this problem i am not able to get sleeps at night.

1. Yes. But I cannot provide you complete examples -- I have not used their products for a while and I believe they have examples right there in their SDK. You need to ask them why you cannot get their SDK sample code to work.
2. Again, you cannot use javax.microedition package in J2SE. The API you use is propreitary to simplewire.
Email their tech support. They will be able answer those Qs much better than any of us here! It is their propreitary product!
Gurpreet Saini
Ranch Hand

Joined: Jun 09, 2002
Posts: 295
Hi there,
I had posted my questions to simplewire tech support. And i am waiting for their reply. I had downloaded WTK from java.sun.com. Can you tell me what can I do with that product. Can I virtually send SMS to any XYZ server.
thanks in advance.
Gurpreet Saini
Ranch Hand

Joined: Jun 09, 2002
Posts: 295
I wanted to ask one thing that can I use WTK to test my Midlet applications. Secondly, do WTK tested applications will be quality assured and will run on cell phone once uploaded. ?. What are Jad files ?.
Do the MIDP1.0 enabled cell phones comes with JVM ?.

[ February 13, 2004: Message edited by: Gurpreet Saini ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: ConnectionNotFoundException