• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ClassCastException in J2ME web service client.

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
reply
    Bookmark Topic Watch Topic
  • New Topic