0
votes

I try to add a sequence which contains a java script mediator as below :

"<sequence name="response">
    <script language="js">
        mc.setPayloadXML(
        &lt;greeting&gt;Hello World&lt;/greeting&gt;
        );
    </script>
    <header name="To" action="remove"/>
    <property name="messageType" value="application/json" scope="axis2"/>       
    <property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
    <property name="RESPONSE" value="true"/>
    <send/>
    <log level="full"/>
</sequence>"

*Howerver,it occurs a error once I press the Update Button,the whole function stack is shown in the log, I check the jar "bsf-all,3.0.0.wso2v2" and it really contains the missing class and the jar is shown in the bundles info "bsf-all,3.0.0.wso2v2,../plugins/bsf-all_3.0.0.wso2v2.jar,4,true" :* "com/sun/phobos/script/javascript/RhinoScriptEngineFactory {org.apache.axis2.rpc.receivers.RPCMessageReceiver} java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at ...... Caused by: java.lang.NoClassDefFoundError: com/sun/phobos/script/javascript/RhinoScriptEngineFactory at org.apache.synapse.mediators.bsf.ScriptMediator.initScriptEngine(ScriptMediator.java:475) at org.apache.synapse.mediators.bsf.ScriptMediator.initInlineScript(ScriptMediator.java:341) at org.apache.synapse.mediators.bsf.ScriptMediator.(ScriptMediator.java:146) at org.apache.synapse.mediators.bsf.ScriptMediatorFactory.createSpecificMediator(ScriptMediatorFactory.java:105) at org.apache.synapse.config.xml.AbstractMediatorFactory.createMediator(AbstractMediatorFactory.java:91) at org.apache.synapse.config.xml.MediatorFactoryFinder.getMediator(MediatorFactoryFinder.java:223) at org.apache.synapse.config.xml.AbstractListMediatorFactory.addChildren(AbstractListMediatorFactory.java:41) at org.apache.synapse.config.xml.SequenceMediatorFactory.createSpecificMediator(SequenceMediatorFactory.java:87) at org.apache.synapse.config.xml.AbstractMediatorFactory.createMediator(AbstractMediatorFactory.java:91) at org.wso2.carbon.mediation.configadmin.ConfigurationValidator.validateSequence(ConfigurationValidator.java:90) at org.wso2.carbon.mediation.configadmin.ConfigurationValidator.validate(ConfigurationValidator.java:73) at org.wso2.carbon.mediation.configadmin.ConfigAdmin.validateConfiguration(ConfigAdmin.java:180) ... 61 more Caused by: java.lang.ClassNotFoundException: com.sun.phobos.script.javascript.RhinoScriptEngineFactory at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:501) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412) atorg.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoa .. at java.lang.ClassLoader.loadClass(ClassLoader.java:248) ... 73 more"

I look up the solution about the same issue you given to other person https://wso2.org/jira/browse/ESBJAVA-1685 but it doesn't take effect.And I search Google for the question for a long time ,someone said the error has been fixxed or it is something wrong with OSGI Frame when it sets up,but others has the same problem with me still stick in it , so please give us a complete solution about how to use script mediator in WSO2 AM 1.5,tks a lot !

1

1 Answers

0
votes

There is an issue with the bsf jar which we use to provide scripting engine..As an alternative way, you can use enrich/payload factory mediator to achieve above task