You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by shyenuganti <sh...@gmail.com> on 2013/04/11 17:13:29 UTC

Issue with Handling SoapFault

Hi All,

I am not able to handle the soapFault properly. Here is my sample Camel code
: 

		
		onException(Exception.class).handled(true)
		   .process(new Processor(){
				public void process(Exchange exchange) throws Exception {
					System.out.println("From Generic Exception Handler");
					  
				}
			   
		});
	
		
		
	
from("quartz://JMSScheduler?cron=0/20+*+*+*+*+?").routeId("QuartzJMSTimer")
				.log("Timer says it's time to work")
				.to("direct:fromJmsQueue");
		
		from("direct:fromJmsQueue")
				.routeId(ROUTE_NAME)
				.pollEnrich(FROM_EVENTQUEUE_JMS)
				.log("Event Message read from JMS queue : ${body}")
				.unmarshal(jaxb)
				.to("bean:policyServiceSOAPRequest?method=createPolicySOAPRequest")
				.log("Policy Service Request : ${body}")
				.processRef("headerProcessor") 
				.log("Sending Request")
				.to("direct:policyServiceRequest");
		
		from("direct:policyServiceRequest")
				
				   .onException(SoapFault.class)
				   .maximumRedeliveries(0).handled(true)
				   .log("Handling SoapFault in the route ")
				   .process(new Processor(){

					@Override
					public void process(Exchange exchange) throws Exception {
						System.out.println("From SOAPFault Handler ... ");
						   SoapFault faultex = exchange.getProperty(Exchange.EXCEPTION_CAUGHT,
SoapFault.class); 
						   logger.debug(faultex.getDetail().getTextContent());
					}
					   
				   })
				   .end()
				   
				.to(POLICY_WEBSERVICE_CALL)
				.convertBodyTo(PolicyResponse.class)
				.to("stream:out");
	
			}


This is throwing me the following error : 

11:03:00,339 ERROR [QuartzEndpoint] Error processing exchange.
Exchange[Message: [Body is null]]. Caused by:
[org.quartz.JobExecutionException - org.apache.cxf.binding.soap.SoapFault:
Account information cannot be found for policy number '8691885'.]
11:03:00,339 INFO  [JobRunShell] Job DEFAULT.quartz-endpoint2 threw a
JobExecutionException: 
org.quartz.JobExecutionException: org.apache.cxf.binding.soap.SoapFault:
Account information cannot be found for policy number '8691885'. [See nested
exception: org.apache.cxf.binding.soap.SoapFault: Account information cannot
be found for policy number '8691885'.]
	at
org.apache.camel.component.quartz.QuartzEndpoint.onJobExecute(QuartzEndpoint.java:117)
	at org.apache.camel.component.quartz.CamelJob.execute(CamelJob.java:54)
	at org.quartz.core.JobRunShell.run(JobRunShell.java:216)
	at
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
Caused by: org.apache.cxf.binding.soap.SoapFault: Account information cannot
be found for  '8691885'.
	at
org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.unmarshalFault(Soap11FaultInInterceptor.java:75)
	at
org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:46)
	at
org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:35)
	at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
	at
org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:114)
	at
org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:69)
	at
org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:34)
	at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
	at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:782)
	at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1590)
	at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream$1.run(HTTPConduit.java:1121)
	at
org.apache.cxf.workqueue.AutomaticWorkQueueImpl$3.run(AutomaticWorkQueueImpl.java:426)
	at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at
org.apache.cxf.workqueue.AutomaticWorkQueueImpl$AWQThreadFactory$1.run(AutomaticWorkQueueImpl.java:351)
	at java.lang.Thread.run(Thread.java:662)


I am seeing the soapFault. But is wrapped inside a
org.quartz.JobExecutionException. Why is that so? 

My quartz job is just to invoke the next route. Are all routes that follows
the quartz component considered part of the quartz job ? In my case, what
all routes are considered part of the quartz job? How can I handle soap
Fault in my case ? 

I am not seeing any logs from the global exception as well? Am I doing
something wrong here? Please help.

Sri Harsha Y.
	



--
View this message in context: http://camel.465427.n5.nabble.com/Issue-with-Handling-SoapFault-tp5730718.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Issue with Handling SoapFault

Posted by shyenuganti <sh...@gmail.com>.
Hi Willem,

I am using a CXF end point in POJO mode. Here is my endpoint definition : 

public static final String POLICY_WEBSERVICE_CALL = 
"cxf:bean:policyClient?defaultOperationName=getAccountInformation";

This is not a producer template call. Does camel encapsulate a soapFault
from CXF end point into a CamelExecutionException?

So, the global exception handler intercepts all the endpoints. Will this
exception handler be fired first before the inroute soapFault exception
handler that I have in my route?





--
View this message in context: http://camel.465427.n5.nabble.com/Issue-with-Handling-SoapFault-tp5730718p5730774.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Issue with Handling SoapFault

Posted by Willem jiang <wi...@gmail.com>.
The first line onException will setup interceptors on all the camel endpoints, which means it will wrap all the calling.
I'm not sure what .to(POLICY_WEBSERVICE_CALL) looks like.
I don't think you are using camel-cxf component to invoke the service, maybe you are using ProduceTemplate to do that kind of work.
I think that is why the SoapFault is wrapped with in a CamelExecutionException.


--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem





On Friday, April 12, 2013 at 11:22 AM, shyenuganti wrote:

> Hi William,
>  
> My understanding of the exception propagation in Camel is as follows :  
>  
> 1. Camel invokes the inroute exception first before propagating the
> exception to the global handler.  
>  
> In this case, If my route throws a soapFault, It should be handled firs on
> the route as it is explicitly handled. The first line should be invoked for
> any other exceptions thrown apart from "SoapFault".
>  
> How does the first line effect the onexception() in the route?
>  
> I have worked on the route a bit more after this post. I used a try() ...
> catch.
>  
> .doTry()  
> .to(POLICY_WEBSERVICE_CALL)
> .doCatch(SoapFault.class)
> .process(new Processor(){
>  
> @Override
> public void process(Exchange exchange) throws Exception {
> System.out.println("From Inroute SOAPFault Handler ... ");
> SoapFault faultex = exchange.getProperty(Exchange.EXCEPTION_CAUGHT,
> SoapFault.class);  
> logger.debug(faultex.getDetail().getTextContent());
> }
>  
> })
>  
> .doCatch(Exception.class)
> .process(new Processor(){
>  
> @Override
> public void process(Exchange exchange) throws Exception {
> System.out.println("From Inroute Exception Handler ...
> "+exchange.getProperty(Exchange.EXCEPTION_CAUGHT));
> //System.out.println("Exchange properties :
> "+exchange.getProperties().toString());
>  
>  
> }
>  
> })
>  
> .end()
>  
> This one actually catches the exception. But it is not exactly a saopFault.
> But that is wrapped in a camelExecutionException. And that is caught in the
> second catch block above.  
>  
> System.out.println("From Inroute Exception Handler ...
> "+exchange.getProperty(Exchange.EXCEPTION_CAUGHT));  
>  
> is giving me this camelExecutionException. How can I extract the soapFault
> from this?
>  
> Why is dotry() ...catch() catching the exception but onexception() is not
> working if I replace at the same place in the route?
>  
>  
> I am confused how Camel handles this exception processing. Please help.
>  
> Sri Harsha Yenuganti.
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/Issue-with-Handling-SoapFault-tp5730718p5730740.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).




Re: Issue with Handling SoapFault

Posted by shyenuganti <sh...@gmail.com>.
Hi William,

My understanding of the exception propagation in Camel is as follows : 

1. Camel invokes the inroute exception first before propagating the
exception to the global handler. 

In this case, If my route throws a soapFault, It should be handled firs on
the route as it is explicitly handled. The first line should be invoked for
any other exceptions thrown apart from "SoapFault".

How does the first line effect the onexception() in the route?

I have worked on the route a bit more after this post. I used a try() ...
catch.

.doTry()   
			.to(POLICY_WEBSERVICE_CALL)
		.doCatch(SoapFault.class)
			 .process(new Processor(){
	
				@Override
				public void process(Exchange exchange) throws Exception {
					System.out.println("From Inroute SOAPFault Handler ... ");
					   SoapFault faultex = exchange.getProperty(Exchange.EXCEPTION_CAUGHT,
SoapFault.class); 
					   logger.debug(faultex.getDetail().getTextContent());
				}
				   
			   })
			   
		.doCatch(Exception.class)
		 .process(new Processor(){
	
				@Override
				public void process(Exchange exchange) throws Exception {
					System.out.println("From Inroute Exception Handler ...
"+exchange.getProperty(Exchange.EXCEPTION_CAUGHT));
					//System.out.println("Exchange properties :
"+exchange.getProperties().toString());
					
					
				}
				   
			   })
			
		.end()

This one actually catches the exception. But it is not exactly a saopFault.
But that is wrapped in a camelExecutionException. And that is caught in the
second catch block above. 

System.out.println("From Inroute Exception Handler ...
"+exchange.getProperty(Exchange.EXCEPTION_CAUGHT)); 

is giving me this camelExecutionException. How can I extract the soapFault
from this?

Why is dotry() ...catch() catching the exception but onexception() is not
working if I replace at the same place in the route?


I am confused how Camel handles this exception processing. Please help.

Sri Harsha Yenuganti.














--
View this message in context: http://camel.465427.n5.nabble.com/Issue-with-Handling-SoapFault-tp5730718p5730740.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Issue with Handling SoapFault

Posted by Willem jiang <wi...@gmail.com>.
Hi  
Can you remove the first line of onException(Exception.class)?
As you set the handled(true) it will not triage any other exception handler.


--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem





On Thursday, April 11, 2013 at 11:13 PM, shyenuganti wrote:

> Hi All,
>  
> I am not able to handle the soapFault properly. Here is my sample Camel code
> :  
>  
> onException(Exception.class).handled(true)
> .process(new Processor(){
> public void process(Exchange exchange) throws Exception {
> System.out.println("From Generic Exception Handler");
>  
> }
>  
> });
>  
>  
>  
>  
> from("quartz://JMSScheduler?cron=0/20+*+*+*+*+?").routeId("QuartzJMSTimer")
> .log("Timer says it's time to work")
> .to("direct:fromJmsQueue");
>  
> from("direct:fromJmsQueue")
> .routeId(ROUTE_NAME)
> .pollEnrich(FROM_EVENTQUEUE_JMS)
> .log("Event Message read from JMS queue : ${body}")
> .unmarshal(jaxb)
> .to("bean:policyServiceSOAPRequest?method=createPolicySOAPRequest")
> .log("Policy Service Request : ${body}")
> .processRef("headerProcessor")  
> .log("Sending Request")
> .to("direct:policyServiceRequest");
>  
> from("direct:policyServiceRequest")
>  
> .onException(SoapFault.class)
> .maximumRedeliveries(0).handled(true)
> .log("Handling SoapFault in the route ")
> .process(new Processor(){
>  
> @Override
> public void process(Exchange exchange) throws Exception {
> System.out.println("From SOAPFault Handler ... ");
> SoapFault faultex = exchange.getProperty(Exchange.EXCEPTION_CAUGHT,
> SoapFault.class);  
> logger.debug(faultex.getDetail().getTextContent());
> }
>  
> })
> .end()
>  
> .to(POLICY_WEBSERVICE_CALL)
> .convertBodyTo(PolicyResponse.class)
> .to("stream:out");
>  
> }
>  
>  
> This is throwing me the following error :  
>  
> 11:03:00,339 ERROR [QuartzEndpoint] Error processing exchange.
> Exchange[Message: [Body is null]]. Caused by:
> [org.quartz.JobExecutionException - org.apache.cxf.binding.soap.SoapFault:
> Account information cannot be found for policy number '8691885'.]
> 11:03:00,339 INFO [JobRunShell] Job DEFAULT.quartz-endpoint2 threw a
> JobExecutionException:  
> org.quartz.JobExecutionException: org.apache.cxf.binding.soap.SoapFault:
> Account information cannot be found for policy number '8691885'. [See nested
> exception: org.apache.cxf.binding.soap.SoapFault: Account information cannot
> be found for policy number '8691885'.]
> at
> org.apache.camel.component.quartz.QuartzEndpoint.onJobExecute(QuartzEndpoint.java:117)
> at org.apache.camel.component.quartz.CamelJob.execute(CamelJob.java:54)
> at org.quartz.core.JobRunShell.run(JobRunShell.java:216)
> at
> org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
> Caused by: org.apache.cxf.binding.soap.SoapFault: Account information cannot
> be found for '8691885'.
> at
> org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.unmarshalFault(Soap11FaultInInterceptor.java:75)
> at
> org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:46)
> at
> org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:35)
> at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
> at
> org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:114)
> at
> org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:69)
> at
> org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:34)
> at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
> at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:782)
> at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1590)
> at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream$1.run(HTTPConduit.java:1121)
> at
> org.apache.cxf.workqueue.AutomaticWorkQueueImpl$3.run(AutomaticWorkQueueImpl.java:426)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
> at
> org.apache.cxf.workqueue.AutomaticWorkQueueImpl$AWQThreadFactory$1.run(AutomaticWorkQueueImpl.java:351)
> at java.lang.Thread.run(Thread.java:662)
>  
>  
> I am seeing the soapFault. But is wrapped inside a
> org.quartz.JobExecutionException. Why is that so?  
>  
> My quartz job is just to invoke the next route. Are all routes that follows
> the quartz component considered part of the quartz job ? In my case, what
> all routes are considered part of the quartz job? How can I handle soap
> Fault in my case ?  
>  
> I am not seeing any logs from the global exception as well? Am I doing
> something wrong here? Please help.
>  
> Sri Harsha Y.
>  
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/Issue-with-Handling-SoapFault-tp5730718.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).