WSO2 does not catching exception from Smooks - wso2

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..?

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.

Related

WSO2 EI 6.4 and error Caused by: org.apache.ws.security.WSSecurityException

Using WSO2 EI 6.4.0 to send a SOAP message with wsp:Policy wsu:Id="SigOnly" works fine when the HTTP response code is 200. The signature is well checked and message flow can continue.
When the response is a SOAP fault with the response code 500, the initiating request sent to EI keeps hanging. The Send mediator doesn't receive any exception so I cannot handle it (what I would like to report it to the caller) in the sequence flow, even in a faultSequence. I just get this error in my logs: Caused by: org.apache.ws.security.WSSecurityException: The signature or decryption was invalid.
I really don't understand why - in this fault situation - the signature or decryption could be invalid while it is valid with non faulty SOAP responses. I don't see differences between the soap headers structure (fault vs. non-fault), it seems to me only the body is different:
<soapenv:Body wsu:Id="id-1-2b51dae55e169f7625472a2369df8671" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<soapenv:Fault>
<faultcode>soapenv:Client</faultcode>
<faultstring>Message bcd45e75-b778-4fe1-83fb-ea97e4015sss failed : VALI-0100 - Validation of request message failed : org.xml.sax.SAXParseException; cvc-enumeration-valid: Value 'Q1andQ2' is not facet-valid with respect to enumeration '[Q1, Q2, Q1+Q2, SO]'. It must be a value from the enumeration., org.xml.sax.SAXParseException; cvc-type.3.1.3: The value 'Q1andQ2' of element 'v21:codeQ' is not valid.
</faultstring>
<faultactor>
...
And the full exception:
[2021-02-09 17:37:01,216] [EI-Core] ERROR - AxisEngine The signature or decryption was invalid org.apache.axis2.AxisFault: The signature or decryption was invalid
at org.apache.rampart.handler.RampartReceiver.setFaultCodeAndThrowAxisFault(RampartReceiver.java:194)
at org.apache.rampart.handler.RampartReceiver.invoke(RampartReceiver.java:96)
at org.apache.axis2.engine.Phase.invokeHandler(Phase.java:340)
at org.apache.axis2.engine.Phase.invoke(Phase.java:313)
at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:261)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:167)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:263)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748) Caused by: org.apache.ws.security.WSSecurityException: The signature or decryption was invalid
at org.apache.ws.security.processor.SignatureProcessor.verifyXMLSignature(SignatureProcessor.java:703)
at org.apache.ws.security.processor.SignatureProcessor.handleToken(SignatureProcessor.java:124)
at org.apache.ws.security.WSSecurityEngine.processSecurityHeader(WSSecurityEngine.java:332)
at org.apache.ws.security.WSSecurityEngine.processSecurityHeader(WSSecurityEngine.java:249)
at org.apache.rampart.RampartEngine.process(RampartEngine.java:221)
at org.apache.rampart.handler.RampartReceiver.invoke(RampartReceiver.java:93)
... 9 more
[2021-02-09 17:37:01,220] [EI-Core] ERROR - ClientWorker Fault processing response message through Axis2 org.apache.axis2.AxisFault: The signature or decryption was invalid
at org.apache.rampart.handler.RampartReceiver.setFaultCodeAndThrowAxisFault(RampartReceiver.java:194)
at org.apache.rampart.handler.RampartReceiver.invoke(RampartReceiver.java:96)
at org.apache.axis2.engine.Phase.invokeHandler(Phase.java:340)
at org.apache.axis2.engine.Phase.invoke(Phase.java:313)
at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:261)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:167)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:263)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.ws.security.WSSecurityException: The signature or decryption was invalid
Any help should be appreciated to tell me what am I to do to be able to get the fault reported up to the mediator level so I could manage the flow.
This issue seems to be a bug in WSO2 EI 6.4.0. Please refer to issue #4155 for more details

WSO2 ESB DataMapper mediator

I'm getting the below error when trying to transform a JSON input to another JSON format using WSO2 ESB DataMapper mediator.
Here, I'm trying to do a very basic level transformation & appreciate if someone could help me to figure out the issue.
[2016-12-22 10:20:15,674] ERROR - ResvsAPI DataMapper mediator : mapping failed
Error while reading input stream. Script engine unable to execute the script javax.script.ScriptException: ReferenceError: "map_S_root_S_root" is not defined in <eval> at line number 1
at org.wso2.carbon.mediator.datamapper.engine.input.readers.JSONInputReader.read(JSONInputReader.java:62)
at org.wso2.carbon.mediator.datamapper.engine.input.InputBuilder.buildInputModel(InputBuilder.java:59)
at org.wso2.carbon.mediator.datamapper.engine.core.mapper.MappingHandler.doMap(MappingHandler.java:67)
at org.wso2.carbon.mediator.datamapper.DataMapperMediator.transform(DataMapperMediator.java:306)
at org.wso2.carbon.mediator.datamapper.DataMapperMediator.mediate(DataMapperMediator.java:256)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:97)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:59)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)
at org.apache.synapse.rest.Resource.process(Resource.java:343)
at org.apache.synapse.rest.API.process(API.java:399)
at org.apache.synapse.rest.RESTRequestHandler.apiProcess(RESTRequestHandler.java:123)
at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:101)
at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:69)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:304)
at org.apache.synapse.core.axis2.SynapseMessageReceiver.receive(SynapseMessageReceiver.java:75)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:325)
at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:371)
at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:151)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
This can be due to an error in the input-output mapping configuration. Can you please provide a screenshot of the mapping UI view and the contents of the mapping configuration file (.dmc file)
*You can find the mapping configuration inside Registry viewer tab in WSO2 ESB Management Console.

How to handle one-way (in-only) soap messages

I've created a proxy service in the ESB that is calling in-only soap operations. (So only an input message). The backend soap service responds with a HTTP 202/Accepted response with no content in the response. As far as I know, this is correct behavior for in-only operations.
When I call the the service via the ESB proxy service I keep getting errors in the logs:
java.lang.UnsupportedOperationException: Not yet implemented
at org.apache.axis2.description.OutOnlyAxisOperation.getMessage(OutOnlyAxisOperation.java:124)
at org.wso2.carbon.core.multitenancy.MultitenantMessageReceiver.processResponse(MultitenantMessageReceiver.java:125)
at org.wso2.carbon.core.multitenancy.MultitenantMessageReceiver.receive(MultitenantMessageReceiver.java:81)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:225)
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:745)
I've tried setting the OUT_ONLY property, FORCE_SC_ACCEPTED but the error persists. It seems that the ESB soap sender is not able to handle this scenario correctly.
Any idea how to handle this? I'm not able to change anything about the backend service.

BAM mediator not working with WSO2ESB

I have installed the latest version of WSO2 BAM (2.4.1) and WSO2 ESB (4.8.1). The BAM Mediator in the ESB is not working. It keeps throwing the below exception everytime it tries to send a message to BAM.
Can you please help?
[2014-09-15 05:54:58,833] ERROR - AsyncDataPublisher Error occurred while finding | defining the event org.wso2.carbon.databridge.agent.thrift.exception.AgentException: Cannot define type {"streamId":"TestStream:1.0.0","name":"TestsStream","version":"1.0.0","nickName":"TestStream","description":"TestStream","metaData":[{"name":"tenant_id","type":"INT"},{"name":"http_method","type":"STRING"},{"name":"character_set_encoding","type":"STRING"},{"name":"remote_address","type":"STRING"},{"name":"transport_in_url","type":"STRING"},{"name":"message_type","type":"STRING"},{"name":"remote_host","type":"STRING"},{"name":"service_prefix","type":"STRING"},{"name":"host","type":"STRING"}],"correlationData":[{"name":"activity_id","type":"STRING"}],"payloadData":
[{"name":"message_direction","type":"STRING"},{"name":"service_name","type":"STRING"},{"name":"operation_name","type":"STRING"},{"name":"message_id","type":"STRING"},{"name":"timestamp","type":"LONG"}]}
at org.wso2.carbon.databridge.agent.thrift.internal.publisher.client.EventPublisher.defineStream(EventPublisher.java:234)
at org.wso2.carbon.databridge.agent.thrift.DataPublisher.defineStream(DataPublisher.java:295)
at org.wso2.carbon.databridge.agent.thrift.AsyncDataPublisher$DataPublishWorker.run(AsyncDataPublisher.java:690)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
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:745)
Caused by: org.wso2.carbon.databridge.agent.thrift.exception.EventPublisherException: TException
at org.wso2.carbon.databridge.agent.thrift.internal.publisher.client.ThriftEventPublisher.defineStream(ThriftEventPublisher.java:120)
at org.wso2.carbon.databridge.agent.thrift.internal.publisher.client.EventPublisher.defineStream(EventPublisher.java:222)
... 7 more
Caused by: org.apache.thrift.transport.TTransportException
at org.apache.thrift.transport.TIOStreamTransport.read(TIOStreamTransport.java:132)
at org.apache.thrift.transport.TTransport.readAll(TTransport.java:84)
at org.apache.thrift.protocol.TBinaryProtocol.readStringBody(TBinaryProtocol.java:354)
at org.apache.thrift.protocol.TBinaryProtocol.readMessageBegin(TBinaryProtocol.java:215)
at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:69)
at org.wso2.carbon.databridge.commons.thrift.service.general.ThriftEventTransmissionService$Client.recv_defineStream(ThriftEventTransmissionService.java:80)
at org.wso2.carbon.databridge.commons.thrift.service.general.ThriftEventTransmissionService$Client.defineStream(ThriftEventTransmissionService.java:66)
at org.wso2.carbon.databridge.agent.thrift.internal.publisher.client.ThriftEventPublisher.defineStream(ThriftEventPublisher.java:109)
... 8 more
Thank you !
-Sarf.
Can you specify how you created the BAM server profile? If i'm not mistaken you can not specify metadata, correlation data and payload data in the BAM mediator stream.
Please refer https://docs.wso2.com/display/BAM241/Setting+up+BAM+Mediator

wso2 getting org.apache.rampart.RampartException: Unsupported SignedSupportingToken

We are trying to do a poc in wso2 esb to invoke our BE service which is ws-security enabled. We have setup a pass thru proxy in wso2 and configured the endpoint according to www.soasecurity.org. However, we keep getting the below error when trying to use the pass thru proxy. Please advise if we are doing anything wrong...
ERROR - Axis2Sender Unexpected error during sending message out
rg.apache.axis2.AxisFault: Unsupported SignedSupportingToken : "{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}IssuedToken"
at org.apache.rampart.handler.RampartSender.invoke(RampartSender.java:76)
at org.apache.axis2.engine.Phase.invokeHandler(Phase.java:340)
at org.apache.axis2.engine.Phase.invoke(Phase.java:313)
at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:261)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:426)
at org.apache.synapse.core.axis2.DynamicAxisOperation$DynamicOperationClient.send(DynamicAxisOperation.java:185)
at org.apache.synapse.core.axis2.DynamicAxisOperation$DynamicOperationClient.executeImpl(DynamicAxisOperation.java:167)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)
at org.apache.synapse.core.axis2.Axis2FlexibleMEPClient.send(Axis2FlexibleMEPClient.java:481)
at org.apache.synapse.core.axis2.Axis2Sender.sendOn(Axis2Sender.java:57)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:342)
at org.apache.synapse.endpoints.AbstractEndpoint.send(AbstractEndpoint.java:329)
at org.apache.synapse.endpoints.AddressEndpoint.send(AddressEndpoint.java:59)
at org.apache.synapse.core.axis2.ProxyServiceMessageReceiver.receive(ProxyServiceMessageReceiver.java:173)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:404)
at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:184)
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:724)
Caused by: org.apache.rampart.RampartException: Unsupported SignedSupportingToken : "{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}IssuedToken"
at org.apache.rampart.builder.TransportBindingBuilder.build(TransportBindingBuilder.java:103)
at org.apache.rampart.MessageBuilder.build(MessageBuilder.java:140)
at org.apache.rampart.handler.RampartSender.invoke(RampartSender.java:65)
... 20 more
What is the security policy you are using to secure the BE service?
Seems like the ESB cannot understand the security policy that is being used for the BE service.
Follow the blog and you will be able to resolve your concern.
Manisha