BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 09-02-2008, 04:55 AM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Aug 2008
Location: Scotland
Model: None!
PIN: N/A
Carrier: Vodafone
Posts: 31
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default J2ME error??

Please Login to Remove!

Hi,

I'm a .NET developer by trade so still getting my head round this Java stuff.

I'm calling a WebService using KSoap2. I got a demo working just using standard Java app using the ksoap2-j2se-full-2.1.2.jar. I could not get this jar file to verify so i tried using the ksoap2-j2me-core-2.1.2.jar as I verify this.

Now when I add it to the project I get the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: javax/microedition/io/Connector
at org.ksoap2.transport.ServiceConnectionMidp.<init>( Unknown Source)
at org.ksoap2.transport.HttpTransport.getServiceConne ction(Unknown Source)
at org.ksoap2.transport.HttpTransport.call(Unknown Source)
at FirstClass.GetResult(FirstClass.java:50)
at FirstClass.main(FirstClass.java:22)
Caused by: java.lang.ClassNotFoundException: javax.microedition.io.Connector
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 5 more

Is this to do with me not using J2ME??? If so is this part of the J2SE? Or am I missing something more obvious?

My code is as follows: (i've added ** as i can't post links)

public static String GetResult()
{
String result = "";

SoapObject soap = new SoapObject("**localhost/BBWebservice", "HelloWorld");

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(soap);

/*With J2SE version would use the following line which worked
*HttpTransportSE ht = new HttpTransportSE("**localhost/BBWebservice/service.asmx"); */
HttpTransport ht = new HttpTransport("**localhost/BBWebservice/service.asmx");
ht.debug = true;

try{
System.out.println("CALLING WEBSERVICE");
ht.call("**localhost/BBWebservice/HelloWorld", envelope);

System.out.println("GETTING RESPONSE");
result = (envelope.getResponse()).toString();
}
catch(Exception ex){
System.out.println("ERROR: "+ ex.toString());
}
finally
{
System.out.println("Finished");
}

return result;
}
Offline  
Old 09-02-2008, 05:20 AM   #2 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Jan 2008
Location: France
Model: 8310
PIN: N/A
Carrier: Vodafone
Posts: 217
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi the problem come from the ksoap you use.

It's the full for J2SE

Or blackberry is on J2ME.

SourceForge.net: Files

and take the ksoap2-j2me-core-2.1.2.jar and don't forget to preverify it

preverify -classpath "C:\Program Files\Research In Motion\BlackBerry JDE 4.3.0\lib\net_rim_api.jar" Path_where_the_jar_is_located\ksoap2-j2me-core-2.1.2.jar

And recover the jar in the output folder located in C:\Program Files\Research In Motion\BlackBerry JDE 4.3.0\bin.

With this all should be ok

Last edited by goulamass : 09-02-2008 at 05:22 AM.
Offline  
Old 09-02-2008, 05:53 AM   #3 (permalink)
Knows Where the Search Button Is
 
Join Date: Aug 2008
Location: Scotland
Model: None!
PIN: N/A
Carrier: Vodafone
Posts: 31
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Thanks for the reply. I am using the preverified ksoap2-j2me-core-2.1.2.jar file. Do you think the problem could be that i am using it within Eclipse J2SE? Would i need to download eclipse J2ME??
Offline  
Old 09-02-2008, 06:03 AM   #4 (permalink)
Thumbs Must Hurt
 
baran_khan's Avatar
 
Join Date: Apr 2008
Model: 9500
PIN: N/A
Carrier: Airtel
Posts: 110
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by FerminRomeroDeTorres View Post
Hi,

Thanks for the reply. I am using the preverified ksoap2-j2me-core-2.1.2.jar file. Do you think the problem could be that i am using it within Eclipse J2SE? Would i need to download eclipse J2ME??
why dont you use eclipse 3.3.1 with blackberry plugin...that will sort out hell of ur issues...
__________________
Smart People ask for Help!!!
Offline  
Old 09-02-2008, 06:06 AM   #5 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Jan 2008
Location: France
Model: 8310
PIN: N/A
Carrier: Vodafone
Posts: 217
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes because in fact eclipse is in J2SE and so can't use the J2ME package.

Take the BlackBerry Plugging as baran_khan said
Offline  
Old 09-02-2008, 06:19 AM   #6 (permalink)
Knows Where the Search Button Is
 
Join Date: Aug 2008
Location: Scotland
Model: None!
PIN: N/A
Carrier: Vodafone
Posts: 31
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm already using the Blackberry plugin for eclipse and i'm still getting the error. So if i can't use J2ME package with J2SE then the ksoap2-j2me-core-2.1.2.jar won't work? In that case i will have to use the ksoap2-j2se-full-2.1.2.jar? I can't get this to verify... so frustrating!
Offline  
Old 09-02-2008, 06:23 AM   #7 (permalink)
Thumbs Must Hurt
 
baran_khan's Avatar
 
Join Date: Apr 2008
Model: 9500
PIN: N/A
Carrier: Airtel
Posts: 110
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

I just saw your code, are you using "localhost" in the web service address?

Cause if it is so, the blackberry consider it as its local resource within the device and will never look outside...SO put the IP address instead of that localhost term.

Secondly, you have to have core version of ksoap2, you can't preverify any other version...
__________________
Smart People ask for Help!!!
Offline  
Old 09-02-2008, 06:29 AM   #8 (permalink)
Thumbs Must Hurt
 
baran_khan's Avatar
 
Join Date: Apr 2008
Model: 9500
PIN: N/A
Carrier: Airtel
Posts: 110
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by FerminRomeroDeTorres View Post
I'm already using the Blackberry plugin for eclipse and i'm still getting the error. So if i can't use J2ME package with J2SE then the ksoap2-j2me-core-2.1.2.jar won't work? In that case i will have to use the ksoap2-j2se-full-2.1.2.jar? I can't get this to verify... so frustrating!
I guess you are trying to run your code on two different environments simultaneously, dont waste your time on that...you'll have to have two different setups for these two...The possible reason you are getting this issue is because you are executing the code on J2ME environment while the resources required are of RIM.
__________________
Smart People ask for Help!!!
Offline  
Old 09-02-2008, 06:46 AM   #9 (permalink)
Knows Where the Search Button Is
 
Join Date: Aug 2008
Location: Scotland
Model: None!
PIN: N/A
Carrier: Vodafone
Posts: 31
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by baran_khan View Post
I guess you are trying to run your code on two different environments simultaneously, dont waste your time on that...you'll have to have two different setups for these two...The possible reason you are getting this issue is because you are executing the code on J2ME environment while the resources required are of RIM.
Hi Baran_khan,

MAybe i'm not explainin it correctly as i'm not a java developer, i'm .net and webdeveloper normally. I have downloaded and installed the blackberry plugin for Eclipse and created a blackberry project where i develop all of the applications for a blackberry. I have a library project with the preverified core ksoap2 jar inside and added this as a reference for the project containing the actual code... i was trying to work out if the j2me was an issue as my understanding of the underlying technologies in Java is not so thorough. I will try your comment about using ip address rather than localhost and hopefully get somewhere with that.
Offline  
Old 09-03-2008, 02:37 AM   #10 (permalink)
Knows Where the Search Button Is
 
Join Date: Aug 2008
Location: Scotland
Model: None!
PIN: N/A
Carrier: Vodafone
Posts: 31
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've tried using the ip address instead of the localhost and i'm still getting nothing. I'm confused about the ME/SE/RIM thing. Any recommended reading to catch up?
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.