10 Replies Latest reply on Feb 23, 2009 7:47 AM by kconner

    Exception on sending message to a fault service, but it does

    mzeijen

      I have a service that throws a ActionProcessingFaultException when the message contains an incorrect XML payload. Before throwing the xml I set the message->fault->cause and message->fault->reason. A simple representation of the class looks like this:

      public class XmlValidator extends AbstractActionPipelineProcessor {
      
       public XmlValidator(ConfigTree configTree) {
       }
       /* (non-Javadoc)
       * @see org.jboss.soa.esb.actions.ActionPipelineProcessor#process(org.jboss.soa.esb.message.Message)
       */
       public Message process(Message message) throws ActionProcessingFaultException {
      
       // .. Get message payload
      
       try {
      
       validate(new StreamSource(new StringReader(xml)));
       } catch (SAXException e) {
      
       message.getFault().setCause(e);
       message.getFault().setReason("Invalid XML");
      
       throw new ActionProcessingFaultException(message, "Invalid XML");
       } catch (Exception e) {
      
       // .. More exception handling
       }
      
       return message;
       }
      
       // .. validate methods
      
      }


      The message has a valid faultTo EPR defined.

      The problem is that after the ActionProcessingFaultException exception gets thrown I see an exception in the log which tells me that the message didn't get delivered to the fault address (Stacktrace below). However the message does get delivered.

      The stacktrace I get in the log looks like this:

      13:21:50,710 ERROR [org.jboss.soa.esb.listeners.message.ActionProcessingPipeline]
       Failed to send fault to address EPR: PortReference < <wsa:Address logical:pai#fault-handler/>,
       <wsa:ReferenceProperties jbossesb:type : urn:jboss/esb/epr/type/logical/> >
       for message header: [ To: EPR: PortReference <
       <wsa:Address logical:pai#fault-handler/>, <wsa:ReferenceProperties jbossesb:type : urn:jboss/esb/epr/type/logical/> >
       From: JMSEpr [ PortReference < <wsa:Address jms://localhost:1099/queue/pai.esb.transaction_stack_validation_splitter/>,
       <wsa:ReferenceProperties jbossesb:java.naming.factory.initial : org.jnp.interfaces.NamingContextFactory/>,
       <wsa:ReferenceProperties jbossesb:java.naming.provider.url : localhost:1099/>,
       <wsa:ReferenceProperties jbossesb:java.naming.factory.url.pkgs : org.jnp.interfaces/>,
       <wsa:ReferenceProperties jbossesb:destination-type : queue/>, <wsa:ReferenceProperties jbossesb:specification-version : 1.1/>,
       <wsa:ReferenceProperties jbossesb:connection-factory : ConnectionFactory/>, <wsa:ReferenceProperties jbossesb:persistent : true/>,
       <wsa:ReferenceProperties jbossesb:acknowledge-mode : AUTO_ACKNOWLEDGE/>, <wsa:ReferenceProperties jbossesb:transacted : false/>,
       <wsa:ReferenceProperties jbossesb:type : urn:jboss/esb/epr/type/jms/> > ] RelatesTo: 1ae87d70-5ef6-4e73-a40e-64f67883d203 ]
      org.jboss.soa.esb.listeners.message.MessageDeliverException: Unexpected FaultMessageException during message delivery.
       at org.jboss.soa.esb.client.ServiceInvoker.deliverAsync(ServiceInvoker.java:254)
       at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.messageTo(ActionProcessingPipeline.java:730)
       at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.faultTo(ActionProcessingPipeline.java:690)
       at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.processPipeline(ActionProcessingPipeline.java:548)
       at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.process(ActionProcessingPipeline.java:392)
       at org.jboss.soa.esb.listeners.jca.JcaMessageAwareListener.process(JcaMessageAwareListener.java:163)
       at org.jboss.soa.esb.listeners.jca.JcaJMSInflowMessageProcessorAdapter.onMessage(JcaJMSInflowMessageProcessorAdapter.java:44)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.soa.esb.listeners.jca.BaseJcaInflow$1.invoke(BaseJcaInflow.java:205)
       at org.jboss.soa.esb.listeners.jca.EndpointProxy.delivery(EndpointProxy.java:242)
       at org.jboss.soa.esb.listeners.jca.EndpointProxy.invoke(EndpointProxy.java:145)
       at $Proxy56.onMessage(Unknown Source)
       at org.jboss.resource.adapter.jms.inflow.JmsServerSession.onMessage(JmsServerSession.java:178)
       at org.jboss.jms.client.container.ClientConsumer.callOnMessageStatic(ClientConsumer.java:160)
       at org.jboss.jms.client.container.SessionAspect.handleRun(SessionAspect.java:831)
       at org.jboss.aop.advice.org.jboss.jms.client.container.SessionAspect16.invoke(SessionAspect16.java)
       at org.jboss.jms.client.delegate.ClientSessionDelegate$run_N8003352271541955702.invokeNext(ClientSessionDelegate$run_N8003352271541955702.java)
       at org.jboss.jms.client.container.ClosedInterceptor.invoke(ClosedInterceptor.java:170)
       at org.jboss.aop.advice.PerInstanceInterceptor.invoke(PerInstanceInterceptor.java:105)
       at org.jboss.jms.client.delegate.ClientSessionDelegate$run_N8003352271541955702.invokeNext(ClientSessionDelegate$run_N8003352271541955702.java)
       at org.jboss.jms.client.delegate.ClientSessionDelegate.run(ClientSessionDelegate.java)
       at org.jboss.jms.client.JBossSession.run(JBossSession.java:199)
       at org.jboss.resource.adapter.jms.inflow.JmsServerSession.run(JmsServerSession.java:237)
       at org.jboss.resource.work.WorkWrapper.execute(WorkWrapper.java:204)
       at org.jboss.util.threadpool.BasicTaskWrapper.run(BasicTaskWrapper.java:275)
       at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:756)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: org.jboss.soa.esb.couriers.FaultMessageException: org.jboss.soa.esb.listeners.message.MessageValidationException: Message payload isn't valid xml
       at com.docmorris.esb.jbossesb.utils.action.XmlValidator.process(XmlValidator.java:119)
       at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.processPipeline(ActionProcessingPipeline.java:520)
       at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.process(ActionProcessingPipeline.java:392)
       at org.jboss.soa.esb.listeners.jca.JcaMessageAwareListener.process(JcaMessageAwareListener.java:163)
       at org.jboss.soa.esb.listeners.jca.JcaJMSInflowMessageProcessorAdapter.onMessage(JcaJMSInflowMessageProcessorAdapter.java:44)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.soa.esb.listeners.jca.BaseJcaInflow$1.invoke(BaseJcaInflow.java:205)
       at org.jboss.soa.esb.listeners.jca.EndpointProxy.delivery(EndpointProxy.java:242)
       at org.jboss.soa.esb.listeners.jca.EndpointProxy.invoke(EndpointProxy.java:145)
       at $Proxy56.onMessage(Unknown Source)
       at org.jboss.resource.adapter.jms.inflow.JmsServerSession.onMessage(JmsServerSession.java:178)
       at org.jboss.jms.client.container.ClientConsumer.callOnMessageStatic(ClientConsumer.java:160)
       at org.jboss.jms.client.container.SessionAspect.handleRun(SessionAspect.java:831)
       at org.jboss.aop.advice.org.jboss.jms.client.container.SessionAspect16.invoke(SessionAspect16.java)
       at org.jboss.jms.client.delegate.ClientSessionDelegate$run_N8003352271541955702.invokeNext
       (ClientSessionDelegate$run_N8003352271541955702.java)
       at org.jboss.jms.client.container.ClosedInterceptor.invoke(ClosedInterceptor.java:170)
       at org.jboss.aop.advice.PerInstanceInterceptor.invoke(PerInstanceInterceptor.java:105)
       at org.jboss.jms.client.delegate.ClientSessionDelegate$run_N8003352271541955702.invokeNext
       (ClientSessionDelegate$run_N8003352271541955702.java)
       at org.jboss.jms.client.delegate.ClientSessionDelegate.run(ClientSessionDelegate.java)
       at org.jboss.jms.client.JBossSession.run(JBossSession.java:199)
       at org.jboss.resource.adapter.jms.inflow.JmsServerSession.run(JmsServerSession.java:237)
       at org.jboss.resource.work.WorkWrapper.execute(WorkWrapper.java:204)
       at org.jboss.util.threadpool.BasicTaskWrapper.run(BasicTaskWrapper.java:275)
       at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:756)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element '
      image-path'. One of '{"http://www.docmorris.com/pai/transaction-1.0":id}' is expected.
       at com.sun.org.apache.xerces.internal.jaxp.validation.Util.toSAXParseException(Util.java:109)
       at com.sun.org.apache.xerces.internal.jaxp.validation.ErrorHandlerAdaptor.error(ErrorHandlerAdaptor.java:104)
       at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:382)
       at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:316)
       at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:429)
       at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3185)
       at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1831)
       at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:705)
       at com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorHandlerImpl.startElement(ValidatorHandlerImpl.java:335)
       at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
       at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
       at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
       at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
       at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
       at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
       at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
       at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
       at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
       at com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorImpl.process(ValidatorImpl.java:192)
       at com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorImpl.validate(ValidatorImpl.java:159)
       at javax.xml.validation.Validator.validate(Validator.java:82)
       at com.docmorris.esb.jbossesb.utils.action.XmlValidator.process(XmlValidator.java:117)
       ... 27 more
      
       at org.jboss.soa.esb.listeners.message.errors.Factory.createExceptionFromFault(Factory.java:50)
       at org.jboss.soa.esb.client.ServiceInvoker.post(ServiceInvoker.java:347)
       at org.jboss.soa.esb.client.ServiceInvoker.deliverAsync(ServiceInvoker.java:235)
       ... 29 more
      Caused by: org.jboss.soa.esb.listeners.message.MessageValidationException: Message payload isn't valid xml
       at com.docmorris.esb.jbossesb.utils.action.XmlValidator.process(XmlValidator.java:119)
       at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.processPipeline(ActionProcessingPipeline.java:520)
       ... 26 more
      Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with
      element 'image-path'. One of '{"http://www.docmorris.com/pai/transaction-1.0":id}' is expected.
       at com.sun.org.apache.xerces.internal.jaxp.validation.Util.toSAXParseException(Util.java:109)
       at com.sun.org.apache.xerces.internal.jaxp.validation.ErrorHandlerAdaptor.error(ErrorHandlerAdaptor.java:104)
       at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:382)
       at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:316)
       at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:429)
       at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3185)
       at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1831)
       at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:705)
       at com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorHandlerImpl.startElement(ValidatorHandlerImpl.java:335)
       at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
       at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
       at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
       at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
       at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
       at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
       at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
       at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
       at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
       at com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorImpl.process(ValidatorImpl.java:192)
       at com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorImpl.validate(ValidatorImpl.java:159)
       at javax.xml.validation.Validator.validate(Validator.java:82)
       at com.docmorris.esb.jbossesb.utils.action.XmlValidator.process(XmlValidator.java:117)
       ... 27 more


      Why does it throw that exception, even when the message was correctly delivered? Am I doing something wrong?

        • 1. Re: Exception on sending message to a fault service, but it
          marklittle

          Are you really sending back a modified version of the input message? (That's what the partial code fragment you included indicates.) If that is the case then I would strongly recommend not doing that because the header information on the incoming message will be suspect for the fault, plus there are potential security implications. Can you create a fresh message?

          • 2. Re: Exception on sending message to a fault service, but it
            mzeijen

            So I need to make a copy of the input message? Is there a safe way to do that easily?

            • 3. Re: Exception on sending message to a fault service, but it
              mzeijen

              But to be clear, I need to set the fault information on that fresh message, or not?

              • 4. Re: Exception on sending message to a fault service, but it
                marklittle

                create a new message and populate it as you see fit. I wouldn't clone the input message (you don't know what other actions may have added/modified as it's passed through the chain). Then set the header the way you need. check the docs, but basically you should set the relatesto field to be the same as the input messageid then at least your recipient can do correlation between the input message it sent and the (hopefully unexpected) fault message it's just received.

                • 5. Re: Exception on sending message to a fault service, but it
                  mzeijen

                  I tried what you said, but I am still getting the same exception.

                  Here is what I do: I create a new message, set the header information, set the content I need and finally set the fault reason and fault cause. I then create the ActionProcessingFaultException with that message and an exception message. Finally I throw that exception.

                  To find out why it logs that Exception I have been digging in to the ESB Source code (JBoss ESB 4.4.GA.CP1). I found the location where that exception gets thrown. In the ServiceInvoker on line 346 (in post method, just after the eprInvoker does an attempt to delivery the message) the reply message of the delivery is checked if it is a Fault message. Because I send an async message to a JMS queue, the reply message is the same as the message I send. That results in a FaultMessageException getting thrown. That exception is then catched by the ActionProcessingPipeline class. There it is simply logged.

                  I am not sure if that is correct behaviour for the ESB. What I do know is that it is annoying me ;). What should I do?



                  • 6. Re: Exception on sending message to a fault service, but it
                    marklittle

                    Hi. Are you suggesting that the code:


                    replyMessage = eprInvoker.attemptDelivery(message, epr);
                    if (replyMessage != null) {
                    if(eprInvoker.synchronous) {
                    // remove the security context so that it is not exposed to the action pipeline.
                    replyMessage.getContext().removeContext(SecurityService.CONTEXT);

                    if (Type.isFaultMessage(replyMessage)) {
                    Factory.createExceptionFromFault(replyMessage) ;
                    }

                    // We've delivered it, we're done!
                    return replyMessage;
                    } else {
                    // It was an async delivery. The replyMessage was just an indicator that
                    // the delivery succeeded. Return null...
                    return null;
                    }


                    is getting a non-null replyMessage and eprInvoker.synchronous is true?

                    • 7. Re: Exception on sending message to a fault service, but it
                      mzeijen

                      That doesn't look like the code I using in JBoss ESB 4.4 GA CP1. I am seeing the following code:

                      replyMessage = eprInvoker.attemptDelivery(message, epr);
                      if (replyMessage != null) {
                       // remove the security context so that it is not exposed to the action pipeline.
                       replyMessage.getContext().removeContext(SecurityService.CONTEXT);
                      
                       if (Type.isFaultMessage(replyMessage)) {
                       Factory.createExceptionFromFault(replyMessage) ;
                       }
                      
                       // We've delivered it, we're done!
                       return replyMessage;
                      } else {
                       logger.info("Unresponsive EPR: " + epr+" for message: "+message.getHeader());
                      
                       serviceClusterInfo.removeDeadEPR(epr);
                      
                       /*
                       * So far we've only removed the EPR from the cache. Should we
                       * also remove it from the registry?
                       */
                      
                       if (removeDeadEprs)
                       RegistryUtil.unregister(service.getCategory(), service.getName(), epr);
                      
                       /*
                       * If the message property is set to fail immediately, or the global property is set,
                       * then don't do retries even if there are other EPRs in the list.
                       */
                      
                       if (("true".equals(message.getProperties().getProperty(Environment.EXCEPTION_ON_DELIVERY_FAILURE, "false")) || exceptionOnDeliveryFailure))
                       throw new MessageDeliverException("Failed to deliver message ["+message.getHeader()+"] to Service [" + service + "]. Told not to retry.");
                      }


                      Am I using the wrong version of JBoss ESB?

                      • 8. Re: Exception on sending message to a fault service, but it
                        marklittle

                        Can you try the trunk? I'm not recommending you switch to it, but it's the closest thing you'll find to 4.5, which is due out in the next few weeks. Alternatively try checking out the CP branch since that's been updated recently too. I suspect we've fixed the issue you are finding, it's just the fix is not in the codebase you're using.

                        • 9. Re: Exception on sending message to a fault service, but it
                          mzeijen

                          Ok, i'll try that. Thanks.

                          At the moment it isn't a big thing, however. I can live with it.

                          • 10. Re: Exception on sending message to a fault service, but it
                            kconner

                            This has already been addressed in 4.4 CP2 and 4.5

                            https://jira.jboss.org/jira/browse/JBESB-2227