Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception While connection to webserver

 
glkishore
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...

 
glkishore
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Balaji Loganathan
author and deputy
Bartender
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic