Skip to main content

Error in J2ME application While running from ant Using OTA (Over the Air)

8 replies [Last post]
wasif
Offline
Joined: 2008-04-22
Points: 0

Hello all,

I have made a J2ME application, while running from ant the application works fine if there is no push registry included, and not run using OTA,. But when i put some PushRegistry Machanism in it it does not behave normal like on closing it shuts down and never comes up again, but when i run it from Wireless tool kit it works fine...

Can u suggest what is the problem when I try to run the application using ant over OTA (Over the Air). here is my code for ant and the code written in application for push Registry:

---------------------The Ant Code for running over OTA------------------------------

--------------------------//End Ant Code--------------------------------------------------

--------------------------JAVA Code from Midlet---------------------------------------

public void scheduleMidlet(long et) throws ClassNotFoundException, ConnectionNotFoundException, SecurityException, Exception{
Date alarm = new Date();
String midletClassName = this.getMidlet().getClass().getName();
System.out.println("Midletclass name: "+midletClassName);
long t = PushRegistry.registerAlarm(midletClassName, alarm.getTime() + et);
System.out.println("Pushed into Registry.... After");
System.out.println("t == "+ t);
}

-------------------------// End Midlet code------------------------------------------------

-------------------------// JAD file Contains----------------------------------------------

MIDlet-Jar-URL: Zozoc.jar
MIDlet-Jar-Size: 120316
MIDlet-Name: Zozoc
MIDlet-Vendor: Trilogy
MIDlet-Version: 1.4.6
MIDlet-1: Zozoc, /icon.png, com.zozoc.Zozoc
MicroEdition-Profile: MIDP-2.0
MicroEdition-Configuration: CLDC-1.0
MIDlet-Icon: /icon.png
MIDlet-Permissions: javax.microedition.io.PushRegistry,javax.microedition.io.Connector.http

------------------------------------------//JAD File Settings-------------------------------------------

and this what is done when i close midlet and this shouldn't happen
---------------------------------------------------------------------------------
[nb-run] Pushed into Registry.... Before
[nb-run] Midletclass name: com.zozoc.Zozoc
[nb-run] Time that is pushed in.. 1208867773171
[nb-run] t == 0
[nb-run] Pushed into Registry.... After
[nb-run] Execution completed.
----------------------------------------------------------------------------------

Please tell where am i going Wrong

Please Reply as soon as possible

Regards
Wasif Tanveer

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
terrencebarr
Offline
Joined: 2004-03-04
Points: 0

Thanks for the help Shawn! That's why we nominated you for Community Star ;-)

https://mobileandembedded.dev.java.net/champion_index.html

-- Terrence

davka417
Offline
Joined: 2008-07-03
Points: 0

does anyone know if any mobiles today support push registry using socket or datagram connections? Especially any SE mobiles?

sfitzjava
Offline
Joined: 2003-06-15
Points: 0

Phones (at least in the US) are on a NAT'ed network. So just like you can't hit a computer in a network that is NAT'ed you can't hit a phone because they don't have determinable IPs. That is other than Nextel. Nextel has an option to setup a static IP on a phone but it is a special plan that not everyone gets.

So the simple answer is no.

However if you went through thousands of hurdles, paid ton's of cash, and signed your life away to the operators to get a server inside there firewall, with access to their NAT tables for dynamic phone IP lookup then it would be possible. And we know how operators can be so helpful with this type of thing...

Best wishes.
-Shawn

sfitzjava
Offline
Joined: 2003-06-15
Points: 0

Actually your code is working correctly.
You are running this from an ant script which does not keep the application up. Once the app ends when running in Ant it will terminate. Using the WTK you are having it emulate the AMS which is what you need to allow the PushRegistry alarms trigger to work.

Now as for the "t==0" print value please check the API docs and it states that when you call the registerAlarm method the first time through it will return 0. What is being returned is the last alarm times value, not what it is being set to.

I'm not sure how to tell the emulator from the command line doing OTA to stay operational until you close the emulator, not just cause from the MIDlet exiting.

Have you tried running the MIDlet but not in OTA mode? Maybe that would work.

Regards,
-Shawn

wasif
Offline
Joined: 2008-04-22
Points: 0

Hello Shawn,

The code works fine when it is tested on the emulator using Toolkit and run through OTA, i too think that ANT is creating some problems, but i didn't find any other way of running this application on OTA using ANT, as far as the time is concerned it returns the last registered time i.e. t==0, and it updates if i try running the application on the toolkit and returns the required figure,

If i run this code without OTA it runs and shows the default message that goes like the application is trying to send and receive automatic updates from the network (Typically a message when u are trying to use Push registry)

I tried to run this midlet on my mobile i.e. SonyEriccson K510, it works and installs correctly when no push registry is implemented, but gives an error while i try to run PushRegistry functionality.....

any suggestions or recommendations?

Regards
Wasif

sfitzjava
Offline
Joined: 2003-06-15
Points: 0

What is the error?
Who is the phone's service provider, or is it unlocked?

You might want to change the Jad attribute to:
MicroEdition-Configuration: CLDC-1.1

But I doubt that will make any difference, but it may be important on the JP platform that SE uses.

-Shawn

wasif
Offline
Joined: 2008-04-22
Points: 0

The provider is Warid and the phone is Unlocked.

well the error was "Operation Failed."

That would be because of perhaps my mobile does not support PushRegistry Functionality.. that's y it gives error. otherwise it runs all other jar and apps very fine ....

i don't think that changing to CLDC 1.1 will take effect anyway.

Regards
Wasif

wasif
Offline
Joined: 2008-04-22
Points: 0

Hello Shawn,

Thanks for your co-operation, the news is that the problem of running the midlet in the mobile phone is solved, though it still didn't work on the ANT, but now its running successfully on the mobile phone, the reason was that my phone allows the PushRegistry permission but the socket permissions are not supported that's why it was saying "Operation failed"

Removing the socket permission made the application run on my mobile phone and it gives the exact required output with the above mentioned code

Regards,
Wasif