NoSuchMethodException {
Throwable exception = null;
// Get the fault from the message and get the detail blocks (probably one)
XMLFault xmlfault = message.getXMLFault();
Block[] detailBlocks = xmlfault.getDetailBlocks();
// If there is only one block, get the element name of that block.
QName elementQName = null;
if (detailBlocks != null && detailBlocks.length >= 1) {
elementQName = detailBlocks[0].getQName();
if (log.isDebugEnabled()) {
if (detailBlocks.length > 1) {
log.debug("The detail element has multiple child elements. " +
"Only the first child is examined to determine if this is a service exception. " +
"If this first detail child is mapped to a service exception, " +
"the information in other detail children may be ignored. " +
"The most common scenario is that the second child is a " +
"{http://jax-ws.dev.java.net/}exception element, which is used " +
"by some vendors for debugging. ");
}
}
}
if (log.isDebugEnabled()) {
log.debug("element QName which will be used to find a service exception = " + elementQName);
log.debug("XMLFault Dump = " +xmlfault.dump(""));
log.debug("OperationDesc Dump =" + operationDesc);
}
// Use the element name to find the matching FaultDescriptor
FaultDescription faultDesc = null;
if (elementQName != null) {
for (int i = 0; i < operationDesc.getFaultDescriptions().length && faultDesc == null;
i++) {
FaultDescription fd = operationDesc.getFaultDescriptions()[i];
FaultBeanDesc faultBeanDesc = marshalDesc.getFaultBeanDesc(fd);
if (faultBeanDesc != null) {
QName tryQName = new QName(faultBeanDesc.getFaultBeanNamespace(),
faultBeanDesc.getFaultBeanLocalName());
if (log.isErrorEnabled()) {
log.debug(" FaultDescription qname is (" + tryQName +
") and detail element qname is (" + elementQName + ")");
}
if (elementQName.equals(tryQName)) {
faultDesc = fd;
}
}
}
}
if (faultDesc == null && elementQName != null) {
// If not found, retry the search using just the local name
for (int i = 0; i < operationDesc.getFaultDescriptions().length && faultDesc == null;
i++) {
FaultDescription fd = operationDesc.getFaultDescriptions()[i];
FaultBeanDesc faultBeanDesc = marshalDesc.getFaultBeanDesc(fd);
if (faultBeanDesc != null) {
String tryName = faultBeanDesc.getFaultBeanLocalName();
if (elementQName.getLocalPart().equals(tryName)) {
faultDesc = fd;
}
}
}
}
if (faultDesc == null) {
// This is a system exception if the method does not throw a checked exception or if
// the detail block is missing or contains multiple items.
exception = createSystemException(xmlfault, message);
} else {
if (log.isErrorEnabled()) {
log.debug("Ready to demarshal service exception. The detail entry name is " +
elementQName);
}
FaultBeanDesc faultBeanDesc = marshalDesc.getFaultBeanDesc(faultDesc);
boolean isLegacy =
(faultDesc.getFaultInfo() == null || faultDesc.getFaultInfo().length() == 0);
// Get the JAXB object from the block
JAXBBlockContext blockContext = new JAXBBlockContext(marshalDesc.getPackages());
// Note that faultBean may not be a bean, it could be a primitive
Class faultBeanFormalClass;
try {
faultBeanFormalClass = loadClass(faultBeanDesc.getFaultBeanClassName());
} catch (ClassNotFoundException e){
faultBeanFormalClass = loadClass(faultBeanDesc.getFaultBeanClassName(), operationDesc.getEndpointInterfaceDescription().getEndpointDescription().getAxisService().getClassLoader());
}
// Use "by java type" marshalling if necessary
if (blockContext.getConstructionType() !=
JAXBUtils.CONSTRUCTION_TYPE.BY_CONTEXT_PATH &&
isNotJAXBRootElement(faultBeanFormalClass, marshalDesc)) {
blockContext.setProcessType(faultBeanFormalClass);
}
// Get the jaxb block and business object
Block jaxbBlock = factory.createFrom(detailBlocks[0], blockContext);
Object faultBeanObject = jaxbBlock.getBusinessObject(true);
// At this point, faultBeanObject is an object that can be rendered as an
// element. We want the object that represents the type.
if (faultBeanObject instanceof JAXBElement) {
faultBeanObject = ((JAXBElement)faultBeanObject).getValue();
}
if (log.isErrorEnabled()) {
log.debug("Unmarshalled the detail element into a JAXB object");
}
// Construct the JAX-WS generated exception that holds the faultBeanObject
Class exceptionClass;
try {
exceptionClass = loadClass(faultDesc.getExceptionClassName());
} catch (ClassNotFoundException e){
exceptionClass = loadClass(faultDesc.getExceptionClassName(), operationDesc.getEndpointInterfaceDescription().getEndpointDescription().getAxisService().getClassLoader());
}
if (log.isErrorEnabled()) {
log.debug("Found FaultDescription. The exception name is " +
exceptionClass.getName());
}
exception = createServiceException(xmlfault.getReason().getText(),
exceptionClass,
faultBeanObject,
faultBeanFormalClass,
marshalDesc,
isLegacy);