MIDP network connections on Palm Vx - Please Help!

Hi,

I have successfully got a MIDlet compiled, preverified, installed and downloaded to my Palm (OS4.1), but when I run my application I get an IllegalArgumentException whenever I do anything that might open a network connection.

I am positive I have followed the examples, particularly HttpView, to the letter but still no success. I am also pretty sure I have the network connectivity on the Palm set up correctly.

This (part) exception happens with socket: urls.

Exception in MIDlet's CommandAction method

java.lang.IllegalArgumentException

at com.sun.cldc.io.j2me.socket.Protocol.openPrim(+7)

at com.sun.midp.io.InternalConnector.openPrim(+308)

at com.sun.midp.io.InternalConnector.open(+6)

at javax.microedition.io.Connector.open(+6)

And this similar one with http: urls...

java.lang.IllegalArgumentException

at com.sun.cldc.io.j2me.http.Protocol.sendRequest(+129)

at com.sun.cldc.io.j2me.http.Protocol.openInputStream(+48)

I get the same failure when running the emulator.

Any help or suggestions will be gratefully appreciated.

TIA.

[1150 byte] By [marklee] at [2007-9-26 16:06:45]
# 1

1. what is the line which causes the error? post the code, including the data which gets passed to the method. The argument being passed to the method is wrong, so that is the key.

2. try running it in the phone emulator - same error?

3. sockets are not supported, only HTTP, so just get HTTP working first, then see if sockets will work with your implementation of MIDP

Don

d1camero at 2007-7-2 19:24:58 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2

Here is my code...

HttpConnection connection = ( HttpConnection )Connector.open( "http://www.google.com/index.html" );

connection.setRequestProperty( "User-Agent", "Profile/MIDP-1.0 Configuration/CLDC-1.0" );

connection.setRequestProperty( "Content-Language", "en-US");

connection.setRequestProperty( "Accept" , "application/octet-stream");

connection.setRequestProperty( "Connection", "close");

// It fails here, or if I do openInputStream etc...

int responseCode = connection.getResponseCode();

I'll try the phone emulator later, I don't have access to it right now.

Thanks for trying to help.

marklee at 2007-7-2 19:24:58 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 3

[marklee],

Are you having the latest MIDP.prc installed onto your Palm Vx?

The other possible cause of the problem could be the fact that the current version of MIDP.prc (i.e. the MIDP for Palm OS 1.0 implementation) is only tested on the PalmOS v3.5.x. The error you are seeing could be the result of the imcompatibilities of the MIDP.prc and the PalmOS v4.1.

HTH.

Allen Lai

Developer Technical Support

SUN Microsystems

http://www.sun.com/developers/support/

allenlai at 2007-7-2 19:24:58 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 4
Also, in HTTP, you write first, check the reponse code, then read.Don
d1camero at 2007-7-2 19:24:58 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 5

[allenlai]

Yes I believe I am using the latest .prc as downloaded only a month or so ago from java.sun.com.

[d1camero]

Thanks. Before posting the original message I tried all combinations and sequences I could think of for reading/writing, changing when I got the input stream, when I got the output stream from the socket and so on.

Nothing made any difference unfortunately.

From the example code fragment I did post, I don't think there are any illegal arguments in there are there?

Since I can't even get the http sample to work but I can get non-Java apps to work, maybe it is as suggested a compatibility problem with OS4.1.

Thanks, both, anyway.

marklee at 2007-7-2 19:24:58 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 6

I am using an emulator and my ROM file is for palmOS 3.5. I am getting the same exception, but intermittently.

The sequence is

1. When I first start the application it might work fine

2, After certain no of runs it starts giving the exception

3. If I re install my midlet it starts working properly for a few times ... then back to step 2...

What may be the reason?

shubhrajit_c at 2007-7-2 19:24:58 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 7

Some more information, and a possible solution. I was running into the same problem as described by

shubhrajit_c . My MIDlet would work for a while making HTTP requests, but would eventually start throwing exceptions. I think it was working for a while and then stopping because the underlying network handler in MIDP and the Palm was running out of HTTP connections that could be used. My solution to this was to check and double-check to make sure that I was properly closing all input, output and httpconnection objects. Once I made all these checks then everything worked properly.

I also noticed (and I think this might be a bug in the MIDP implementation) that the input and output streams maybe closed implicitly on HTTP connections, but when you use DataInput/OutputStreams the connections are not closed (you have to close them explicitly). I encountered this situation when developing my MIDlet. My first implementation for the communication between MIDlet and server used an all text based protocol (XML message passing). I found this to be far too slow and so I decided to use the java.io.DataInputStream and java.io.DataOutputStream classes for the message passing. I initially only changed my data serialization code (from XML to dataInputStreams, which is a change from all text to binary data). I left the rest of my networking code the same (setting up the connection, handle redirects, etc.) Making the switch in data representation brought the problem to the foreground because then it was noticeable that some of the streams weren't being closed properly.

I hope this makes sense. Feel free to contact me if you would like more information.

04379501 at 2007-7-2 19:24:58 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 8

hello sir,

when i tryed executing the Demos.prc file (this file is from midp4palm\Prcfiles , is an example comes with midp4palm1.0.zip )

in that appiction one application namely google is thr . when i taped that appication my Palm is getting like a blurred data, like some dots on palm. and not opening any other like when i tap home screen .are calculator or find option .nothing iss opening.

whether is it a problem of memory.

i have some important information in the palm . how can i get the home screen. and other appications

please help

seshu

sesh_003 at 2007-7-2 19:24:58 > top of Java-index,Java Mobility Forums,Java ME Technologies...