fipries
fipries

Reputation: 386

WSO2 EI Maximum lock count exceeded error when respond

We have an input sequence in WSO2 EI 6 that receives a JSON, goes through a custom mediator in java that takes the JSON and with that information sends several requests, completes the JSON and returns it as STRING to the sequence that we take as output_body. Once in the sequence it enters through a filter Origin = 1, makes a request to the SIL API with that JSON, enters a sequence that detects if it is necessary to send an email to find an error and finally we have a PAYLOAD that transforms the STRING of the JSON in a JSON and add it to the body of the output and finally we do a reply.

It is failing in the last respond with the following error:

[2021-01-13 16:48:58,070] [-1234] [] [PassThroughMessageProcessor-46] ERROR {org.wso2.carbon.integrator.core.json.JsonStreamFormatter} -  Error occurred while writing to application/json
java.lang.reflect.InvocationTargetException
    at sun.reflect.GeneratedMethodAccessor77.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.wso2.carbon.integrator.core.json.JsonStreamFormatter.writeTo(JsonStreamFormatter.java:109)
    at org.apache.synapse.transport.passthru.PassThroughHttpSender.submitResponse(PassThroughHttpSender.java:626)
    at org.apache.synapse.transport.passthru.PassThroughHttpSender.invoke(PassThroughHttpSender.java:285)
    at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
    at org.apache.synapse.core.axis2.Axis2Sender.sendBack(Axis2Sender.java:220)
    at org.apache.synapse.mediators.builtin.RespondMediator.mediate(RespondMediator.java:35)
    at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:109)
    at org.apache.synapse.mediators.filters.FilterMediator.mediate(FilterMediator.java:237)
    at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:267)
    at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.mediateFromContinuationStateStack(Axis2SynapseEnvironment.java:805)
    at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:303)
    at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:578)
    at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:195)
    at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
    at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:265)
    at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.Error: Maximum lock count exceeded
    at java.util.concurrent.locks.ReentrantLock$Sync.nonfairTryAcquire(ReentrantLock.java:141)
    at java.util.concurrent.locks.ReentrantLock$NonfairSync.tryAcquire(ReentrantLock.java:213)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1198)
    at java.util.concurrent.locks.ReentrantLock$NonfairSync.lock(ReentrantLock.java:209)
    at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:285)
    at org.apache.synapse.transport.passthru.Pipe$ByteBufferOutputStream.flushContent(Pipe.java:598)
    at org.apache.synapse.transport.passthru.Pipe$ByteBufferOutputStream.write(Pipe.java:573)
    at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1793)
    at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1769)
    at org.apache.commons.io.IOUtils.copy(IOUtils.java:1744)
    at org.apache.synapse.commons.json.JsonUtil.writeJsonStream(JsonUtil.java:955)
    at org.apache.synapse.commons.json.JsonUtil.writeAsJson(JsonUtil.java:273)
    at org.apache.synapse.commons.json.JsonStreamFormatter.writeTo(JsonStreamFormatter.java:70)
    ... 22 more

Any help? May I need to "close" something in my custom mediator o increase any WSO2 parameter to support this?

Cheers

Upvotes: 1

Views: 567

Answers (1)

Aprendiendo Siempre
Aprendiendo Siempre

Reputation: 363

We have also had this problem and we have solved it in the following way:

Apparently we got a response from the backend 200 OK without json body, this seemed to make the ESB fail when we tried to give a final response 200 OK with a json body perhaps due to some header that caused the error.

Finally we asked the backend to change the 200 OK to 204 No Content and everything started working

Upvotes: 1

Related Questions