Home > Blockchain >  Error showing when calling class from sequence
Error showing when calling class from sequence

Time:11-11

I am trying to call class from a wso2 sequence However, I am getting this error:

 Error loading class : com.test.mediator.ChangeValue - Class not found java.lang.ClassNotFoundException: com.test.mediator.ChangeValue cannot be found by synapse-core_2.1.7.wso2v182

For a little better understanding calling class in sequence is as follows:

 <class name="com.test.mediator.ChangeValue"/>
<log level="custom">
    <property name="After CLASS" value="in Seq"/>
    <property expression="$ctx:NameN" name="NameClass"/>
</log>

For class, the class definition is as follows:

package com.test.mediator;

import org.apache.synapse.MessageContext; 
import org.apache.synapse.mediators.AbstractMediator;

public class ChangeValue extends AbstractMediator {

public boolean mediate(MessageContext context) { 
    // TODO Implement your mediation logic here 
    changeVal(context);
    return true;
}

public void changeVal(MessageContext context) {
    String Namem = (String) context.getProperty("NAMEE");
    String Namen = "Ali";
    context.setProperty("NameN", Namen);
  }
}

Any help why this error would be showing up would mean a lot please thanks

CodePudding user response:

What's happening here is you haven't added the Class mediator to the MI run time. So runtime is unable to find the Class mediator. There are two ways to add a Class mediator to the MI runtime.

  1. Build the Class Mediator Project using Maven and copy the Jar to <MI_HOME>/lib directory and restart the server.
  2. Pack the ClassMediator into a Carbon Application and deploy it to MI. You can use this blog as a reference.
  • Related