1

I am using WSO2 ESB 4.8.1 and i am using Smooks 1.5 to read a fixed length file and then parse it in raw XML. It is working fine but i have to also implement its exceptional flow.

Problem:

The problem is that if i mess up smooks config file it is throwing an exception but it is not being catched by WSO2. For all the other errors and exception WSO2 initiates the fault sequence where you can get ERROR_MESSAGE, ERROR_DETAIL properties, but in this case it just terminates the flow and the service does not goes into fault sequence. So i can't do anything about it unless service goes into fault sequence.

Sample File:

John     Lock

Smooks-config File that i am using to create an exception:

<?xml version="1.0"?>
<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
                      xmlns:fl="http://www.milyn.org/xsd/smooks/fixed-length-1.3.xsd">
  <fl:reader fields="FNAME[4],$ignore$[4],LNAME">
      </fl:reader>
</smooks-resource-list>

Exception in wso2 log file:

org.milyn.cdr.SmooksConfigurationException: Error invoking @Initialize method 'initialize' on class 'org.milyn.fixedlength.FixedLengthReader'.
    at org.milyn.cdr.annotation.Configurator.invoke(Configurator.java:457)
    at org.milyn.cdr.annotation.Configurator.initialise(Configurator.java:439)
    at org.milyn.cdr.annotation.Configurator.configure(Configurator.java:91)
    at org.milyn.cdr.annotation.Configurator.configure(Configurator.java:66)
    at org.milyn.delivery.JavaContentHandlerFactory.create(JavaContentHandlerFactory.java:63)
    at org.milyn.delivery.ContentDeliveryConfigBuilder$ContentHandlerExtractionStrategy.addCDU(ContentDeliveryConfigBuilder.java:623)
    at org.milyn.delivery.ContentDeliveryConfigBuilder$ContentHandlerExtractionStrategy.applyCDUStrategy(ContentDeliveryConfigBuilder.java:548)
    at org.milyn.delivery.ContentDeliveryConfigBuilder$ContentHandlerExtractionStrategy.applyStrategy(ContentDeliveryConfigBuilder.java:536)
    at org.milyn.delivery.ContentDeliveryConfigBuilder$SmooksResourceConfigurationTableIterator.iterate(ContentDeliveryConfigBuilder.java:711)
    at org.milyn.delivery.ContentDeliveryConfigBuilder$SmooksResourceConfigurationTableIterator.access$300(ContentDeliveryConfigBuilder.java:690)
    at org.milyn.delivery.ContentDeliveryConfigBuilder.extractContentHandlers(ContentDeliveryConfigBuilder.java:484)
    at org.milyn.delivery.ContentDeliveryConfigBuilder.load(ContentDeliveryConfigBuilder.java:349)
    at org.milyn.delivery.ContentDeliveryConfigBuilder.getConfig(ContentDeliveryConfigBuilder.java:146)
    at org.milyn.container.standalone.StandaloneExecutionContext.<init>(StandaloneExecutionContext.java:91)
    at org.milyn.container.standalone.StandaloneExecutionContext.<init>(StandaloneExecutionContext.java:65)
    at org.milyn.Smooks.createExecutionContext(Smooks.java:411)
    at org.milyn.Smooks.createExecutionContext(Smooks.java:374)
    at org.wso2.carbon.mediator.transform.SmooksMediator.mediate(SmooksMediator.java:103)
    at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)
    at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47)
    at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:131)
    at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:196)
    at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)
    at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47)
    at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:131)
    at org.apache.synapse.core.axis2.ProxyServiceMessageReceiver.receive(ProxyServiceMessageReceiver.java:166)
    at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
    at org.apache.axis2.transport.base.AbstractTransportListener.handleIncomingMessage(AbstractTransportListener.java:328)
    at org.apache.synapse.transport.vfs.VFSTransportListener.processFile(VFSTransportListener.java:597)
    at org.apache.synapse.transport.vfs.VFSTransportListener.scanFileOrDirectory(VFSTransportListener.java:328)
    at org.apache.synapse.transport.vfs.VFSTransportListener.poll(VFSTransportListener.java:158)
    at org.apache.synapse.transport.vfs.VFSTransportListener.poll(VFSTransportListener.java:107)
    at org.apache.axis2.transport.base.AbstractPollingTransportListener$1$1.run(AbstractPollingTransportListener.java:67)
    at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
    at java.lang.String.substring(String.java:1911)
    at org.milyn.fixedlength.FixedLengthReader.buildFields(FixedLengthReader.java:455)
    at org.milyn.fixedlength.FixedLengthReader.initialize(FixedLengthReader.java:277)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.milyn.cdr.annotation.Configurator.invoke(Configurator.java:453)

Note: Smooks is giving the correct exception but what i don't understand is that why does not WSO2 esb service goes into fault sequence and just terminated ...? Is it some behavior by smooks..?

Community
  • 1
  • 1
omer khalid
  • 855
  • 1
  • 12
  • 39

1 Answers1

0

I think it is expected behavior of WSO2 ESB. Recently, we were working on project where we used smooks to convert fixed length data to XML in WSO2 ESB using VFS transport. we have faced same kind of issue. After contacting with WSO2 Official support, we found that it is expected behavior of WSO2 ESB. Fault sequence will be only execute, when synapse exception occurs.

Waqas Ali Razzaq
  • 659
  • 1
  • 5
  • 30
  • 1
    yeah as far i have researched on it, i think it is the default behaviour of WSO2 or some kind of bug. – omer khalid Dec 26 '14 at 09:37
  • Strange but true. Only SynapseException fires fault sequence, so it's necessary to catch original exception, wrap it and re-throw. – user3714601 Dec 27 '14 at 13:08
  • @user3714601 is there any way to catch the exception...? – Umair Khalid Dec 28 '14 at 16:07
  • As I wrote, only to catch the original one and throw it wrapped into SynapseException. If you can't catch it, the only option I see is to change org.apache.synapse.core.axis2.ProxyServiceMessageReceiver class from synapse_core package. – user3714601 Dec 30 '14 at 08:10