Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JAX-WS Custom Exceptions  RSS feed

 
Stefan Gerber
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
--
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!