[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wsas-java-dev
Subject:    Re: [Dev] Is there a way to switch from Rhino to Nashorn for Script Mediator
From:       Thomas LEGRAND <thomas.legrand () versusmind ! eu>
Date:       2017-06-28 6:03:56
Message-ID: CAJN4piTAZcWNrSc_7CRJBSMa-4i7EDTvysN_VjeLLc5Pv1jSQA () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hello,

I used an ugly workaround to bypass the Rhino limitation: I put the big
JSON payload as string in a property and I empty the payload before calling
the script mediator.
The best would be able to use the enrich one by using directly JSON and not
XML but that is okay :)

Thanks for your help.

Regards

Thomas

Le mardi 27 juin 2017, Isuru Perera <isurup@wso2.com> a =C3=A9crit :

> Hi Asitha,
>
> Thomas is trying on EI 6.0.0. Not ESB. In EI, there is no
> "/repository/components/lib" directory.
>
> On Mon, Jun 26, 2017 at 3:01 PM, Asitha Nanayakkara <asitha@wso2.com
> <javascript:_e(%7B%7D,'cvml','asitha@wso2.com');>> wrote:
>
>> Hi Thomas,
>>
>> The project I have provided creates a jar. So you have to copy the jar t=
o
>> /repository/components/lib. Then you have to restart the ESB.
>>
>> If you want you can add the classes to a CAR project and add a template
>> to call the class mediator. Once the CAR is deployed you can invoke the
>> class mediator through the template without restarting the ESB.
>>
>> Regards,
>> Asitha
>>
>> On Mon, Jun 26, 2017 at 1:49 PM, Thomas LEGRAND <
>> thomas.legrand@versusmind.eu
>> <javascript:_e(%7B%7D,'cvml','thomas.legrand@versusmind.eu');>> wrote:
>>
>>> Hello Asitha,
>>>
>>> I tried to use your mediator to test but I have this error when I deplo=
y
>>> my CAR:
>>>
>>> java.lang.ClassNotFoundException: org.wso2.carbon.mediation.mediator.sa=
mple.NashornMediator
>>>> cannot be found by synapse-core_2.1.7.wso2v13 at
>>>> org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(Bundle=
Loader.java:501)
>>>> at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoade=
r.java:421)
>>>> at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoade=
r.java:412)
>>>> at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loa
>>>> dClass(DefaultClassLoader.java:107) at java.lang.ClassLoader.loadClass=
(Unknown
>>>> Source) at org.apache.synapse.config.xml.ClassMediatorFactory.createSp=
e
>>>> cificMediator(ClassMediatorFactory.java:102) ... 29 more
>>>
>>>
>>> I firstly tried to deploy it via the interface in the ESB artifacts
>>> menu. Then I tried by I dropping the generated JAR of the mediator in
>>> dropins. Then in repository/components/lib (directory I had to create).=
 And
>>> of course, I tried in lib, at the same level of dropins.
>>>
>>> What do I miss?
>>>
>>> Regards,
>>>
>>> Thomas
>>>
>>> 2017-06-25 19:16 GMT+02:00 Asitha Nanayakkara <asitha@wso2.com
>>> <javascript:_e(%7B%7D,'cvml','asitha@wso2.com');>>:
>>>
>>>> Hi Thomas,
>>>>
>>>> At the moment there is no straightforward way to configure the Script
>>>> mediator JS engine to use Nashorn.
>>>>
>>>> Another option would be to write a class mediator which uses the JDK
>>>> default JS engine or Nashorn specifically. You can use [1] as a refere=
nce
>>>> point if you are willing to write a class mediator. But you won't get =
the
>>>> E4X XML manipulation functionality you get from the Script mediator fr=
om
>>>> this. You might need to load a js library that does XML manipulation.
>>>>
>>>> [1] https://github.com/Asitha/nashorn-class-mediator
>>>>
>>>> Regards,
>>>> Asitha
>>>>
>>>> On Fri, Jun 23, 2017 at 8:40 PM, Thomas LEGRAND <
>>>> thomas.legrand@versusmind.eu
>>>> <javascript:_e(%7B%7D,'cvml','thomas.legrand@versusmind.eu');>> wrote:
>>>>
>>>>> Hello everybody,
>>>>>
>>>>> I encountered the limitation of the Rhino engine because of my heavy
>>>>> JSON payload. I am using Enterprise Integrator 6.0.0 with Java 8 and =
I
>>>>> found out that the default JS engine should be Nashorn for the Data M=
apper
>>>>> mediator.
>>>>>
>>>>> Is it possible to configure the EI to use the same JS engine for the
>>>>> Script mediator?
>>>>> And, is it possible to configure the Rhino engine to stop the
>>>>> optimization to prevent this error?
>>>>>
>>>>> Regards,
>>>>>
>>>>> Thomas
>>>>>
>>>>> _______________________________________________
>>>>> Dev mailing list
>>>>> Dev@wso2.org <javascript:_e(%7B%7D,'cvml','Dev@wso2.org');>
>>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> *Asitha Nanayakkara* <http://asitha.github.io/>
>>>> Senior Software Engineer
>>>> WSO2, Inc. <http://wso2.com/>
>>>> Mob: +94 77 853 0682 <+94%2077%20853%200682>
>>>> [image: https://wso2.com/signature] <https://wso2.com/signature>
>>>>
>>>>
>>>
>>
>>
>> --
>> *Asitha Nanayakkara* <http://asitha.github.io/>
>> Senior Software Engineer
>> WSO2, Inc. <http://wso2.com/>
>> Mob: +94 77 853 0682 <077%20853%200682>
>> [image: https://wso2.com/signature] <https://wso2.com/signature>
>>
>>
>> _______________________________________________
>> Dev mailing list
>> Dev@wso2.org <javascript:_e(%7B%7D,'cvml','Dev@wso2.org');>
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
>
> --
> Isuru Perera
> Technical Lead | WSO2, Inc. | http://wso2.com/
> Lean . Enterprise . Middleware
>
> about.me/chrishantha
> Contact: +IsuruPereraWSO2 <https://www.google.com/+IsuruPereraWSO2/about>
>

[Attachment #5 (text/html)]

Hello,<div><br></div><div>I used an ugly workaround to bypass the Rhino limitation: I \
put the big JSON payload as string in a property and I empty the payload before \
calling the script mediator.</div><div>The best would be able to use the enrich one \
by using directly JSON and not XML but that is okay \
:)</div><div><br></div><div>Thanks for your \
help.</div><div><br></div><div>Regards</div><div><br></div><div>Thomas</div><div><br>Le \
mardi 27 juin 2017, Isuru Perera &lt;<a \
href="mailto:isurup@wso2.com">isurup@wso2.com</a>&gt; a écrit  :<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div dir="ltr"><div>Hi Asitha,<br><br></div>Thomas is trying \
on EI 6.0.0. Not ESB. In EI, there is no &quot;/repository/components/lib&quot; \
directory.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun \
26, 2017 at 3:01 PM, Asitha Nanayakkara <span dir="ltr">&lt;<a \
href="javascript:_e(%7B%7D,&#39;cvml&#39;,&#39;asitha@wso2.com&#39;);" \
target="_blank">asitha@wso2.com</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div dir="ltr">Hi Thomas,<div><br></div><div>The project I \
have provided creates a jar. So you have to copy the jar to \
/repository/components/lib. Then you have to restart the \
ESB.</div><div><br></div><div>If you want you can add the classes to a CAR project \
and add a template to call the class mediator. Once the CAR is deployed you can \
invoke the class mediator through the template without restarting the \
ESB.</div><div><br></div><div>Regards,</div><div>Asitha</div></div><div><div><div \
class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 26, 2017 at 1:49 PM, \
Thomas LEGRAND <span dir="ltr">&lt;<a \
href="javascript:_e(%7B%7D,&#39;cvml&#39;,&#39;thomas.legrand@versusmind.eu&#39;);" \
target="_blank">thomas.legrand@versusmind.eu</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div dir="ltr"><div>Hello Asitha,<br><br></div>I tried to use \
your mediator to test but I have this error when I deploy my CAR:<br><br><blockquote \
class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex">java.lang.ClassNotFoundExcepti<wbr>on:  \
org.wso2.carbon.mediation.medi<wbr>ator.sample.NashornMediator cannot be  found by \
synapse-core_2.1.7.wso2v13  at 
org.eclipse.osgi.internal.load<wbr>er.BundleLoader.findClassInter<wbr>nal(BundleLoader.java:501)
  at 
org.eclipse.osgi.internal.load<wbr>er.BundleLoader.findClass(Bund<wbr>leLoader.java:421)
  at 
org.eclipse.osgi.internal.load<wbr>er.BundleLoader.findClass(Bund<wbr>leLoader.java:412)
  at 
org.eclipse.osgi.internal.base<wbr>adaptor.DefaultClassLoader.loa<wbr>dClass(DefaultClassLoader.java<wbr>:107)
  at java.lang.ClassLoader.loadClas<wbr>s(Unknown Source)
	at 
org.apache.synapse.config.xml.<wbr>ClassMediatorFactory.createSpe<wbr>cificMediator(ClassMediatorFac<wbr>tory.java:102)
                
	... 29 more</blockquote><div><br></div><div>I firstly tried to deploy it via the \
interface in the ESB artifacts menu. Then I tried by I dropping the generated JAR of \
the mediator in dropins. Then in repository/components/lib (directory I had to \
create). And of course, I tried in lib, at the same level of \
dropins.<br><br></div><div>What do I \
miss?<br><br></div><div>Regards,<br><br></div><div>Thomas<br></div></div><div><div><div \
class="gmail_extra"><br><div class="gmail_quote">2017-06-25 19:16 GMT+02:00 Asitha \
Nanayakkara <span dir="ltr">&lt;<a \
href="javascript:_e(%7B%7D,&#39;cvml&#39;,&#39;asitha@wso2.com&#39;);" \
target="_blank">asitha@wso2.com</a>&gt;</span>:<br><blockquote class="gmail_quote" \
style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div \
dir="ltr">Hi Thomas,<div><br></div><div>At the moment there is no straightforward way \
to configure the Script mediator JS engine to use \
Nashorn.</div><div><br></div><div>Another option would be to write a class mediator \
which uses the JDK default JS engine or Nashorn specifically. You can use [1] as a \
reference point if you are willing to write a class mediator. But you won&#39;t get \
the E4X XML manipulation functionality you get from the Script mediator from this. \
You might need to load a js library that does XML \
manipulation.</div><div><br></div><div>[1]  <a \
href="https://github.com/Asitha/nashorn-class-mediator" \
target="_blank">https://github.com/Asitha/<wbr>nashorn-class-mediator</a></div><div><br></div><div>Regards,</div><div>Asitha</div></div><div \
class="gmail_extra"><br><div class="gmail_quote"><div><div>On Fri, Jun 23, 2017 at \
8:40 PM, Thomas LEGRAND <span dir="ltr">&lt;<a \
href="javascript:_e(%7B%7D,&#39;cvml&#39;,&#39;thomas.legrand@versusmind.eu&#39;);" \
target="_blank">thomas.legrand@versusmind.eu</a>&gt;</span> \
wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 \
.8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr">Hello \
everybody,<div><br></div><div>I encountered the limitation of the Rhino engine \
because of my heavy JSON payload. I am using Enterprise Integrator 6.0.0 with Java 8 \
and I found out that the default JS engine should be Nashorn for the Data Mapper \
mediator.</div><div><br></div><div>Is it possible to configure the EI to use the same \
JS engine for the Script mediator?</div><div>And, is it possible to configure the \
Rhino engine to stop the optimization to prevent this \
error?</div><div><br></div><div>Regards,</div><div><br></div><div>Thomas</div></div> \
<br></div></div>______________________________<wbr>_________________<br> Dev mailing \
list<br> <a href="javascript:_e(%7B%7D,&#39;cvml&#39;,&#39;Dev@wso2.org&#39;);" \
target="_blank">Dev@wso2.org</a><br> <a \
href="http://wso2.org/cgi-bin/mailman/listinfo/dev" rel="noreferrer" \
target="_blank">http://wso2.org/cgi-bin/mailma<wbr>n/listinfo/dev</a><br> \
<br></blockquote></div><span><font color="#888888"><br><br \
clear="all"><div><br></div>-- <br><div data-smartmail="gmail_signature"><div \
dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div \
dir="ltr"><div dir="ltr"><div><a href="http://asitha.github.io/" \
target="_blank"><font size="2" face="arial, helvetica, sans-serif" \
color="#0b5394"><b>Asitha Nanayakkara</b></font></a></div><div \
style="color:rgb(136,136,136)"><span style="color:rgb(102,102,102)"><font \
face="arial, helvetica, sans-serif">Senior Software Engineer</font></span></div> \
<div><a href="http://wso2.com/" target="_blank"><font face="arial, helvetica, \
sans-serif" color="#666666">WSO2, Inc.</font></a><font face="arial, helvetica, \
sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif"><font \
color="#666666">Mob:</font><font color="#000000">  <a \
href="tel:+94%2077%20853%200682" value="+94778530682" target="_blank">+94 77 853 \
0682</a></font></font></div><div><font color="#000000"><a \
href="https://wso2.com/signature" target="_blank"><img \
alt="https://wso2.com/signature" \
src="http://c.content.wso2.com/signatures/wso2-signature-general.png"></a><br><br></font></div></div></div></div></div></div></div></div></div></div></div></div>
 </font></span></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div \
data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div \
dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><a \
href="http://asitha.github.io/" target="_blank"><font size="2" face="arial, \
helvetica, sans-serif" color="#0b5394"><b>Asitha Nanayakkara</b></font></a></div><div \
style="color:rgb(136,136,136)"><span style="color:rgb(102,102,102)"><font \
face="arial, helvetica, sans-serif">Senior Software Engineer</font></span></div> \
<div><a href="http://wso2.com/" target="_blank"><font face="arial, helvetica, \
sans-serif" color="#666666">WSO2, Inc.</font></a><font face="arial, helvetica, \
sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif"><font \
color="#666666">Mob:</font><font color="#000000">  <a href="tel:077%20853%200682" \
value="+94778530682" target="_blank">+94 77 853 \
0682</a></font></font></div><div><font color="#000000"><a \
href="https://wso2.com/signature" target="_blank"><img \
alt="https://wso2.com/signature" \
src="http://c.content.wso2.com/signatures/wso2-signature-general.png"></a><br><br></font></div></div></div></div></div></div></div></div></div></div></div></div>
 </div>
</div></div><br>______________________________<wbr>_________________<br>
Dev mailing list<br>
<a href="javascript:_e(%7B%7D,&#39;cvml&#39;,&#39;Dev@wso2.org&#39;);" \
target="_blank">Dev@wso2.org</a><br> <a \
href="http://wso2.org/cgi-bin/mailman/listinfo/dev" rel="noreferrer" \
target="_blank">http://wso2.org/cgi-bin/mailma<wbr>n/listinfo/dev</a><br> \
<br></blockquote></div><br><br clear="all"><br>-- <br><div \
data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div \
dir="ltr"><div><div dir="ltr"><span style="color:rgb(102,102,102)"><font \
size="2"><span style="font-family:arial,helvetica,sans-serif">Isuru \
Perera<br>Technical Lead | WSO<font size="2">2,</font> Inc. | <a \
href="http://wso2.com/" target="_blank">http://wso2.com/</a><br>Lean . Enterprise . \
Middleware<br></span></font></span><br><a href="http://about.me/chrishantha" \
target="_blank">about.me/chrishantha</a><br></div><div><span><span \
style="color:rgb(102,102,102)"><font size="2"><span \
style="font-family:arial,helvetica,sans-serif">Contact: \
</span></font></span></span><a href="https://www.google.com/+IsuruPereraWSO2/about" \
target="_blank">+IsuruPereraWSO2</a></div></div></div></div></div></div></div></div> \
</div> </blockquote></div>



_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic