0

I have an api project in wso2 integration studio. I'm calling an api that returns 1000's of data inside. But I'm printing this result inside the script mediator. The application gives the following error. When I call the api that returns 400 data, I do not get an error.How can I fix bug?

The script engine returned an Exception executing the external js script : null function mediate java.lang.IllegalArgumentException: out of range index
Ahmet Kalem
  • 113
  • 6

1 Answers1

0

This is an inherent problem when you use the Script Mediator for large payloads. The Micro Integrator uses Rhino engine to execute JavaScripts. Rhino engine converts the script to a method inside a Java class. Therefore, when processing large data volumes, the code length must be less than 65536 characters, since the Script mediator converts the payload into a Java object. However, you can use the following alternative options to process large JSON data volumes.

  • Achieve the same functionality via a Class mediator.
  • If the original message consists of repetitive sections, you can use the Iterate mediator to generate a relatively small payload using those repetitive sections. This will then allow you to use the Script mediator.
  • The Script Mediator supports using Nashorn to execute JavaScripts, in addition to its default Rhino engine. Hence you can try using the Nashhorn engine instead of the default Rhino engine. For this, you can change the language like below.
<script language="nashornJs">
ycr
  • 12,828
  • 2
  • 25
  • 45
  • Hi thanks for asnwered. I tried to change script language as nashornJS. Bu when ı save the changes wso2 integration studio ı get error the following "No script engine found for language : nashornJS". Please Can you explain this bug how to fix ? – Ahmet Kalem Apr 14 '23 at 11:39
  • @AhmetKalem Sorry I had a typo in my answer. It has to be `nashornJs` lowercase `s`. – ycr Apr 14 '23 at 12:11