Search code examples
wso2wso2-enterprise-integratorwso2-integration-studio

JsonUtil cannot be resolved in WSO2 class mediator


I am using WSO2 Class mediator to inject String to Jsonbody by using WSO2 Developer Studio.

String transformedJson=jsonBody.toString();
        JsonUtil.newJsonPayload(((Axis2MessageContext) context).getAxis2MessageContext(),
                transformedJson, true, true);

Facing ERROR like "JsonUtil cannot be resolved" after adding import statement as "import org.apache.synapse.commons.json.JsonUtil;"

Dependency added in class mediator pom.xml by follows this. Still can't able to resolve this import ERROR.

Dependency File:

    <!-- https://mvnrepository.com/artifact/org.apache.synapse/synapse-core -->
<dependency>
    <groupId>org.apache.synapse</groupId>
    <artifactId>synapse-core</artifactId>
    <version>2.1.2-wso2v4</version>
</dependency>

Can i get Jar for this? I hope jar name would be "synapse-commons-2.1.2-wso2v4.jar".


Solution

  • I resolved above JsonUtil ERROR by adding below dependency in pom.xml

    Note: after updating pom.xml, i did mvn update by clicking alt+f5.

    dependency:

    <!-- https://mvnrepository.com/artifact/org.apache.synapse/synapse-commons -->
    <dependency>
        <groupId>org.apache.synapse</groupId>
        <artifactId>synapse-commons</artifactId>
        <version>2.1.7-wso2v228</version>
    </dependency>
    

    Reference Link: check here