File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes ClassCastException in J2ME web service client. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "ClassCastException in J2ME web service client." Watch "ClassCastException in J2ME web service client." New topic
Author

ClassCastException in J2ME web service client.

Mohammed AlRefaii
Greenhorn

Joined: Oct 03, 2009
Posts: 8
Hi every one,
I have a big problem as i see it, i create a web service with netbeans 6.7 ,deployed it to tomcat 6.0.18
then create a J2ME client to consume this service but when i call the method from the stub of the webservice i have a classCastException,
i try to call this webservice from soapUI its working well,
if the method returns an object, but when i create a webservice returns an primitive its working with J2ME client,
beside that i was working with webservice and j2me client to it before 6 month but i don't face this problem, may be its from the jax-ws version or any thing else
can any one help me please.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Could you attach a printout of the exception or tell us what class cast that fails?
By the way:
Web services does not return objects, they return data that is unmarshalled in the client and causes an object tree corresponding to the data to be created.
Marshalling and unmarshalling is usually done by JAXB (if you are using JAX-WS).
Best wishes!
Mohammed AlRefaii
Greenhorn

Joined: Oct 03, 2009
Posts: 8
Very thanks for your reply
but any class i create it on the webservice to retrieve it by the j2me client is make classCastEception and when i change
the stub which is generated automatically by netbeans to print the array of args of the class that stub make casting to them
i have nullPointerException,
Please any tip, Very thanks.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Well, how do you know it is a class cast exception? Do you have any log output of some kind?
Best wishes!
Mohammed AlRefaii
Greenhorn

Joined: Oct 03, 2009
Posts: 8
Very thanks Mr. Ivan for you interesting and quickly reply,
I run J2ME emulator which is create stub for webservice in try block
and i catch the exception then printing it and i have the following :

java.lang.ClassCastException
at testwspkg.testWSService_Stub.testClass_fromObject(testWSService_Stub.java:84)
at testwspkg.testWSService_Stub.testOP(testWSService_Stub.java:78)
at hello.HelloMIDlet$1.run(HelloMIDlet.java:115)

I can send to you the projects but i cannot upload them with the message.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
That output did not contain much help.
What kind of casting is attempted at the line where the exception occurs, that is, at line 84 in testWSService_Stub.java?
No need to send me the project, thanks - I have projects of my own to amuse myself with.
Best wishes!
Mohammed AlRefaii
Greenhorn

Joined: Oct 03, 2009
Posts: 8
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
This seems possible to solve!
In the method where the ClassCastException occurs, before anything else is done, add two print statements that print out the type of obj[0] and obj[1].
The reason for the ClassCastException is probably that these two objects are not of the type Float when the method in question is called.
Best wishes!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: ClassCastException in J2ME web service client.