0
votes

I am using Latest Anypoint Studio 4

My Workflow

    <?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
    xmlns:json="http://www.mulesoft.org/schema/mule/json" 
    xmlns:db="http://www.mulesoft.org/schema/mule/db"
    xmlns="http://www.mulesoft.org/schema/mule/core"
    xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd http://www.mulesoft.org/schema/mule/json 
    http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd 
    http://www.mulesoft.org/schema/mule/core 
    http://www.mulesoft.org/schema/mule/core/current/mule.xsd
    http://www.mulesoft.org/schema/mule/db 
    http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd
    http://www.mulesoft.org/schema/mule/ee/core 
    http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
    <db:config name="Database_Config" doc:name="Database Config" doc:id="b64daf9d-2d50-406d-8555-2669e73fdaa0" >
        <db:my-sql-connection host="localhost" port="3306" user="root" password="admin" database="company?useSSL=false" />
    </db:config>
    <flow name="ducksoupFlow" doc:id="667d651e-5778-4470-9cf8-6ce044f3c53f" >
        <scheduler doc:name="Scheduler" doc:id="737ee2ce-e3b3-4e7f-838f-18146b871299" >
            <scheduling-strategy >
                <fixed-frequency />
            </scheduling-strategy>
        </scheduler>
        <db:select doc:name="Database_Config" doc:id="25c71406-2ef2-41fb-8521-37e138f5dc1e" config-ref="Database_Config">
            <db:sql >select dob,first_name,last_name,gender, role from employees e, roles r where e.no = r.emp_no</db:sql>
        </db:select>
        <json:object-to-json-transformer doc:name="Object to JsOn" doc:id="97af6f79-004a-4a63-a5c4-aa7c08273bde" />
        <logger level="INFO" doc:name="Logger" doc:id="a730ff7b-9fb6-4c0e-979c-c9c692ec5b74" message="#[payload]"/>
    </flow>
</mule>

Build is Successful, when deploy getting the error

org.xml.sax.SAXParseException; lineNumber: 30; columnNumber: 110; cvc-complex-type.2.4.a: Invalid content was found starting with element 'json:object-to-json-transformer'. One of '{"http://www.mulesoft.org/schema/mule/core":abstract-message-processor, "http://www.mulesoft.org/schema/mule/core":abstract-mixed-content-message-processor, "http://www.mulesoft.org/schema/mule/core":abstract-exception-strategy}' is expected.

Somewhere it suggests changing the "Current" in the namespace to version. I tried that too. No Luck

Any help is really appreciated

1

1 Answers

1
votes

If you are using Mule Runtime version 3.x, then make sure you have following dependency in pom.xml

<dependency>
    <groupId>org.mule.modules</groupId>
    <artifactId>mule-module-json</artifactId>
    <version>${mule.version}</version>
</dependency>

If you are using Mule 4.x, then DataWeave is recommended.

<set-payload value=#[output application/json --- payload] />

OR

<set-payload value="#[payload]" mimeType="application/json" />