• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

JAX-WS Custom Exceptions

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I got a javax.xml.ws.WebServiceException: java.lang.NoSuchMethodException: on the client when i throw a custom exception on the server side. It seems that the default constructor is tried to call. But why? Has anybody an idea where the problem is?




thanks
 
Stefan Gerber
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
--
 
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!
The signature of your custom fault class constructor is not good.
Please see section 3.7 of the JAX-WS 2.1 Specification, with an example in section 2.6.2.
Best wishes!
 
Stefan Gerber
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Ivan,
Thanks for your advice. There is something i don't understand. I must define the functions getErrorCode() and getUserMessage() at the CustomeException class otherwise i get a NoSuchMethodException. Why must i define the methods there? I have already defined a Bean.... and is it right that i always must define a Bean when i want to add some additional fields to a customeexception?


My faultBean looks like this:



and my Custom exception looks like this:



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!


There is something i don't understand. I must define the functions getErrorCode() and getUserMessage() at the CustomeException class otherwise i get a NoSuchMethodException. Why must i define the methods there? I have already defined a Bean.... and is it right that i always must define a Bean when i want to add some additional fields to a customeexception?


I haven't had time to investigate this closely, perhaps even look at the Metro source, so I can only guess.
My guess is that the web service stack uses Java reflection to find the instance fields or getter methods in the FaultDetailBean class and then expects the corresponding methods in the exception class.
Best wishes!
 
LOOK! OVER THERE! (yoink) your tiny ad is now my tiny ad.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic