1

I have used NB to add a "client web service" to a Codename one app through the NB interface. This works fine in the simulator.

The WSDL classes are generated during build automatically and I have them landing in com.myco.myapp.generated package.

Having checked the generated JAR the WSDL classes are there all ok.

But when I push this to the "build for Android" to codename1, run on the device I get

An Internal application error occurred : java.lang.NoClassDefFoundError: com.myco.myapp.generated.SimpleStockList_Service

But the class is definitely there in the JAR.

I am sure its something to do with the JAR and its manifest, but never really had to get behind the scenes with Ant and JARs and builds to know what to do.

As the classes are generated during ant build, I can not pack them up into a library. (tried that and get fail due to 2 instances of same class.)

Linger
  • 14,942
  • 23
  • 52
  • 79
jamesarbrown
  • 243
  • 3
  • 7

2 Answers2

1

Codename One doesn't support binary libraries at this time, you will need to integrate the source code into the build process. There are many complexities involved in supporting binary libraries in such a setup.

Shai Almog
  • 51,749
  • 5
  • 35
  • 65
  • Hi Shai, There were no binaries added. I found the class being objected too was an extension of javax.xml.ws.Service, so I re-wrote the class so it was not an extension. But now it complains NoClassDef for javax.xml.ws.Service which is part of the JDK? – jamesarbrown Sep 15 '12 at 07:27
  • Yes... humm... the class is not in the stripped version of Java used. So maybe a better question is to ask, what is the best way of getting a serialized bytestream from a server to a device without opening up SQL server to the world? – jamesarbrown Sep 15 '12 at 08:09
  • Look at ConnectionRequest/NetworkManager and follow the developer guide in the website for instructions on how to do Networking/REST with Codename One. – Shai Almog Sep 15 '12 at 10:25
  • Thanks for continued support. I restarted, creating a http servlet server side and a connection on Codename1. My target is to move an object from one to the other. So nothing better to use that externalizable interface both sides...... but the codename1 jar will not run server side... complains NPE Display getPlatformName... – jamesarbrown Sep 16 '12 at 08:24
  • Yes if(!xmlVMInstanceofBugTested) { xmlVMInstanceofBug =Display.getInstance().getPlatformName().equals("ios"); xmlVMInstanceofBugTested = true; } – jamesarbrown Sep 16 '12 at 08:51
  • On the server? You need this only for the client, it will connect to the server via HTTP/servlet protocol. – Shai Almog Sep 16 '12 at 12:44
  • Hi Shai, sorry I was not clear.... was wondering how to externalize in the first place. In the end, I created a stripped version of your Externalize function and used that server side to externalise the object. Details are here http://www.jamesarbrown.com/?p=164. Maybe not the correct way, but happy for me it worked. – jamesarbrown Sep 17 '12 at 09:51
  • You need to use the JavaSE.jar and use Display.init(someAwtComponent) to get this to work. It will work headless (doesn't require AWT) once you do that but it might have a problem on google app engine. – Shai Almog Sep 17 '12 at 20:03
  • Agreed if using the codename1 Jar. But I think the stripped down jar I have created from yours, just containing the Util and externalizable class will work on pretty much anything as there is nothing but standard java.io libs used. It would be nice for Codename1 to have a server side JAR and API for moving Externalizable objects from one to the other. If you can move a generic object, you can move pretty much anything :) – jamesarbrown Sep 18 '12 at 08:40
  • True, its a good approach. We have something better planned than just a server API though. We would like to effectively seamlessly serialize webservice invocations to any protocol you would like via our cloud service. This is taking some time to implement (our plates are pretty full with tasks but we will get there)... – Shai Almog Sep 18 '12 at 12:10
  • Look forward to it. Good Luck. – jamesarbrown Sep 18 '12 at 12:58
1

Thanking Shai for his help.

Ultimate answer is not to use WSDL as moving objects relies Serialization which is not included in the small Java package.

Due to this I created a custom servlet which codename1 ConnectionRequest can deal with via a standard HTTP request.

This is how I achieved it http://www.jamesarbrown.com/?p=164

jamesarbrown
  • 243
  • 3
  • 7