Error when testing Connection of Global Element in MuleStudio - mule

I'm using MuleStudio 3.4 and have a simple Flow with a Drupal Connector. The Configuration for this Drupal Connector comes from a Global ElemCent Configuration.
But when i want to test the connection from the Global Elements Properties Window, i get the the message:
Test Connection failed: Invalid Global Element. Cannot access the Global Element to test.
java.long.Throwable
Here is the Configuration XML:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:drupal="http://www.mulesoft.org/schema/mule/drupal" 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="CE-3.4.0" 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/json http://www.mulesoft.org/schema/mule/json/current/mule-json.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/drupal http://www.mulesoft.org/schema/mule/drupal/1.0/mule-drupal.xsd">
<drupal:config name="Drupal" username="dba" password="***" apiUrl="/service/rest/" server="localhost" port="8888" commentEndpoint="comment" fileEndpoint="file" nodeEndpoint="node" userEndpoint="user" doc:name="Drupal" taxonomyTermEndpoint="taxonomy-term" taxonomyVocabularyEndpoint="taxonomy-vocabulary">
<drupal:connection-pooling-profile initialisationPolicy="INITIALISE_ONE" exhaustedAction="WHEN_EXHAUSTED_GROW"/>
</drupal:config>
<flow name="drupal-esbFlow1" doc:name="drupal-esbFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="drupal/node/create" doc:name="HTTP"/>
<drupal:create-node config-ref="Drupal" username="dba" password="***" doc:name="Drupal">
<drupal:node type="article" title="[message.payload['title']]">
<drupal:body>
<drupal:und ref="#[payload]"/>
</drupal:body>
</drupal:node>
</drupal:create-node>
<json:object-to-json-transformer doc:name="Object to JSON"/>
</flow>

just make sure that you are persisting this information in mule-app.properties. Otherwise you can create another property place holder and after referencing that you can go ahead and use.

Related

Passing a Mule payload object to Drools rule

I'm tying to build a mule flow which get data from a db, builds an object and then fires a drools rule. My problem is initialFacts-ref="#[payload.MapObject]" cannot be resolved. On deployment I'm getting 'No bean named '#[payload.MapObject]' is defined' How can I get the payload object into the rule as a fact?
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:db="http://www.mulesoft.org/schema/mule/db"
xmlns:json="http://www.mulesoft.org/schema/mule/json"
xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xmlns:jms="http://www.mulesoft.org/schema/mule/jms"
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"
xmlns:bpm="http://www.mulesoft.org/schema/mule/bpm"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-current.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/json
http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/vm
http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd
http://www.mulesoft.org/schema/mule/jms
http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd
http://www.mulesoft.org/schema/mule/core
http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/bpm
http://www.mulesoft.org/schema/mule/bpm/3.2/mule-bpm.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/ee/tracking
http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/ee/dw
http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd">
<bpm:drools />
<flow name="myFlow" >
<http:listener config-ref="HTTP_Listener_Configuration" path="/myflow" doc:name="HTTP">
<http:response-builder>
<http:header headerName="Access-Control-Allow-Origin" value="*"/>
</http:response-builder>
</http:listener>
<db:select config-ref="MySQL_Finance" doc:name="Database">
<db:parameterized-query><![CDATA[SELECT * FROM myTable WHERE ID = #[message.inboundProperties.'http.query.params'.ID]]]></db:parameterized-query>
</db:select>
<response>
<json:object-to-json-transformer doc:name="Object to JSON"/>
</response>
<component class="org.mule.transformers.myMapping" doc:name="myMapping"/>
<bpm:rules doc:name="myRule" rulesDefinition="src/main/resources/rules/myRule.drl" initialFacts-ref="#[payload.MapObject]"/>
</flow>
</mule>
package org.mule.transformers;
import org.mule.api.MuleMessage;
import org.mule.api.transformer.TransformerException;
import org.mule.transformer.AbstractMessageTransformer;
public class myMapping extends AbstractMessageTransformer {
/**
* #param args
*/
public Object transformMessage(MuleMessage message, String outputEncoding) throws TransformerException {
Object myMapping = null;
if(message != null){
myMapping = message.getPayload();
}
return myMapping;
}
}
initialFacts-ref refers to an existing Spring bean so you can't use a MEL expression as you try to. It is used for loading initial facts so that's why it's static.
In your case, it seems you just want to process the current message in a rule, not provide an initial set of facts to the rules engine. In this case, there's nothing to do. The current message payload is passed to Drools so you can access it directly.

Publish jms message to WMQ mule

I want to publish jms message to Websphere MQ,so I made the configuration changes in my mule configuration file as
targetClient="JMS_COMPLIANT" specification="1.1"/>
But still I am not able to publush jms message I am getting an error like
Root Exception stack trace:
com.ibm.msg.client.jms.DetailedJMSException: JMSCMQ0004: The value '-999999999' was not valid for the property 'targetClient'.
The value of the property 'targetClient' was none of the valid values for this property.
Set the property to a valid value.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
I cannot use Jms connector here as per my project requirement,
can anybody help me in publishing JMS message to WMQ without using Jms connector
Below is my configuration
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:ftp="http://www.mulesoft.org/schema/mule/ee/ftp" xmlns:data-mapper="http://www.mulesoft.org/schema/mule/ee/data-mapper" xmlns:wmq="http://www.mulesoft.org/schema/mule/ee/wmq" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:jms="http://www.mulesoft.org/schema/mule/jms" 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.5.0"
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/ee/wmq http://www.mulesoft.org/schema/mule/ee/wmq/current/mule-wmq-ee.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/ee/data-mapper http://www.mulesoft.org/schema/mule/ee/data-mapper/current/mule-data-mapper.xsd
http://www.mulesoft.org/schema/mule/ee/ftp http://www.mulesoft.org/schema/mule/ee/ftp/current/mule-ftp-ee.xsd">
<wmq:connector name="MyQueue" hostName="XXX" port="XXX" transportType="CLIENT_MQ_TCPIP" validateConnections="true" doc:name="WMQ" channel="SYSTEM.DEF.SVRCONN" queueManager="DevQueueManager1" password="XXX" username="XXX" targetClient="JMS_COMPLIANT"/>
<jms:object-to-jmsmessage-transformer name="Object_to_JMSMessage" doc:name="Object to JMSMessage"/>
<flow name="mqconnectorflowFlow" doc:name="mqconnectorflowFlow">
<file:inbound-endpoint path="D:\Mule-Documents\MyTasks\WMQ\In" responseTimeout="10000" doc:name="File"/>
<wmq:outbound-endpoint queue="DevQueue" connector-ref="MyQueue" doc:name="WMQ" targetClient="JMS_COMPLIANT"/>
</flow>

MULE Esb xml to Object transformer

I am trying to utilize the xml to object transformer in mule while transfroming an xml payload to a Java Bean (Customer). Here is my simple flow. The exception I am seeing is below
Exception stack is:
1. CUSTOMER (com.thoughtworks.xstream.mapper.CannotResolveClassException)
com.thoughtworks.xstream.mapper.DefaultMapper:56 (null)
2. CUSTOMER (com.thoughtworks.xstream.mapper.CannotResolveClassException) (org.mule.api.transformer.TransformerException)
org.mule.module.xml.transformer.XmlToObject:76 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transformer/TransformerException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
com.thoughtworks.xstream.mapper.CannotResolveClassException: CUSTOMER
at com.thoughtworks.xstream.mapper.DefaultMapper.realClass(DefaultMapper.java:56)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.DynamicProxyMapper.realClass(DynamicProxyMapper.java:55)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
FLOW
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" 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.4.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/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd">
<flow name="alternateFlow1" doc:name="alternateFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8999" doc:name="HTTP"/>
<http:outbound-endpoint exchange-pattern="request-response" host="www.thomas-bayer.com" port="80" path="sqlrest/CUSTOMER/3/" method="GET" doc:name="HTTP"/>
<mulexml:xml-to-object-transformer returnClass="com.abc.dto.CUSTOMER" doc:name="XML to Object"/>
<logger level="INFO" doc:name="Logger"/>
</flow>
</mule>
XML:
<CUSTOMER xmlns:xlink="w3.org/1999/xlink">
;
<ID>4</ID>
<FIRSTNAME>Sylvia</FIRSTNAME>
<LASTNAME>Ringer</LASTNAME>
<STREET>365 College Av.</STREET>
<CITY>Dallas</CITY>
</CUSTOMER>
You need to add an alias in the mulexml:xml-to-object-transformer:
<mulexml:alias name="CUSTOMER" class="com.abc.dto.CUSTOMER" />
Also there's no reason to go all caps with the class name so rename your class and alias it:
<mulexml:alias name="CUSTOMER" class="com.abc.dto.Customer" />

Using Smooks transformer in Mule 3.4 CE

I'm trying to use smooks 1.5 to transform a csv file to xml. I have already imported all smooks jar, but getting this error
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration >problem: Unable to locate NamespaceHandler for namespace >>[http://www.muleforge.org/smooks/schema/mule-module-smooks]
Offending resource: URL >>[file:/D:/Documents/MuleStudio/workspace/.mule/apps/smooksapp/SmooksApp.xml]
This is my mule-config file
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:smooks="http://www.muleforge.org/smooks/schema/mule-module-smooks" 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.4.0" 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/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.muleforge.org/smooks/schema/mule-module-smooks http://dist.muleforge.org/smooks/schema/mule-module-smooks/1.3/mule-module-smooks.xsd">
<flow name="SmooksAppFlow1" doc:name="SmooksAppFlow1">
<file:inbound-endpoint path="D:\Documents\MuleStudio\workspace\smooksapp\src\main\resources" responseTimeout="10000" doc:name="File"/>
<smooks:transformer name="csvToXmlSmooksTransformer" configFile="D:\Documents\MuleStudio\workspace\smooksapp\src\main\resources\smooks-config.xml" resultType="STRING" reportPath="target/smooks-report/report.html" />
<file:outbound-endpoint responseTimeout="10000" doc:name="File" path="D:\Documents\MuleStudio\workspace\smooksapp\src\main\resources"/>
</flow>
</mule>
Add this to your project pom.xml file:
<dependencies>
...
<!-- The Mule Smooks Module -->
<dependency>
<groupId>org.mule.modules.mule-module-smooks</groupId>
<artifactId>smooks-4-mule-3</artifactId>
<version>1.3-RC1</version>
</dependency>
...
</dependencies>
Works fine with Mule version 3.4.1.

Chaining router and scheme

i am attempting to use a chaining router like so:
<flow name="Something">
<quartz:inbound-endpoint jobName="eventTimer"
repeatInterval="2000">
<quartz:event-generator-job />
</quartz:inbound-endpoint>
<chaining-router>
<jdbc:outbound-endpoint queryKey="selectMules"
exchange-pattern="request-response" />
<collection-splitter />
<vm:outbound-endpoint path="Something"
exchange-pattern="one-way" />
</chaining-router>
</flow>
However, i keep gettnig a scheme error:
A Fatal error has occurred while the server was running: *
* cvc-complex-type.2.4.a: Invalid content was found starting with element *
* 'chaining-router'.
Now, i've checked and the relveant scehmes is loaded - my schemes are:
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring="http://www.springframework.org/schema/beans" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:stdio="http://www.mulesoft.org/schema/mule/stdio" xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz" xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf"
xmlns:script="http://www.mulesoft.org/schema/mule/scripting"
xmlns:pattern="http://www.mulesoft.org/schema/mule/pattern" xmlns:jdbc="http://www.mulesoft.org/schema/mule/jdbc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd
http://www.mulesoft.org/schema/mule/quartz http://www.mulesoft.org/schema/mule/quartz/3.2/mule-quartz.xsd
http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/3.2/mule-scripting.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/3.2/mule-http.xsd
http://www.mulesoft.org/schema/mule/stdio http://www.mulesoft.org/schema/mule/stdio/3.2/mule-stdio.xsd
http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/3.2/mule-cxf.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.mulesoft.org/schema/mule/pattern http://www.mulesoft.org/schema/mule/pattern/3.2/mule-pattern.xsd
http://www.mulesoft.org/schema/mule/jdbc http://www.mulesoft.org/schema/mule/jdbc/3.2/mule-jdbc.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/3.2/mule-vm.xsd">
Am i missing something??
Thanks!
The chaining-router is a legacy router designed to work with the old service element. In flows, use routing message processors instead.
In your case, you don't need any router to chain stuff together as message processors are automatically chained in a flow (provided endpoints are request-response, otherwise some dispatches happen asynchronously).