0

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>
Ryan Carter
  • 11,441
  • 2
  • 20
  • 27
Rajeun
  • 721
  • 2
  • 12
  • 37
  • 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 Mar 20 '15 at 10:31
  • ERROR 2015-03-20 10:37:00,163 [main] org.mule.module.launcher.application.DefaultMuleApplication: null java.lang.NullPointerException – Rajeun Mar 20 '15 at 10:40
  • 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 Mar 20 '15 at 10:40
  • 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 Mar 20 '15 at 10:41
  • 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) Caused by: org.mule.api.lifecycle.InitialisationException: Unexpected exception parsing XML document from URL [file:/C:/Users/Rajeun/AnypointStudio/workspace/.mule/apps/test/test.xml]; nested exception is java.lang.NullPointerException – Rajeun Mar 20 '15 at 10:42
  • Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from URL [file:/C:/Users/Rajeun/AnypointStudio/workspace/.mule/apps/test/test.xml]; nested exception is java.lang.NullPointerException Caused by: java.lang.NullPointerException – Rajeun Mar 20 '15 at 10:42
  • <![CDATA[INSERT INTO push(id, token, tel, email) VALUES (1,2,3,#[payload['userImage']])]]> – Rajeun Mar 20 '15 at 11:02
  • @RyanCarter have you any suggestion?? – Rajeun Mar 20 '15 at 12:26
  • I can't read this in the comments. Can you edit your original question and paste the full trace and full xml config in the question? – Ryan Carter Mar 20 '15 at 12:41
  • @RyanCarter done !! check this link: http://stackoverflow.com/revisions/9764b14c-a22f-4ec8-b271-d278b0309499/view-source – Rajeun Mar 20 '15 at 13:19
  • Ok, I still cant see your config though? Can you post the XML config? – Ryan Carter Mar 20 '15 at 13:42
  • 1
    Also, please: http://meta.stackexchange.com/help/formatting – David Dossot Mar 20 '15 at 13:43

1 Answers1

0

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

Ryan Carter
  • 11,441
  • 2
  • 20
  • 27
  • thank you for replying. well it gives new exceptions: java.io.IOException org.mule.api.config.ConfigurationException org.mule.api.lifecycle.InitialisationException org.springframework.beans.factory.BeanCreationException org.mule.api.lifecycle.InitialisationException: org.mule.api.MuleRuntimeException – Rajeun Mar 20 '15 at 15:07
  • Again, I need the full stack trace. Can you upload it to pastebin or something similar? – Ryan Carter Mar 20 '15 at 15:18
  • I feel that there is something missing: I got also this exception: Caused by: java.lang.ClassNotFoundException: Cannot load class 'myclass' – Rajeun Mar 20 '15 at 15:21
  • do you have a class called 'myclass'? If not try using a map instead. See my updated answer – Ryan Carter Mar 20 '15 at 15:23
  • yep, check my updated answer. Either replace the returnClass with the correct fully qualified class or use a map. – Ryan Carter Mar 20 '15 at 15:28
  • I think its okey.i still have probleme with the http connector configuration, I have to change the link of the json file its not working. thank you very much for your help !! – Rajeun Mar 20 '15 at 15:34
  • I think I can see your problem. I updated my answer again with some info to help. – Ryan Carter Mar 20 '15 at 15:45
  • I'm sorry I asked a lot of questions.well the application is deployed but there are some errors: http://pastebin.com/SYG5avz9 – Rajeun Mar 20 '15 at 16:47