0
votes

I would like to save the flow coming from this json file: https://gist.githubusercontent.com/Rajeun/3dbbe8ca240d479dbabe/raw/aba5d0ec9345b886426ab767376b7c9cb60c251f/person.json in a database using anypoint studio.

For this i'm using a http connector where i mentioned the link of the json file. and then i used a json-to-object transformer and a database connector. In my db i have a table with id, token, tel "int" and email is a varchar -(I tested the connection and its working well). when i run my code:

ERROR 2015-03-20 13:14:05,522 [main] org.mule.module.launcher.application.DefaultMuleApplication: null
java.lang.NullPointerException
    at org.mule.module.db.internal.config.domain.query.QueryTemplateBeanDefinitionParser.parseParameterizedQuery(QueryTemplateBeanDefinitionParser.java:136) ~[mule-module-db-3.6.1.jar:3.6.1]
    at org.mule.module.db.internal.config.domain.query.QueryTemplateBeanDefinitionParser.doParse(QueryTemplateBeanDefinitionParser.java:62) ~[mule-module-db-3.6.1.jar:3.6.1]
    at org.mule.config.spring.parsers.AbstractMuleBeanDefinitionParser.parseInternal(AbstractMuleBeanDefinitionParser.java:295) ~[mule-module-spring-config-3.6.1.jar:3.6.1]
    at org.springframework.beans.factory.xml.AbstractBeanDefinitionParser.parse(AbstractBeanDefinitionParser.java:59) ~[spring-beans-3.2.10.RELEASE.jar:3.2.10.RELEASE]
    at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73) ~[spring-beans-3.2.10.RELEASE.jar:3.2.10.RELEASE]
    at org.mule.config.spring.MuleHierarchicalBeanDefinitionParserDelegate.parseCustomElement(MuleHierarchicalBeanDefinitionParserDelegate.java:98) ~[mule-module-spring-config-3.6.1.jar:3.6.1]
    at org.mule.config.spring.MuleHierarchicalBeanDefinitionParserDelegate.parseCustomElement(MuleHierarchicalBeanDefinitionParserDelegate.java:140) ~[mule-module-spring-config-3.6.1.jar:3.6.1]
    ******************************************************************************

Config:

  <mule xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
        xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.6.1"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
    http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
    http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.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/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd">
        <http:listener-config name="HTTP_Listener_Configuration" host="www.gist.githubusercontent.com" port="80" doc:name="HTTP Listener Configuration"/>
        <db:mysql-config name="MySQL_Configuration" host="localhost" port="3306" user="root" database="mulesoft" doc:name="MySQL Configuration"/>
        <db:template-query name="Template_Query" doc:name="Template Query">
            <db:parameterized-query/>
        </db:template-query>
        <flow name="testFlow">
            <http:listener config-ref="HTTP_Listener_Configuration" path="Rajeun/3dbbe8ca240d479dbabe/raw/aba5d0ec9345b886426ab767376b7c9cb60c251f/person.json" doc:name="HTTP"/>
            <json:json-to-object-transformer returnClass="myclass" doc:name="JSON to Object"/>
            <response>
                <logger message="c bon" level="INFO" doc:name="Logger"/>
            </response>
            <response>
                <db:insert config-ref="MySQL_Configuration" doc:name="Database">
                    <db:parameterized-query><![CDATA[INSERT INTO push(id, token, tel, email) VALUES (2,2,3,#[payload['userImage']])]]></db:parameterized-query>
                </db:insert>
            </response>
        </flow>
    </mule>
1
there should be a stack trace showing the reason why deployment failed. Points to something wrong with your configuration. Please post this and the your configuration.Ryan Carter
ERROR 2015-03-20 10:37:00,163 [main] org.mule.module.launcher.application.DefaultMuleApplication: null java.lang.NullPointerExceptionRajeun
INFO 2015-03-20 10:37:00,164 [main] org.mule.module.launcher.application.DefaultMuleApplication: App 'test' never started, nothing to dispose of ERROR 2015-03-20 10:37:00,500 [main] org.mule.module.launcher.DefaultArchiveDeployer: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + Failed to deploy artifact 'test', see below +Rajeun
Caused by: org.mule.api.config.ConfigurationException: Unexpected exception parsing XML document from URL [file:/C:/Users/Rajeun/AnypointStudio/workspace/.mule/apps/test/test.xml]; nested exception is java.lang.NullPointerException (org.mule.api.lifecycle.InitialisationException) (org.mule.api.config.ConfigurationException)Rajeun

1 Answers

0
votes

Remove the empty template query:

<db:template-query name="Template_Query" doc:name="Template Query">
   <db:parameterized-query />
</db:template-query>

Also, does 'myclass' exist? if not try just using a map:

<json:json-to-object-transformer returnClass="java.util.HashMap" doc:name="JSON to Object"/>

Also It looks like you want to retrieve that JSON file from the specified URL. For that you want the http:request not http:listener. http:listener is used as a message source waiting for requests to your app.

You should use the http:request to request the file and trigger it using a polling message source:

<http:request-config name="HTTP_Request_Configuration" host="www.gist.githubusercontent.com" port="80" doc:name="HTTP Request Configuration"/>


 <flow name="testFlow">
    <poll>
        <http:request config-ref="HTTP_Request_Configuration" path="Rajeun/3dbbe8ca240d479dbabe/raw/aba5d0ec9345b886426ab767376b7c9cb60c251f/person.json" method="GET" doc:name="HTTP"/>
    </poll>

</flow>

See: http://www.mulesoft.org/documentation/display/current/HTTP+Request+Connector And: http://www.mulesoft.org/documentation/display/current/Poll+Reference