BlackBerry Forums Support Community

BlackBerry Forums Support Community (http://www.blackberryforums.com/)
-   Developer Forum (http://www.blackberryforums.com/developer-forum/)
-   -   J2ME error?? (http://www.blackberryforums.com/developer-forum/148068-j2me-error.html)

FerminRomeroDeTorres 09-02-2008 03:55 AM

J2ME error??
 
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;
}

goulamass 09-02-2008 04:20 AM

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

FerminRomeroDeTorres 09-02-2008 04:53 AM

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??

baran_khan 09-02-2008 05:03 AM

Quote:

Originally Posted by FerminRomeroDeTorres (Post 1084124)
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...

goulamass 09-02-2008 05:06 AM

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

Take the BlackBerry Plugging as baran_khan said

FerminRomeroDeTorres 09-02-2008 05:19 AM

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!

baran_khan 09-02-2008 05:23 AM

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...

baran_khan 09-02-2008 05:29 AM

Quote:

Originally Posted by FerminRomeroDeTorres (Post 1084135)
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.

FerminRomeroDeTorres 09-02-2008 05:46 AM

Quote:

Originally Posted by baran_khan (Post 1084143)
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.

FerminRomeroDeTorres 09-03-2008 01:37 AM

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?


All times are GMT -5. The time now is 05:39 PM.

Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.