aspose file tools*
The moose likes Java Micro Edition and the fly likes Exception While connection to webserver Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Exception While connection to webserver" Watch "Exception While connection to webserver" New topic
Author

Exception While connection to webserver

glkishore
Greenhorn

Joined: Jul 09, 2001
Posts: 9
hai,
i am calling a servlet from my MIDlet. it is working fine, but when i click submit first it is giving the following Error:
Exception: java/lang/ClassNotFoundException
com/sun/midp/io/InternalConnector.openPrim (static) IP = 102
com/sun/midp/io/InternalConnector.openInternal (static) IP = 9
com/sun/midp/io/j2me/http/Protocol.connect (virtual) IP = 92
com/sun/midp/io/j2me/http/Protocol$PrivateOutputStream.flush (virtual) IP = 17
java/io/DataOutputStream.flush (virtual) IP = 7
SecondMidletServlet.invokeServlet (virtual) IP = 163
SecondMidletServlet.commandAction (virtual) IP = 66
javax/microedition/lcdui/Display$DisplayAccessor.commandAction (virtual) IP = 99
com/sun/kvem/midp/lcdui/EmulEventHandler$EventLoop.run (virtual) IP = 430
i couldn't trace, why it is comming, even though it is not giveing any problem, i want to get rid of this. any once can help me how can solve this problem.
Thanks
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
Hi Can u tell me what webserver and j2me sdk u r using..because i used j2me wireless toolkit with weblogic server 6.0,its working fine for me on all cases while calling a servlet from the midlet.
Also..quote some snippets of ur code callin a servlet,and code reading ur servlet datas...



Spritle Software Blogs
glkishore
Greenhorn

Joined: Jul 09, 2001
Posts: 9
hi,
i am using JWS, here is my servlet calling code:
void getData(String url) throws IOException {
HttpConnection c = null;
InputStream is = null;
StringBuffer b = new StringBuffer();
TextBox t = null;
try {
c = (HttpConnection)Connector.open(url);
c.setRequestMethod(HttpConnection.GET);
c.setRequestProperty("IF-Modified-Since","20 Jan 2001 16:19:14 GMT");
c.setRequestProperty("User-Agent","Profile/MIDP-1.0 Configuration/CLDC-1.0");
c.setRequestProperty("Content-Language", "en-CA");
is = c.openDataInputStream();
int ch;
// receive response and display it in a textbox.
while ((ch = is.read()) != -1) {
b.append((char) ch);
}

} finally {
if(is!= null) { is.close(); }
if(c != null) { c.close(); }
}
t = new TextBox("First Servlet", b.toString(), 1024, 0);
display.setCurrent(t);
}
------------------
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
Your name "glkishore" does not comply with the JavaRanch naming policy. Please spare a moment and re-register with a name that meets the requirements. Note that without an acceptable name, you will not qualify for the Javaranch giveaways.
Thanks!

Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
Hi...
I assume that u r using J2ME toolkit wiht JWS.Basically I tried the communication between MIDP with Servlet using the tutorial http://developer.java.sun.com/developer/products/wireless/midp/articles/servlets/ provided by Ousay Mahmoud.
I used JSWDK1.0.1 with J2ME Toolkit and also Web logic server6.0 for some purpose..

I suggest you to try the program in that tutorial..if the error comes again then i guess the error with the JWS only...
Originally posted by glkishore:
hi,
i am using JWS, here is my servlet calling code:
void getData(String url) throws IOException {
HttpConnection c = null;
InputStream is = null;
--------------

chanoch wiggers
Author
Ranch Hand

Joined: May 24, 2001
Posts: 245
try commenting out your code as I have done below and tell me if the error is still arriving. It looks like either the openPrim method can't find the class to instantiate (the datainputstream its going on about) or the logic by which you are calling the servlet is not quite right.
If it cant find the class to instantiate...
it might be that the implementation class is not set for some reason

void getData(String url) throws IOException {
HttpConnection c = null;
InputStream is = null;
StringBuffer b = new StringBuffer();
TextBox t = null;
try {
c = (HttpConnection)Connector.open(url);
c.setRequestMethod(HttpConnection.GET);
c.setRequestProperty("IF-Modified-Since","20 Jan 2001 16:19:14 GMT");
c.setRequestProperty("User-Agent","Profile/MIDP-1.0 Configuration/CLDC-1.0");
c.setRequestProperty("Content-Language", "en-CA");
/* is = c.openDataInputStream();
int ch;
// receive response and display it in a textbox.
while ((ch = is.read()) != -1) {
b.append((char) ch);
}
*/
} finally {
if(is!= null) { is.close(); }
if(c != null) { c.close(); }
}
//t = new TextBox("First Servlet", b.toString(), 1024, 0);
display.setCurrent(t);
}
[/B]

chanoch<p><a href="http://www.amazon.com/exec/obidos/ASIN/1861007736/" target="_blank" rel="nofollow">Author of Professional Apache Tomcat</a></p>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception While connection to webserver
 
Similar Threads
Using J2ME APIs in J2SE, or vice versa?
HTTPS COnnection from Motorola i730
how to transfer data from mobile to servlet
Exception at run time ....HTTP/1.1 400 Bad Request
Exception at run time ....HTTP/1.1 400 Bad Request