Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exceptions in method declarations. JAXB

Suppose I have such exceptions hierarchy:

public class A extends RuntimeException {
...
}

public class B extends A {
...
}

In the web service interface there is a method:

public void aa() throws A;

Implementation of this method can throw either exception A or exception B, but while deploying to tomcat cxf publishes wsdl only with A exception declaration.

I have tried to use @XmlRootElement on both classes, @XmlType on both classes, @XmlRootElement on parent class, @XmlRootElement with @XmlSeeAlso on parent class, but published wsdl doesn't have B exception declaration. Also I have written a test that uses that wsdl and test gets only A exception however I've emulated both types of exceptions. How can I get child exception in wsdl declaration?

like image 241
maks Avatar asked May 18 '26 06:05

maks


1 Answers

I think you need to list both A and B as possible exceptions thrown from aa, otherwise jaxb has no means to know that you might throw exceptions of derived classes. Try:

public void aa() throws A, B;
like image 56
Attila Avatar answered May 19 '26 19:05

Attila