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.
Related
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>
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:file="http://www.mulesoft.org/schema/mule/file" 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.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/file http://www.mulesoft.org/schema/mule/file/current/mule-file.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
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
<mulexml:namespace-manager includeConfigNamespaces="true">
<mulexml:namespace prefix="ns0" uri="http://www.cpscreen.com/schemas"/>
</mulexml:namespace-manager>
<configuration doc:name="Configuration">
<expression-language autoResolveVariables="true">
<import class="org.mule.util.StringUtils" />
<import class="org.mule.util.ArrayUtils" />
</expression-language>
</configuration>
<flow name="user_provisions_-_xml_postFlow1" doc:name="user_provisions_-_xml_postFlow1">
<file:inbound-endpoint path="E:/temp/mule" responseTimeout="10000" doc:name="File">
<file:filename-regex-filter pattern="in_(.*).csv" caseSensitive="true"/>
</file:inbound-endpoint>
<file:file-to-string-transformer doc:name="File to String"/>
<expression-component doc:name="Expression"><![CDATA[java.util.List items = new java.util.ArrayList( Arrays.asList( payload.split("\n") ));
items.remove(0);;
java.lang.String listString = '';
for (String s : items) {
listString += s + "\n";
}
payload=listString.trim();]]></expression-component>
<http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="46908" path="userprovision" method="POST" doc:name="HTTP"/>
<object-to-string-transformer mimeType="text/xml" doc:name="Object to String"/>
<splitter expression="#[xpath('//UpdateUserRequest')]" doc:name="Splitter"/>
<logger message="Here is #[payload]" level="INFO" doc:name="Logger"/>
</flow>
</mule>
I am getting like,
WARN 2014-09-10 15:30:27,181 [[user_provisions_-_xml_post].user_provisions_-_xml_postFlow1.stage1.02] org.mule.routing.ExpressionSplitter: Splitter returned no results. If this is not expected, please check your split expression
Update :
I got where the issue is but I could resolve the split issue. Because of namespace in the XML splitter does not evaluate the split expression...
<?xml version="1.0" encoding="UTF-8"?>
<UpdateUserRequests xmlns="http://www.cpscreen.com/schemas">
<UpdateUserRequest userId="Test" account="Test" password="Test">
<User>
<Account id="4">34567</Account>
<UserId>Test</UserId>
<Profile>Admin</Profile>
<PersonName>
<GivenName>Sahak</GivenName>
<FamilyName>Kn</FamilyName>
</PersonName>
</User>
</UpdateUserRequest>
<UpdateUserRequest userId="Test" account="Test" password="Test">
<User>
<Account id="5">12345</Account>
<UserId>Test</UserId>
<Profile>Admin</Profile>
<PersonName>
<GivenName>Arun</GivenName>
<FamilyName>Kumar</FamilyName>
</PersonName>
</User>
</UpdateUserRequest>
</UpdateUserRequests>
If I remove xmlns="http://www.cpscreen.com/schemas" it is splitting to multiple
How do I add the spit expression if there is a namespace in the xml ?
Use the following expression to split the xml with namespace.
<splitter expression="#[xpath('//ns0:UpdateUserRequest')]" doc:name="Splitter"/>
The above expression works considering the "ns0" namespace is added in the Mule MXL namespace manager.
Hope this helps.
You should directly use the splitter after the file inbound endpoint ...
This expression works for splitting CSV file :-
<splitter expression="#[StringUtils.split(message.payload, '\n\r')]" doc:name="Splitter_For_MultipleRow"/>
And if your CSV files have a column headers like Name, Age etc .. you can use this :-
<splitter expression="#[rows=StringUtils.split(message.payload, '\n\r');ArrayUtils.subarray(rows,1,rows.size())]" doc:name="Splitter_For_MultipleRow"></splitter>
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" />
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.
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).