Hi All,
While working with Camel i have a requirement where i need to validate an
XML with a given XSD and in case of validation faliure need to stop the
process and notify user about valdation failed
First part is working fine for the validation as i am using camel out of the
box validator
and i have declared a global Exception handler in my spring.xml file with
the following entry
<onException useOriginalMessage="true">
<exception>org.apache.camel.ValidationException</exception>
<exception>org.xml.sax.SAXParseException</exception>
<exception>org.apache.camel.processor.validation.SchemaValidationException</exception>
<exception>java.lang.Exception</exception>
<handled>
<constant>false</constant>
</handled>
<process ref="exceptionHandler"/>
to uri="file://data/failed" /
</onException>
where exceptionHandler is my custom Exceptionhandler
public class AdapterExceptionHandler implements Processor {
IAdapterManager adapterManager;
public void setAdapterManager(IAdapterManager adapterManager) {
this.adapterManager = adapterManager;
}
public void process(Exchange exchange) throws Exception {
ExceptionBean exeB = new ExceptionBean();
System.out.println(exchange.getProperty("************
"+Exchange.EXCEPTION_CAUGHT,Throwable.class));
exeB.setExceptionObj(exchange.getException());
System.out.println("Excahange
adapterManager---------"+adapterManager);
ManagerStateBean mgrStateBean = null;
if (adapterManager.getAdapterMgrState() != null) {
mgrStateBean=adapterManager.getAdapterMgrState();
}else{
mgrStateBean = new ManagerStateBean();
}
mgrStateBean.setExecutionStatus(AdapterConstants.ExceptionOccurred);
mgrStateBean.setExceptionData(exeB);
adapterManager.setAdapterMgrState(mgrStateBean);
}
But when validation getting failed camel is giving the control back to
AdapterExceptionHandler but Exchange is coming as null since when i am
trying to fetch exception object from it it is coming as null
though on the console it is showing the DefaultErrorHandler is handling the
exception but i am clueless how i can forward the exception to my
"AdapterExceptionHandler "
here is the console output
[thread #1 - file://data/input/] DefaultValidationErrorHandler DEBUG
Validation error: org.xml.sax.SAXParseException: cvc-complex-type.2.4.b: The
content of element 'record' is not complete. One of '{element}' is expected.
org.xml.sax.SAXParseException: cvc-complex-type.2.4.b: The content of
element 'record' is not complete. One of '{element}' is expected.
at
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown
Source)[:1.6.0_26]
[thread #1 - file://data/input/] DefaultErrorHandler DEBUG Failed
delivery for exchangeId: ID-snsln-045-51580-1314777491191-0-28. On delivery
attempt: 0 caught:
org.apache.camel.processor.validation.SchemaValidationException: Validation
failed for:
com.sun.org.apache.xerces.internal.jaxp.validation.SimpleXMLSchema@1d2b8e
errors: [org.xml.sax.SAXParseException: cvc-complex-type.2.4.b: The content
of element 'record' is not complete. One of '{element}' is expected.,
org.xml.sax.SAXParseException: cvc-complex-type.2.4.b: The content of
element 'record' is not complete. One of '{element}' is expected.,
org.xml.sax.SAXParseException: cvc-complex-type.2.4.b: The content of
element 'record' is not complete. One of '{element}' is expected.].
Exchange[null]
Excahange INNNNNNNNNNNnull
Excahange INNNNNNNNNNNCamelFailureEndpoint
Excahange INNNNNNNNNNNCamelFailureHandled
null
null
can any one help me out how can i pass the Exception to my
"AdapterExceptionHandler"
Thanks in advance
--
View this message in context:
http://camel.465427.n5.nabble.com/Error-Handling-In-Camel-tp4753284p4753284.html
Sent from the Camel - Users mailing list archive at Nabble.com.