Hi
We could fix the limitation that script mediator can not handle message
payload larger than 64KB by only upgrading the rhino version to 1.7.0.R4.
But we have not upgraded script engine version to 17.
Currently ESB 5.0.0 loads script engines from apache-commons-bsf-3.0 and
java script engine is rhino 1.6. We can not remove the apache-commons-bsf-3.0
since groovy, py and rb script engine also loaded from apache-commons-bsf-3.0.
So we only upgraded the rhino to 1.7R4 and got the issue fixed.
However we tried to upgrade the java script engine by loading it from
JRE(Then engine depend on the JRE version ESB running. Rhino for java 7 and
Nashorn for java 8) and found a limitation when getting the message
payload(XML) from Scriptable object which passed to setPayloadXML
in ScriptMessageContext. That is because script engine comes from the JDK,
depends on the java internal class in rt.jar that only available at run
time and it does not depend on rhino external dependency. All the classes
loads from JDK itself. So we can not use those internal classes to get the
xlm from scriptable object like bsf converting it using a XMLHelper
class[1]. But in rhino 1.6, those dependent classes loads from external
rhino jar we provided and we can use those classes. What JDK does was
adding the same classes into different package and made them internal(Ex:
sun.org.mozilla.javascript.internal.Scriptable;).
<dependency>
<groupId>org.mozilla</groupId>
<artifactId>rhino</artifactId>
<version>1.7R4</version>
</dependency>
[1]
http://grepcode.com/file/repo1.maven.org/maven2/org.apache.bsf/bsf-utils/3.1/org/apache/bsf/xml/JavaScriptE4XXmlBeansHelper.java
Thanks,
Nuwanw
On Fri, Apr 15, 2016 at 11:05 AM, Sanjiva Weerawarana <[email protected]>
wrote:
> Kasun we should move to Nashorn - we're already doing that in UUF and
> that's the future.
>
> On Wed, Apr 13, 2016 at 1:58 AM, Manuranga Perera <[email protected]> wrote:
>
>> I assume the current script engine use evaluate method. We can support
>> evaluating once and invoking per request. This will add significant
>> per-request performance improvements.
>>
>> Also when switching to nashorn we may be able to support IDEA debugging
>> like we have done for new UI framework.
>>
>> On Mon, Apr 11, 2016 at 1:47 PM, Kasun Indrasiri <[email protected]> wrote:
>>
>>> I think for a major release such as 5.0, its quite important to get this
>>> kind of major limitations fixed (this has been raised in several occasions
>>> AFAIR)
>>>
>>> Lets spend sometime and evaluate the effort involves with this.
>>> For Connectors, if this introduce any issues, we have to fix them and
>>> re-release connectors. Here we are talking about a major release and we
>>> simply can't halt such enhancements because of the down stream
>>> components/features.
>>>
>>> On Mon, Apr 11, 2016 at 2:04 PM, Maheeka Jayasuriya <[email protected]>
>>> wrote:
>>>
>>>> Hi all,
>>>>
>>>> Current script mediator implementation depends on
>>>> apache-commons-bsf-3.0 to get the script engines for Rhino, Ruby, Groovy
>>>> and Jython [1][2]. However, moving forward if we are to support newer Rhino
>>>> and Nashorn (for Java 8) we can directly use these engines or any other
>>>> implementation of our own by extending javax.script.ScriptEngine and
>>>> javax.script.ScriptEngineFactory respectively. We only need to register
>>>> these with the javax.script.ScriptEngineManager. We can for the moment
>>>> support newer version of Rhino and Nashorn as new script engines (by
>>>> defining a new parameter value to select the engine) so as to not break the
>>>> existing stories.
>>>>
>>>> Are we aware of all the limitations of Rhino at the moment? Is it only
>>>> the 64KB limitation that we are focusing on?
>>>>
>>>> [1] http://commons.apache.org/proper/commons-bsf/
>>>> [2]
>>>> https://github.com/wso2/wso2-synapse/blob/master/modules/extensions/src/main/java/org/apache/synapse/mediators/bsf/ScriptMediator.java
>>>> : initScriptEngine() method
>>>>
>>>> Thanks,
>>>> Maheeka
>>>>
>>>>
>>>> Maheeka Jayasuriya
>>>> Software Engineer
>>>> Mobile : +94777750661
>>>>
>>>> On Mon, Apr 11, 2016 at 12:55 PM, Prabath Ariyarathna <
>>>> [email protected]> wrote:
>>>>
>>>>> @PrabathAR - Can you give us more details on this please?
>>>>>
>>>>> Inside Rhino engine, we can set optimization levels[1] which change
>>>>> the behavior of the engine. Default level is 0 and no optimizations are
>>>>> performed, but we can set this level in between -1 and 9 for the different
>>>>> optimizations. We can set this level to -1 which Rhino switch into the
>>>>> interpreted mode, which means that it goes down to a different path for
>>>>> executing the code than it does in compiled mode. Interpreted mode is, of
>>>>> course, slower than compiled mode but improvement from the memory usage
>>>>> side[2].
>>>>> If we can give the optimization level in a configurable way we can
>>>>> overcome this issue.
>>>>>
>>>>> But +1 for adding new Rhino version if issue already fixed it in the
>>>>> later version. However we can check the possibility of adding configurable
>>>>> optimization levels.
>>>>>
>>>>> [1]
>>>>> https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino/Optimization
>>>>> [2]
>>>>> http://stackoverflow.com/questions/14538541/performance-of-the-compiled-vs-interpreted-javascript-in-java7-rhino
>>>>>
>>>>> Thanks.
>>>>>
>>>>> On Mon, Apr 11, 2016 at 12:34 PM, Vanjikumaran Sivajothy <
>>>>> [email protected]> wrote:
>>>>>
>>>>>> With JDK 8, there is an in-build JS engine called Nashorn. Isn't that
>>>>>> worth to leverage the JS support by using native implementation to JDK 8?
>>>>>>
>>>>>>
>>>>>> [1]
>>>>>> http://www.oracle.com/technetwork/articles/java/jf14-nashorn-2126515.html
>>>>>>
>>>>>> On Sun, Apr 10, 2016 at 11:57 PM, Malaka Silva <[email protected]>
>>>>>> wrote:
>>>>>>
>>>>>>> PrabathAR has already found a way to support this using existing
>>>>>>> rhino version. There is a configuration to optimize the execution.
>>>>>>>
>>>>>>> @PrabathAR - Can you give us more details on this please?
>>>>>>>
>>>>>>> On Mon, Apr 11, 2016 at 12:22 PM, Nuwan Pallewela <[email protected]>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Hi All,
>>>>>>>>
>>>>>>>> There is a limitation in wso2 script mediator when we try to
>>>>>>>> manipulate payloads with JavaScript as the scripting language, when the
>>>>>>>> Payload size is larger than 64KB, ESB throws an exception. Cause for
>>>>>>>> this
>>>>>>>> is Rhino version which is used by the script mediator has a limitation
>>>>>>>> of
>>>>>>>> handling JavaScript objects of size 64KB or more. But rhino have fixed
>>>>>>>> it
>>>>>>>> in the later versions. So we can include new rhino and nashorn engines
>>>>>>>> as
>>>>>>>> the script engine for JS in script mediator and avoid the limitation of
>>>>>>>> handling larger payloads.
>>>>>>>> Can we do this improvement to ESB 5.0.0 release?
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> Nuwan
>>>>>>>>
>>>>>>>> --
>>>>>>>> ----------------------------------------------------------
>>>>>>>>
>>>>>>>> *Nuwan Chamara Pallewela*
>>>>>>>>
>>>>>>>>
>>>>>>>> *Software Engineer*
>>>>>>>>
>>>>>>>> *WSO2, Inc. *http://wso2.com
>>>>>>>> *lean . enterprise . middleware*
>>>>>>>>
>>>>>>>> Email *[email protected] <[email protected]>*
>>>>>>>> Mobile *+94719079739 <%2B94719079739>@*
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> Architecture mailing list
>>>>>>>> [email protected]
>>>>>>>> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>>
>>>>>>> Best Regards,
>>>>>>>
>>>>>>> Malaka Silva
>>>>>>> Senior Tech Lead
>>>>>>> M: +94 777 219 791
>>>>>>> Tel : 94 11 214 5345
>>>>>>> Fax :94 11 2145300
>>>>>>> Skype : malaka.sampath.silva
>>>>>>> LinkedIn : http://www.linkedin.com/pub/malaka-silva/6/33/77
>>>>>>> Blog : http://mrmalakasilva.blogspot.com/
>>>>>>>
>>>>>>> WSO2, Inc.
>>>>>>> lean . enterprise . middleware
>>>>>>> http://www.wso2.com/
>>>>>>> http://www.wso2.com/about/team/malaka-silva/
>>>>>>> <http://wso2.com/about/team/malaka-silva/>
>>>>>>> https://store.wso2.com/store/
>>>>>>>
>>>>>>> Save a tree -Conserve nature & Save the world for your future. Print
>>>>>>> this email only if it is absolutely necessary.
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> Architecture mailing list
>>>>>>> [email protected]
>>>>>>> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Vanjikumaran Sivajothy
>>>>>> *Associate Technical Lead*
>>>>>> *WSO2 Inc. http://wso2.com <http://wso2.com/>*
>>>>>> *+1-925-464-6816*
>>>>>> [image: Facebook] <https://www.facebook.com/vanjikumaran> [image:
>>>>>> Twitter] <https://twitter.com/vanjikumaran> [image: LinkedIn]
>>>>>> <http://www.linkedin.com/pub/vanjikumaran-sivajothy/25/b31/293> [image:
>>>>>> Blogger] <http://vanjikumaran.blogspot.com/> [image: SlideShare]
>>>>>> <http://www.slideshare.net/vanjikumaran>
>>>>>>
>>>>>> This communication may contain privileged or other
>>>>>> confidential information and is intended exclusively for the addressee/s.
>>>>>> If you are not the intended recipient/s, or believe that you may
>>>>>> have received this communication in error, please reply to the
>>>>>> sender indicating that fact and delete the copy you received and in
>>>>>> addition, you should not print, copy, re-transmit, disseminate, or
>>>>>> otherwise use the information contained in this communication.
>>>>>> Internet communications cannot be guaranteed to be timely, secure, error
>>>>>> or virus-free. The sender does not accept liability for any errors
>>>>>> or omissions
>>>>>>
>>>>>> _______________________________________________
>>>>>> Architecture mailing list
>>>>>> [email protected]
>>>>>> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>>
>>>>> *Prabath Ariyarathna*
>>>>>
>>>>> *Associate Technical Lead*
>>>>>
>>>>> *WSO2, Inc. *
>>>>>
>>>>> *lean . enterprise . middleware *
>>>>>
>>>>>
>>>>> *Email: [email protected] <[email protected]>*
>>>>>
>>>>> *Blog: http://prabu-lk.blogspot.com <http://prabu-lk.blogspot.com>*
>>>>>
>>>>> *Flicker : https://www.flickr.com/photos/47759189@N08
>>>>> <https://www.flickr.com/photos/47759189@N08>*
>>>>>
>>>>> *Mobile: +94 77 699 4730 *
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Architecture mailing list
>>>>> [email protected]
>>>>> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>>> Architecture mailing list
>>>> [email protected]
>>>> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>>>>
>>>>
>>>
>>>
>>> --
>>> Kasun Indrasiri
>>> Software Architect
>>> WSO2, Inc.; http://wso2.com
>>> lean.enterprise.middleware
>>>
>>> cell: +94 77 556 5206
>>> Blog : http://kasunpanorama.blogspot.com/
>>>
>>> _______________________________________________
>>> Architecture mailing list
>>> [email protected]
>>> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>>>
>>>
>>
>>
>> --
>> With regards,
>> *Manu*ranga Perera.
>>
>> phone : 071 7 70 20 50
>> mail : [email protected]
>>
>> _______________________________________________
>> Architecture mailing list
>> [email protected]
>> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>>
>>
>
>
> --
> Sanjiva Weerawarana, Ph.D.
> Founder, CEO & Chief Architect; WSO2, Inc.; http://wso2.com/
> email: [email protected]; office: (+1 650 745 4499 | +94 11 214 5345)
> x5700; cell: +94 77 787 6880 | +1 408 466 5099; voip: +1 650 265 8311
> blog: http://sanjiva.weerawarana.org/; twitter: @sanjiva
> Lean . Enterprise . Middleware
>
> _______________________________________________
> Architecture mailing list
> [email protected]
> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>
>
--
Nuwan Wimalasekara
Senior Software Engineer - Test Automation
WSO2, Inc.: http://wso2.com
lean. enterprise. middleware
phone: +94 71 668 4620
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture