<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>redstream &#187; Maven</title>
	<atom:link href="http://www.redstream.nl/category/technical/maven/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.redstream.nl</link>
	<description>Pragmatic Integrators</description>
	<lastBuildDate>Fri, 27 Jan 2012 19:31:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Automagically deploy your web application using the Maven Cargo plugin.</title>
		<link>http://www.redstream.nl/2011/10/07/automagically-deploy-your-web-application-using-the-maven-cargo-plugin/</link>
		<comments>http://www.redstream.nl/2011/10/07/automagically-deploy-your-web-application-using-the-maven-cargo-plugin/#comments</comments>
		<pubDate>Fri, 07 Oct 2011 12:09:01 +0000</pubDate>
		<dc:creator>Pascal Prins</dc:creator>
				<category><![CDATA[Maven]]></category>

		<guid isPermaLink="false">http://www.redstream.nl/?p=2863</guid>
		<description><![CDATA[Last week I optimized the deployment process of a number of Mavenized projects. I noticed that the way I automated the project was not yet (fully) known by the developers. This is why I decided to write this blogpost. It &#8230; <a href="http://www.redstream.nl/2011/10/07/automagically-deploy-your-web-application-using-the-maven-cargo-plugin/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F10%2F07%2Fautomagically-deploy-your-web-application-using-the-maven-cargo-plugin%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F10%2F07%2Fautomagically-deploy-your-web-application-using-the-maven-cargo-plugin%2F&amp;source=redstreamlive&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Last week I optimized the deployment process of a number of Mavenized projects. I noticed that the way I automated the project was not yet (fully) known by the developers. This is why I decided to write this blogpost. </p>
<p>It appeared to be a true eyeopener for the developers. </p>
<p><span id="more-2863"></span></p>
<p>This example assumes that you have a local instance of <a href="http://tomcat.apache.org/" target="_blank">Apache Tomcat 7.x</a> running.</p>
<p>First, create a new project using Maven: </p>
<pre>
mvn archetype:create -DgroupId=nl.redstream.demo
                     -DartifactId=simplewebapp
                     -DarchetypeArtifactId=maven-archetype-webapp
</pre>
<p>Add the <a href="http://cargo.codehaus.org/" target="_blank">Cargo plugin</a> to the <code>pom.xml</code> (inside the <code>&lt;build&gt;</code> tag)</p>

<div class="wp_codebox"><table><tr id="p28636"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td class="code" id="p2863code6"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.codehaus.cargo<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>cargo-maven2-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.1.2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;phase<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>deploy<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/phase<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>deployer-redeploy<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;container<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;containerId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${mule.deploy.containerId}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/containerId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>remote<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/container<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>runtime<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;properties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;cargo.server.settings<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${mule.deploy.serverId}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/cargo.server.settings<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/properties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>The Cargo plugin is attached to the <code>deploy</code> lifecycle phase of Maven. Which means that the <code>deployer-redeploy</code> goal will be executed whenever you type: <code>mvn deploy</code>. The plugin uses the defined configuration at runtime. I used the <code>depoyer-redeploy</code> goal, because this goal will deploy your app if it is not yet deployed, and undeploy first when it is already deployed. More info on the Cargo plugin <a href="http://cargo.codehaus.org/" target="_blank">here</a>.</p>
<p>The properties will be resolved from your <code>settings.xml</code> in which we have defined several profiles: one for each target environment (i.e. develop, test, qa).</p>
<p>Here&#8217;s an example for a development environment (you can add the profiles for the other target environment yourself):</p>
<p>Add the following (inside the <code>&lt;profiles&gt;</code> tag) to your <code>~/.m2/settings.xml</code>:</p>

<div class="wp_codebox"><table><tr id="p28637"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code" id="p2863code7"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;profile<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>develop<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;properties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mule.deploy.containerId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>tomcat7x<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mule.deploy.containerId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>                
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mule.deploy.serverId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>develop<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mule.deploy.serverId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/properties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;activation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;activeByDefault<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>false<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/activeByDefault<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>env<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>dev<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/activation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/profile<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Also, add a <code><server></code> definition with id=develop (inside the <code>&lt;servers&gt;</code> tag):</p>

<div class="wp_codebox"><table><tr id="p28638"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p2863code8"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;server<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>develop<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;cargo.remote.uri<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://localhost:8080/manager/text<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/cargo.remote.uri<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;cargo.remote.username<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>deploy<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/cargo.remote.username<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;cargo.remote.password<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>deploy<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/cargo.remote.password<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/server<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>The trick here is to add the Cargo configuration to the server definition. The defined properties are used by Maven to automagically deploy your webapp. In this demo I used localhost, but it could also be a remote host.</p>
<p>Note that I used a username and password for the deployment process. Add these in your <code>$CATALINA_HOME/conf/tomcat-users.xml</code>:</p>

<div class="wp_codebox"><table><tr id="p28639"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p2863code9"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;user</span> <span style="color: #000066;">username</span>=<span style="color: #ff0000;">&quot;deploy&quot;</span> <span style="color: #000066;">password</span>=<span style="color: #ff0000;">&quot;deploy&quot;</span> <span style="color: #000066;">roles</span>=<span style="color: #ff0000;">&quot;manager-script&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></td></tr></table></div>

<p>Note: user <strong>_must_</strong> have the <code>manager-script</code> role!</p>
<p>Now, all that&#8217;s left is deploying your application by executing <code>mvn clean deploy -Denv=dev</code>. The property <code>env=dev</code> will activate the correct profile in your <code>settings.xml</code> and resolve the earlier mentioned properties. BUT, the <code>deploy</code> phase requires a <code>distributionManagement</code> tag in your <code>pom.xml</code>. Mine looks like this (PS: I use <a href="http://www.jfrog.com/products.php" title="JFrog Artifactory" target="_blank">JFrog Artifactory</a>):</p>

<div class="wp_codebox"><table><tr id="p286310"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code" id="p2863code10"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;distributionManagement<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;repository<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>artifactory<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://dev.foobar.local:8080/artifactory/libs-release-local/<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/repository<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;snapshotRepository<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>artifactory<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://dev.foobar.local:8080/artifactory/libs-snapshot-local<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/snapshotRepository<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/distributionManagement<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>After you&#8217;ve added this to your pom, you&#8217;re ready to deploy your application.</p>
<p>Result:</p>
<pre>
...
[INFO]
[INFO] --- cargo-maven2-plugin:1.1.2:deployer-redeploy (default) @ simplewebapp ---
[INFO] [mcat7xRemoteDeployer] [/Users/pprins/projects/sandbox/simplewebapp/target/simplewebapp.war] is not deployed. Doing a fresh deployment.
[INFO] [mcat7xRemoteDeployer] Deploying [/Users/pprins/projects/sandbox/simplewebapp/target/simplewebapp.war]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.569s
[INFO] Finished at: Fri Oct 07 13:20:24 CEST 2011
[INFO] Final Memory: 7M/554M
[INFO] ------------------------------------------------------------------------
</pre>
<p>Goto: http://localhost:8080/simplewebapp et voila: your web app!</p>
<p>A redeploy would look something like this:</p>
<pre>
...
[INFO] --- cargo-maven2-plugin:1.1.2:deployer-redeploy (default) @ simplewebapp ---
[INFO] [mcat7xRemoteDeployer] Redeploying [/Users/pprins/projects/sandbox/simplewebapp/target/simplewebapp.war]
[INFO] [mcat7xRemoteDeployer] Undeploying [/Users/pprins/projects/sandbox/simplewebapp/target/simplewebapp.war]
[INFO] [mcat7xRemoteDeployer] Deploying [/Users/pprins/projects/sandbox/simplewebapp/target/simplewebapp.war]
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.redstream.nl/2011/10/07/automagically-deploy-your-web-application-using-the-maven-cargo-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generate JAXB classes with Maven based on multiple schema’s</title>
		<link>http://www.redstream.nl/2011/01/14/generate-jaxb-classes-with-maven-based-on-multiple-schema%e2%80%99s/</link>
		<comments>http://www.redstream.nl/2011/01/14/generate-jaxb-classes-with-maven-based-on-multiple-schema%e2%80%99s/#comments</comments>
		<pubDate>Fri, 14 Jan 2011 12:47:03 +0000</pubDate>
		<dc:creator>Pascal Prins</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[JAXB]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[maven JAXB]]></category>

		<guid isPermaLink="false">http://www.redstream.nl/?p=2358</guid>
		<description><![CDATA[Earlier, we blogged about generating JAXB classes based on XSD files. However, sometimes we need multiple configurations with multiple XSD files. Previous blog posts did not cover this topic, so I thought I&#8217;d cover it in a seperate post. The solution &#8230; <a href="http://www.redstream.nl/2011/01/14/generate-jaxb-classes-with-maven-based-on-multiple-schema%e2%80%99s/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F01%2F14%2Fgenerate-jaxb-classes-with-maven-based-on-multiple-schema%25e2%2580%2599s%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.redstream.nl%2F2011%2F01%2F14%2Fgenerate-jaxb-classes-with-maven-based-on-multiple-schema%25e2%2580%2599s%2F&amp;source=redstreamlive&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Earlier, we blogged about generating JAXB classes based on XSD files. However, sometimes we need multiple configurations with multiple XSD files. Previous blog posts did not cover this topic, so I thought I&#8217;d cover it in a seperate post.</p>
<p>The solution is to add multiple executions for the <code>maven-jaxb2-plugin</code> plugin. Each <code>execution</code> is bound to the <code><a href="http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html">generate-resources</a></code> phase of the Maven build process. Now, each time the project is build, the executions kick in and the JAXB classes are generated.</p>
<p><span id="more-2358"></span></p>
<p>Behold the following configuration:</p>

<div class="wp_codebox"><table><tr id="p235812"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
</pre></td><td class="code" id="p2358code12"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.jvnet.jaxb2.maven2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>maven-jaxb2-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>0.7.0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>One<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;phase<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>generate-resources<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/phase<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>generate<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;schemaDirectory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${xsd.path}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/schemaDirectory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;schemaIncludes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
					<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;include<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>schema-1.xsd<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/include<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
					<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;include<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>schema-2.xsd<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/include<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/schemaIncludes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;readOnly<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>true<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/readOnly<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;removeOldOutput<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>true<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/removeOldOutput<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;verbose<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>true<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/verbose<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;extension<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>true<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/extension<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bindingDirectory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${jaxb.path}/<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bindingDirectory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bindingIncludes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
					<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bindingInclude<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>jaxb-bindings-one.xml<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bindingInclude<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bindingIncludes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Two<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;phase<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>generate-resources<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/phase<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>generate<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;schemaDirectory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${xsd.path}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/schemaDirectory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;schemaExcludes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
					<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exclude<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>schema-1.xsd<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exclude<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
					<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exclude<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>schema-2.xsd<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exclude<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/schemaExcludes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;readOnly<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>true<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/readOnly<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;removeOldOutput<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>false<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/removeOldOutput<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;forceRegenerate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>true<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/forceRegenerate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;verbose<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>true<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/verbose<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;extension<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>true<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/extension<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bindingDirectory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${jaxb.path}/<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bindingDirectory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bindingIncludes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
					<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bindingInclude<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>jaxb-bindings-two.xml<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bindingInclude<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bindingIncludes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Execution &#8220;One&#8221; will generate the JAXB classed for <code>schema-1.xsd</code> and <code>schema-2.xsd</code> (all other schema&#8217;s in path <code>${xsd.path}</code> will not be processed) and uses <code>jaxb-bindings-one.xml</code> as bindingfile. Execution &#8220;Two&#8221; uses all other XSD&#8217;s in directory <code>${xsd.path}</code> and uses <code>jaxb-bindings-two.xml</code>.</p>
<p>The trick is to use <code>removeOldOutput</code> properly. By default, this has the value <code>true</code> and will cause the <code>generateDirectory</code> to be deleted before the XJC binding compiler recompiles the source files. So, by default, the second execution will delete the result of the first execution before recompiling. Setting this to value <code>false</code> in the second execution solves our problem. Now, both configurations are executed successfully, each with its own binding file.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redstream.nl/2011/01/14/generate-jaxb-classes-with-maven-based-on-multiple-schema%e2%80%99s/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using a WAR module as dependency in Maven</title>
		<link>http://www.redstream.nl/2010/10/22/using-a-war-module-as-dependency-in-maven/</link>
		<comments>http://www.redstream.nl/2010/10/22/using-a-war-module-as-dependency-in-maven/#comments</comments>
		<pubDate>Fri, 22 Oct 2010 07:49:31 +0000</pubDate>
		<dc:creator>Pascal Alma</dc:creator>
				<category><![CDATA[Maven]]></category>
		<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://blog.redstream.nl/?p=1978</guid>
		<description><![CDATA[Today I created a Maven module which holds our integration tests. The disadvantage when holding these tests in your &#8216;normal&#8217; Maven modules is that the tests are fired every time the module is built (by you or your continuous integration &#8230; <a href="http://www.redstream.nl/2010/10/22/using-a-war-module-as-dependency-in-maven/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.redstream.nl%2F2010%2F10%2F22%2Fusing-a-war-module-as-dependency-in-maven%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.redstream.nl%2F2010%2F10%2F22%2Fusing-a-war-module-as-dependency-in-maven%2F&amp;source=redstreamlive&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Today I created a <a href="http://maven.apache.org/ ">Maven</a> module which holds our integration tests. The disadvantage when holding these tests in your &#8216;normal&#8217; Maven modules is that the tests are fired every time the module is built (by you or your continuous integration server like <a href="http://hudson-ci.org/">Hudson</a>). Since these tests take rather long to execute, developers tend to use the &#8216;<a href="http://maven.apache.org/plugins/maven-surefire-plugin/examples/skipping-test.html">skipTests=true</a>&#8216; option when they build the code, which is taking away a great part of one the main reasons why you should use Maven. See also <a href="http://docs.codehaus.org/display/MAVENUSER/Maven+and+Integration+Testing">this article</a> for more info about this subject.<span id="more-1978"></span><br />
So when creating this test module I ran into the situation where I wanted to test the code I had put in a Maven WAR module. The first thing I tried was adding the WAR module as a dependency to the integration test project and make use classes that are defined in the WAR module. The configuration looks like this:</p>

<div class="wp_codebox"><table><tr id="p197817"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p1978code17"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>nl.redstream.adapters<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>my-adapter<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.0-SNAPSHOT<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>war<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>test<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>However, this doesn&#8217;t work and this was where I started my search for a solution. One option to get it to work was to move the Java sources from the WAR module to a separate JAR module and include that in the WAR module. But that is a last resort because it ment quite some rework since I have to use multiple WAR modules as a dependency in this integration test module. The first option I tried out was to make use of the <a href="http://static.appfuse.org/maven-warpath-plugin">WarPath</a> plugin. Although it might be useful in some cases it didn&#8217;t work for me.<br />
The second option I tried was to make use of the war-overlay as described <a href="http://maven.apache.org/plugins/maven-war-plugin/examples/war-overlay.html">here</a>. I added the following to my project pom:</p>

<div class="wp_codebox"><table><tr id="p197818"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code" id="p1978code18"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;build<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.apache.maven.plugins<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>maven-war-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;webResources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;resource<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;directory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${basedir}/src/main/java<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/directory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filtering<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>true<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filtering<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/resource<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/webResources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;overlays<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;overlay</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;overlay<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>nl.redstream.adapters<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>my-adapter<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/overlay<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/overlays<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/build<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Although the result was a little better (I could see the classes in the WEB-INF of my WAR module were added to the integration test module) I still wasn&#8217;t able to refer to the classes in my integration tests&#8230;<br />
Then I ended up at <a href="http://ykyuen.wordpress.com/2009/10/30/maven-dependency-on-jarwar-package">this</a> page (I then realized I have been using this solution before but forgotten about it. So I hope by blogging it now I will remember it from now on). As described on the page I added to the pom of the WAR project the following:</p>

<div class="wp_codebox"><table><tr id="p197819"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code" id="p1978code19"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;build<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
...
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  ...
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>maven-war-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2.1-beta-1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attachClasses<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>true<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/attachClasses<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  ...
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
...
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/build<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>And now I can refer to the classes of my WAR module in the integration test module by adding the following dependency:</p>

<div class="wp_codebox"><table><tr id="p197820"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p1978code20"><pre class="xml" style="font-family:monospace;"> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>nl.redstream.adapters<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>my-adapter<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.0-SNAPSHOT<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;classifier<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>classes<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/classifier<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>test<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.redstream.nl/2010/10/22/using-a-war-module-as-dependency-in-maven/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Side-effects of using Maven3</title>
		<link>http://www.redstream.nl/2010/06/08/side-effects-of-using-maven3/</link>
		<comments>http://www.redstream.nl/2010/06/08/side-effects-of-using-maven3/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 08:32:09 +0000</pubDate>
		<dc:creator>Pascal Alma</dc:creator>
				<category><![CDATA[Maven]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[Maven3]]></category>

		<guid isPermaLink="false">http://blog.redstream.nl/?p=1870</guid>
		<description><![CDATA[After attending to Jason van Zyl&#8217;s session about Maven3 we decided to start using Maven 3 instead of the 2.2 we were using. Since it is fully backward compatible we made it run without making a change to our pom&#8217;s. &#8230; <a href="http://www.redstream.nl/2010/06/08/side-effects-of-using-maven3/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.redstream.nl%2F2010%2F06%2F08%2Fside-effects-of-using-maven3%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.redstream.nl%2F2010%2F06%2F08%2Fside-effects-of-using-maven3%2F&amp;source=redstreamlive&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>After attending to <a href="http://technology.amis.nl/blog/8061/an-evening-about-maven">Jason van Zyl&#8217;s session</a> about Maven3 we decided to start using Maven 3 instead of the 2.2 we were using. Since it is fully backward compatible we made it run without making a change to our pom&#8217;s. However, what this version does add is generate warnings for all kinds of &#8216;misconfigurations&#8217; in the poms. This does not lead to problems in this version but it might do so in future version, so it is better to solve this issues. <span id="more-1870"></span><br />
One warning we got was:</p>
<blockquote><p>
[WARNING]<br />
[WARNING] Some problems were encountered while building the effective model for nl.redstream.framework:rs-core:jar:2.0-SNAPSHOT<br />
[WARNING] &#8216;build.plugins.plugin.version&#8217; for org.apache.maven.plugins:maven-clean-plugin is missing. @<br />
[WARNING]<br />
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.<br />
[WARNING]<br />
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.<br />
[WARNING]</p></blockquote>
<p>So it appeared we forgot to mention the verion for the clean plugin, so I added the (latest) version to the pom like shown here and went on:</p>

<div class="wp_codebox"><table><tr id="p187022"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code" id="p1870code22"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.apache.maven.plugins<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>maven-clean-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2.4<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filesets<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fileset<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;directory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${basedir}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/directory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;includes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;include<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>derby.log<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/include<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;include<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>activemq-data<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/include<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;include<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>.mule<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/include<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;include<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>muleEmbeddedDB<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/include<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;include<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>out<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/include<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/includes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fileset<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filesets<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>However, after some time we noticed that some of our unit tests started to fail while they were valid and we hadn&#8217;t touched the code. After some investigation it appeared the problem was caused by the <code>maven-clean-plugin</code>. The version I chose (2.4) is not able to remove complete directories (or at least not with the configuration as we shown above). For some reason, until adding the version, the plugin was using version 2.2. and that does know how to handle my configuration. So I changed the version of the clean-plugin to 2.2 and my tests work like a charm without warnings of Maven.</p>
<p>So although Maven3 does work without a change it does not mean you won&#8217;t run into issues. But it must be said that we would run into this issue sooner or later without Maven3. So we would suggest to start using Maven3 (or at least give it a try) as it will only improve the quality of your builds (and runs much faster ;-).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redstream.nl/2010/06/08/side-effects-of-using-maven3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Combining Smooks with Mule</title>
		<link>http://www.redstream.nl/2010/04/23/combining-smooks-with-mule/</link>
		<comments>http://www.redstream.nl/2010/04/23/combining-smooks-with-mule/#comments</comments>
		<pubDate>Fri, 23 Apr 2010 06:10:38 +0000</pubDate>
		<dc:creator>Pascal Alma</dc:creator>
				<category><![CDATA[Maven]]></category>
		<category><![CDATA[Mule]]></category>
		<category><![CDATA[Smooks]]></category>

		<guid isPermaLink="false">http://blog.redstream.nl/?p=1722</guid>
		<description><![CDATA[For a new interface that we have to implement we have to transfrom a file with &#8216;character separated values&#8217; to a XML message. One way to obtain this transformation is by using Smooks. Smooks is an extensible framework for building &#8230; <a href="http://www.redstream.nl/2010/04/23/combining-smooks-with-mule/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.redstream.nl%2F2010%2F04%2F23%2Fcombining-smooks-with-mule%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.redstream.nl%2F2010%2F04%2F23%2Fcombining-smooks-with-mule%2F&amp;source=redstreamlive&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>For a new interface that we have to implement we have to transfrom a file with &#8216;character separated values&#8217; to a XML message. One way to obtain this transformation is by using <a href="http://www.smooks.org/mediawiki/index.php?title=Main_Page">Smooks</a>. Smooks is an extensible framework for building applications for processing XML and non XML<br />
data (CSV, EDI, Java etc) using Java. Although Smooks can run standalone, we want to combine it with our integration platform that is based on <a href="http://www.mulesoft.org/display/COMMUNITY/Home">Mule CE</a><span id="more-1722"></span>.<br />
After a short search we found a mavenized Smooks module <a href="svn.muleforge.org/smooks/trunk">here</a>. I made some little changes to the module so the dependencies are referring to Mule2.2.2-SNAPSHOT and Smooks1.3.1. After this I deployed the module to our company repository so it is ready for use. An example how to use the module will be posted next, so stay tuned.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redstream.nl/2010/04/23/combining-smooks-with-mule/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>First results evaluating Mule&#039;s Management Console</title>
		<link>http://www.redstream.nl/2010/04/09/first-results-evaluating-mules-management-console/</link>
		<comments>http://www.redstream.nl/2010/04/09/first-results-evaluating-mules-management-console/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 11:56:33 +0000</pubDate>
		<dc:creator>Pascal Alma</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[Mule]]></category>

		<guid isPermaLink="false">http://blog.redstream.nl/?p=1703</guid>
		<description><![CDATA[As I said before we were asked to check out the new Management Console of Mule. In this post I will show the steps I took to get the console up and running and the first results of the evaluation. &#8230; <a href="http://www.redstream.nl/2010/04/09/first-results-evaluating-mules-management-console/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.redstream.nl%2F2010%2F04%2F09%2Ffirst-results-evaluating-mules-management-console%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.redstream.nl%2F2010%2F04%2F09%2Ffirst-results-evaluating-mules-management-console%2F&amp;source=redstreamlive&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>As I <a href="http://www.redstream.nl/2010/03/31/evaluating-mule-management-console/">said before</a> we were asked to check out the new <a href="http://www.mulesoft.org/display/mmc/Overview+of+the+Management+Console">Management Console</a> of <a href="http://www.mulesoft.org/display/MULE2USER/Home">Mule</a>. In this post I will show the steps I took to get the console up and running and the first results of the evaluation.</p>
<ul>
<li>The first thing I had to fix was the fact that the Management Console only works with the Enterprise Edition. Luckily there is a 30 days trial available of the Enterprise Edition <a href="http://www.mulesoft.com/mule-esb-enterprise-trial-download">here</a>, so I started by downloading that one.<span id="more-1703"></span>
</li>
<li>Next issue was that I wanted to deploy my Mule application as a WAR on a <a href="http://tomcat.apache.org/">Tomcat</a> instance. To build this WAR I use <a href="http://maven.apache.org/">Maven</a> (of course) so I had to made the Enterprise Edition jars available as dependencies in my repository. Luckily this issue is foreseen by MuleSoft as the Enterprise Edition comes with a script called &#8216;populate_m2_repo&#8217; that adds all jars to the local repository. After running this script I was able to build my WAR file packed with the Mule EE jars.
</li>
<li>Next I had to add the Mule Agent to my war. To make this possible I added the agent.jar also to my local Maven repository by running the command:<br />
<blockquote><p>mvn install:install-file -DgroupId=org.mule.console -DartifactId=mmc-agent -Dversion=2.2.5 -Dpackaging=jar -Dfile=mmc-agent-2.2.5-ea.jar </p></blockquote>
</li>
<li>With the agent in my repository I just had to add the following dependencies to the pom of my WAR:

<div class="wp_codebox"><table><tr id="p170324"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code" id="p1703code24"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.mule.console<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>mmc-agent<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${mule.version}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.mulesource.muleesb<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>mule-core-ee<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${mule.version}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #808080; font-style: italic;">&lt;!-- 3rd party libs --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>quartz<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>quartz<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.5.2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.springframework<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>spring-webmvc<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${spring.version}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>By adding these dependencies my WAR will also contain the Mule Agent that is necessary for the console to monitor my Mule application.
</li>
<li>The next step was deploying the Management Console to the Tomcat server. This is as simple as uploading the WAR to the &#8216;webapps&#8217; directory. And after Tomcat has unpacked it and started it you can access it with the following address in your browser &#8216;http://localhost:8080/mmc-server-2.2.5-ea/&#8217; (of course only if you didn&#8217;t change any defaults) and you get the login screen:</li>
</ul>
<p><a href="http://www.redstream.nl/wp-content/uploads/2010/04/Screen-shot-2010-04-09-at-8.01.43-AM.png"><img src="http://www.redstream.nl/wp-content/uploads/2010/04/Screen-shot-2010-04-09-at-8.01.43-AM-300x176.png" alt="" title="Screen shot 2010-04-09 at 8.01.43 AM" width="300" height="176" class="alignnone size-medium wp-image-1709" /></a></p>
<p>After login in with &#8216;admin/admin&#8217; you can add your Mule application as a server:<br />
<a href="http://www.redstream.nl/wp-content/uploads/2010/04/Screen-shot-2010-04-09-at-8.02.33-AM.png"><img src="http://www.redstream.nl/wp-content/uploads/2010/04/Screen-shot-2010-04-09-at-8.02.33-AM-300x176.png" alt="" title="Screen shot 2010-04-09 at 8.02.33 AM" width="300" height="176" class="alignnone size-medium wp-image-1710" /></a></p>
<p>This gives you a lot of information about the machine/processes running that application:<br />
<a href="http://www.redstream.nl/wp-content/uploads/2010/04/Screen-shot-2010-04-09-at-8.03.05-AM.png"><img src="http://www.redstream.nl/wp-content/uploads/2010/04/Screen-shot-2010-04-09-at-8.03.05-AM-300x244.png" alt="" title="Screen shot 2010-04-09 at 8.03.05 AM" width="300" height="244" class="alignnone size-medium wp-image-1711" /></a></p>
<p>and<br />
<a href="http://www.redstream.nl/wp-content/uploads/2010/04/Screen-shot-2010-04-09-at-8.03.50-AM.png"><img src="http://www.redstream.nl/wp-content/uploads/2010/04/Screen-shot-2010-04-09-at-8.03.50-AM-300x133.png" alt="" title="Screen shot 2010-04-09 at 8.03.50 AM" width="300" height="133" class="alignnone size-medium wp-image-1712" /></a></p>
<p>Although all this (technical) information is nice to have I think one of the main benefits is found on the &#8216;Services&#8217; tab where you can audit, pause, start, etc. your individual service:<br />
<a href="http://www.redstream.nl/wp-content/uploads/2010/04/Screen-shot-2010-04-09-at-8.05.12-AM.png"><img src="http://www.redstream.nl/wp-content/uploads/2010/04/Screen-shot-2010-04-09-at-8.05.12-AM-300x254.png" alt="" title="Screen shot 2010-04-09 at 8.05.12 AM" width="300" height="254" class="alignnone size-medium wp-image-1713" /></a></p>
<p>For each service you can enable the &#8216;audit&#8217; option so each incoming and outgoing message is logged:<br />
<a href="http://www.redstream.nl/wp-content/uploads/2010/04/Screen-shot-2010-04-09-at-8.22.08-AM.png"><img src="http://www.redstream.nl/wp-content/uploads/2010/04/Screen-shot-2010-04-09-at-8.22.08-AM-300x214.png" alt="" title="Screen shot 2010-04-09 at 8.22.08 AM" width="300" height="214" class="alignnone size-medium wp-image-1716" /></a></p>
<p>Although it is an Early Access release, I haven&#8217;t found any issue with it, but maybe that&#8217;s because I only have done some basic routines :-) We will certainly look further into this and I expect the next build of the EA (with more functionality like &#8216;alerts&#8217;) to become available next week. I&#8217;ll keep you informed!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redstream.nl/2010/04/09/first-results-evaluating-mules-management-console/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Maven2 and com.sun.jmx.jmxri Dependency Problems</title>
		<link>http://www.redstream.nl/2010/02/24/maven2-and-com-sun-jmx-jmxri-dependency-problems/</link>
		<comments>http://www.redstream.nl/2010/02/24/maven2-and-com-sun-jmx-jmxri-dependency-problems/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 10:44:15 +0000</pubDate>
		<dc:creator>Pascal Prins</dc:creator>
				<category><![CDATA[Maven]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://blog.redstream.nl/?p=1648</guid>
		<description><![CDATA[I knew I solved this problem earlier: I just didn&#8217;t know how I solved it. That&#8217;s just why wiki&#8217;s and blogs are invented. The problem? One of the developers we&#8217;re currently coaching was getting started with the Mule ESB using &#8230; <a href="http://www.redstream.nl/2010/02/24/maven2-and-com-sun-jmx-jmxri-dependency-problems/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.redstream.nl%2F2010%2F02%2F24%2Fmaven2-and-com-sun-jmx-jmxri-dependency-problems%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.redstream.nl%2F2010%2F02%2F24%2Fmaven2-and-com-sun-jmx-jmxri-dependency-problems%2F&amp;source=redstreamlive&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>I knew I solved this problem earlier: I just didn&#8217;t know how I solved it. That&#8217;s just why wiki&#8217;s and blogs are invented.</p>
<p>The problem? One of the developers we&#8217;re currently coaching was getting started with the Mule ESB using the book <a href="http://www.manning.com/dossot/">Mule in Action</a> .</p>
<p>When trying to run the Maven-based samples that came with the book, Maven wasn&#8217;t able to find the <code>com.sun.jmx:jmxri:1.2.1</code> and <code>com.sun.jdmk:jmxtools:jar:1.2.1</code> dependency. Looking at our internal repository, only the related pom.xml appeared to be there (and not the jar).</p>
<p><span id="more-1648"></span></p>
<p>Investigating the dependencies of the samples, there was no direct dependency. So, it had to be an indirect dependency. Then it struck me: log4j ! The latest version (1.2.15) depends on these <code>com.sun.jmx</code> packages and you won&#8217;t be needing them for average logging scenario&#8217;s.</p>
<p>The solution is kinda pragmatic, but hey &#8230; it works! Look at your pom.xml, find the log4j dependency. Now, you have two options:</p>
<ol>
<li>If you depend on the latest version you have to exclude the following dependencies:

<div class="wp_codebox"><table><tr id="p164827"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code" id="p1648code27"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>log4j<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>log4j<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.2.15<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exclusions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exclusion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.sun.jmx<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>jmxri<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exclusion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exclusion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.sun.jdmk<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>jmxtools<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exclusion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exclusions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

</li>
<li>If no version is mentioned, add the version number:

<div class="wp_codebox"><table><tr id="p164828"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p1648code28"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>log4j<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>log4j<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.2.14<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

</li>
</ol>
<p><strong>Note:</strong> If you do need the <code>com.sun.jmx</code> dependencies. Download the libraries from the <span style="text-decoration: line-through;">Sun</span> Oracle website and upload them to your Maven repository.<br />
<strong>Disclaimer:</strong> you already noticed, but this solution only works if you have a direct dependency to log4j. Generic advice would be to find out if any indirect dependency exists and exlude it in your <code>pom.xml</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redstream.nl/2010/02/24/maven2-and-com-sun-jmx-jmxri-dependency-problems/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dynamic Routing in Mule</title>
		<link>http://www.redstream.nl/2010/01/12/dynamic-routing-in-mule/</link>
		<comments>http://www.redstream.nl/2010/01/12/dynamic-routing-in-mule/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 14:52:10 +0000</pubDate>
		<dc:creator>Pascal Alma</dc:creator>
				<category><![CDATA[Maven]]></category>
		<category><![CDATA[Mule]]></category>

		<guid isPermaLink="false">http://blog.redstream.nl/?p=1559</guid>
		<description><![CDATA[I needed Mule to determine the outbound endpoint based on the content of properties in my custom XML message. Although this might look as common functionality I couldn&#8217;t find a complete example for this on the net. This one was &#8230; <a href="http://www.redstream.nl/2010/01/12/dynamic-routing-in-mule/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.redstream.nl%2F2010%2F01%2F12%2Fdynamic-routing-in-mule%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.redstream.nl%2F2010%2F01%2F12%2Fdynamic-routing-in-mule%2F&amp;source=redstreamlive&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>I needed <a href="http://www.mulesoft.org/display/MULE/Home">Mule</a> to determine the outbound endpoint based on the content of properties in my custom XML message. Although this might look as common functionality I couldn&#8217;t find a complete example for this on the net. <a href="http://javatch.blogspot.com/2009/05/mule2x-expression-recipient-list-router.html">This one</a> was close, but didn&#8217;t match completely with my situation:<br />
I receive an XML message that is conform my own custom format. Based on the content of several fields in this XML message I determine what the next endpoint must be to process the message. Then my message is forwarded to that endpoint. <span id="more-1559"></span><br />
The &#8216;mule-config&#8217; for this looks like:</p>

<div class="wp_codebox"><table><tr id="p155933"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
</pre></td><td class="code" id="p1559code33"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mule</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.mulesource.org/schema/mule/core/2.2&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">xmlns:jms</span>=<span style="color: #ff0000;">&quot;http://www.mulesource.org/schema/mule/jms/2.2&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">xmlns:spring</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">xmlns:stdio</span>=<span style="color: #ff0000;">&quot;http://www.mulesource.org/schema/mule/stdio/2.2&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">xmlns:test</span>=<span style="color: #ff0000;">&quot;http://www.mulesource.org/schema/mule/test/2.2&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">xmlns:vm</span>=<span style="color: #ff0000;">&quot;http://www.mulesource.org/schema/mule/vm/2.2&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;</span>
<span style="color: #009900;">      http://www.mulesource.org/schema/mule/core/2.2 http://www.mulesource.org/schema/mule/core/2.2/mule.xsd</span>
<span style="color: #009900;">      http://www.mulesource.org/schema/mule/test/2.2 http://www.mulesource.org/schema/mule/test/2.2/mule-test.xsd</span>
<span style="color: #009900;">      http://www.mulesource.org/schema/mule/jms/2.2 http://www.mulesource.org/schema/mule/jms/2.2/mule-jms.xsd</span>
<span style="color: #009900;">      http://www.mulesource.org/schema/mule/stdio/2.2 http://www.mulesource.org/schema/mule/stdio/2.2/mule-stdio.xsd</span>
<span style="color: #009900;">      http://www.mulesource.org/schema/mule/vm/2.2 http://www.mulesource.org/schema/mule/vm/2.2/mule-vm.xsd</span>
<span style="color: #009900;">      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;spring:bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;routingComponent&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;nl.redstream.components.RoutingComponent&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;custom-transformer</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;JaxbXmlToCdmObject&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;nl.redstream.transformers.XmlToObjectJaxbTransformer&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;spring:property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jaxbContextPackage&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;nl.redstream.message.v01_0&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/custom-transformer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;custom-transformer</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;JaxbObjectToCdmXml&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;nl.redstream.transformers.ObjectToXmlJaxbTransformer&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;spring:property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jaxbContextPackage&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;nl.redstream.message.v01_0&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/custom-transformer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;jms:activemq-connector</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;JMSConnector&quot;</span> <span style="color: #000066;">specification</span>=<span style="color: #ff0000;">&quot;1.1&quot;</span> <span style="color: #000066;">dynamicNotification</span>=<span style="color: #ff0000;">&quot;true&quot;</span></span>
<span style="color: #009900;">                <span style="color: #000066;">brokerURL</span>=<span style="color: #ff0000;">&quot;failover:(vm://localhost?broker.persistent=true&amp;amp;broker.useJmx=false)&quot;</span></span>
<span style="color: #009900;">                <span style="color: #000066;">acknowledgementMode</span>=<span style="color: #ff0000;">&quot;AUTO_ACKNOWLEDGE&quot;</span></span>
<span style="color: #009900;">                <span style="color: #000066;">maxRedelivery</span>=<span style="color: #ff0000;">&quot;3&quot;</span></span>
<span style="color: #009900;">                <span style="color: #000066;">disableTemporaryReplyToDestinations</span>=<span style="color: #ff0000;">&quot;true&quot;</span></span>
<span style="color: #009900;">                <span style="color: #000066;">persistentDelivery</span>=<span style="color: #ff0000;">&quot;true&quot;</span></span>
<span style="color: #009900;">                <span style="color: #000066;">username</span>=<span style="color: #ff0000;">&quot;user&quot;</span></span>
<span style="color: #009900;">                <span style="color: #000066;">password</span>=<span style="color: #ff0000;">&quot;password&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;vm:endpoint</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;test_vm&quot;</span> <span style="color: #000066;">path</span>=<span style="color: #ff0000;">&quot;test-path&quot;</span> <span style="color: #000066;">synchronous</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;jms:endpoint</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;test_queue&quot;</span> <span style="color: #000066;">queue</span>=<span style="color: #ff0000;">&quot;test-queue&quot;</span> <span style="color: #000066;">connector-ref</span>=<span style="color: #ff0000;">&quot;JMSConnector&quot;</span> <span style="color: #000066;">synchronous</span>=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;model</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;mule-event-processing&quot;</span> <span style="color: #000066;">inherit</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;service</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;start-event-processor&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;inbound<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;vm:inbound-endpoint</span> <span style="color: #000066;">address</span>=<span style="color: #ff0000;">&quot;vm://event-processor&quot;</span> <span style="color: #000066;">synchronous</span>=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #000066;">transformer-refs</span>=<span style="color: #ff0000;">&quot;JaxbXmlToCdmObject&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/inbound<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;component<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;spring-object</span> <span style="color: #000066;">bean</span>=<span style="color: #ff0000;">&quot;routingComponent&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/component<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;outbound<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;custom-outbound-router</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;nl.redstream.router.DynamicRouter&quot;</span> <span style="color: #000066;">transformer-refs</span>=<span style="color: #ff0000;">&quot;JaxbObjectToCdmXml&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;spring:property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;evaluator&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;custom&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;spring:property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;customEvaluator&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;cdm-msg-property&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;spring:property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;expression&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;ADDRESS_LIST&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/custom-outbound-router<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/outbound<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/service<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;service</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;TEST&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;inbound<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;vm:inbound-endpoint</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;test_vm&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/inbound<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;echo-component</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;outbound<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;pass-through-router<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;jms:outbound-endpoint</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;test_queue&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/pass-through-router<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/outbound<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/service<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/model<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mule<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>This is what happens with this configuration: the message is received on the inbound endpoint of the &#8216;start-event-processor&#8217; service. The endpoint forwards the mesage to the component &#8216;RoutingComponent&#8217;. In this component the next inbound endpoint is determined and added as a property to the XML message. The code for the component looks like:</p>

<div class="wp_codebox"><table><tr id="p155934"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
</pre></td><td class="code" id="p1559code34"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">nl.redstream.components</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.ArrayList</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">nl.redstream.message.v01_0.Message</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">nl.redstream.message.v01_0.PropertySetType</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">nl.redstream.message.v01_0.PropertyType</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.log4j.Logger</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mule.api.transformer.TransformerException</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * Routes a Message to the correct Business Process by using message metadata
 *
 * @author pascal
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> RoutingComponent
<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">static</span> Logger logger <span style="color: #339933;">=</span> Logger.<span style="color: #006633;">getLogger</span><span style="color: #009900;">&#40;</span>RoutingComponent.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> Message routeMessage<span style="color: #009900;">&#40;</span>Message cdmMessage<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> TransformerException <span style="color: #009900;">&#123;</span>
        logger.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;routeMessage(Message cdmMessage)&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// Determin next inbound endpoint</span>
        <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> nextEndpoint <span style="color: #339933;">=</span> getBusinessProcess<span style="color: #009900;">&#40;</span>cdmMessage.<span style="color: #006633;">getMessageHeader</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.
                <span style="color: #006633;">getPropertySet</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// Set next endpoint</span>
        setAddressList<span style="color: #009900;">&#40;</span>nextEndpoint, cdmMessage<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// Return message</span>
        <span style="color: #000000; font-weight: bold;">return</span> cdmMessage<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> setAddressList<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> nextEndpoint, Message msg<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        List<span style="color: #339933;">&lt;</span>string<span style="color: #339933;">&gt;</span> addressList <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;</span>string<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        addressList.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>nextEndpoint<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        PropertyType prop <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PropertyType<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        prop.<span style="color: #006633;">setKey</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ADDRESS_LIST&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        prop.<span style="color: #006633;">setValue</span><span style="color: #009900;">&#40;</span>nextEndpoint<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        msg.<span style="color: #006633;">getMessageHeader</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getPropertySet</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getProperties</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>prop<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> getBusinessProcess<span style="color: #009900;">&#40;</span>PropertySetType propertySet<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// Access some logic to determine next matching BusinessProcess</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #0000ff;">&quot;test_vm&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>In the component the method &#8216;routeMessage&#8217; is called. In this method I determine what the next step is that has to be performed (in this example &#8220;test_vm&#8221; is hardcoded as next endpoint but this can easily be made more dynamically). Then the name of that endpoint is added as a property to the message header.<br />
Then the message is passed to my custom-outbound-router. It is a subclass of the &#8216;expression-recipient-list-router&#8217; and I made the method &#8216;isMatch&#8217; always returning true so no filter has to be used. The code for the router is very simple:</p>

<div class="wp_codebox"><table><tr id="p155935"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code" id="p1559code35"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">nl.redstream.router</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mule.api.MuleMessage</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mule.api.routing.RoutingException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mule.routing.outbound.ExpressionRecipientList</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 *
 * @author pascal
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> DynamicRouter <span style="color: #000000; font-weight: bold;">extends</span> ExpressionRecipientList <span style="color: #009900;">&#123;</span>
&nbsp;
    @Override
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> isMatch<span style="color: #009900;">&#40;</span>MuleMessage message<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> RoutingException <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>The actual inbound endpoint to which the message is transfered next is determined by making use of my custom evaluator (The creation and use of the custom evaluator is described <a href="http://www.redstream.nl/2010/01/02/create-your-own-expression-evaluator-in-mule/">here</a>. It also explains more about the used xml schema for my message). With this configuration in place it will use the property &#8216;ADDRESS_LIST&#8217; in the MessageHeader to obtain the endpoint. Since the dynamic-router in this example always return &#8216;test_vm&#8217; the message will be forwarded to that endpoint and be picked up by the &#8216;TEST&#8217; service. Here is a test class to test this example:</p>

<div class="wp_codebox"><table><tr id="p155936"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
</pre></td><td class="code" id="p1559code36"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">nl.redstream.components</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">nl.redstream.utils.FileUtils</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mule.api.MuleMessage</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mule.module.client.MuleClient</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mule.tck.FunctionalTestCase</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * Checks the dynamic routing
 *
 * @author pascal
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> RoutingComponentTest <span style="color: #000000; font-weight: bold;">extends</span> FunctionalTestCase <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">final</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> getConfigResources<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #0000ff;">&quot;config/test-dynamic-router-config.xml&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #008000; font-style: italic; font-weight: bold;">/**
     * Tests the correct handling of an exception.
     *
     * @throws Exception
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testReceivingEvent<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Exception</span></a> <span style="color: #009900;">&#123;</span>
        MuleMessage msg <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
        MuleClient client <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MuleClient<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        client.<span style="color: #006633;">dispatch</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;vm://event-processor&quot;</span>,
                FileUtils.<span style="color: #006633;">getFileAsString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;xml/example-msg.xml&quot;</span><span style="color: #009900;">&#41;</span>, <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Athread+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Thread</span></a>.<span style="color: #006633;">sleep</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1500</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        msg <span style="color: #339933;">=</span> client.<span style="color: #006633;">request</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;test_queue&quot;</span>, <span style="color: #cc66cc;">500</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        assertNotNull<span style="color: #009900;">&#40;</span>msg<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>This class sends an <a href="http://www.redstream.nl/wp-content/uploads/2010/01/example-msg.xml" >example message</a> to the event-processor. The message will be enriched with a property &#8216;ADDRESS_LIST&#8217; in the header that has the value &#8216;vm_test&#8217;. So  I expect a message on the queue &#8216;test_queue&#8217;. If it is not there the test fails, otherwise the router is working correctly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redstream.nl/2010/01/12/dynamic-routing-in-mule/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Combining Mule with a BPEL Engine</title>
		<link>http://www.redstream.nl/2009/12/18/combining-mule-with-a-bpel-engine/</link>
		<comments>http://www.redstream.nl/2009/12/18/combining-mule-with-a-bpel-engine/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 09:26:38 +0000</pubDate>
		<dc:creator>Pascal Alma</dc:creator>
				<category><![CDATA[BPEL]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[Mule]]></category>
		<category><![CDATA[SoapUI]]></category>
		<category><![CDATA[Web Service]]></category>
		<category><![CDATA[Netbeans]]></category>

		<guid isPermaLink="false">http://blog.redstream.nl/?p=1501</guid>
		<description><![CDATA[In my current project we are going to need a BPEL engine besides our Mule CE implementation. Actually, we will use Mule for our stateless communication between systems and use BPEL for the stateful processes. One of the possible frameworks &#8230; <a href="http://www.redstream.nl/2009/12/18/combining-mule-with-a-bpel-engine/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.redstream.nl%2F2009%2F12%2F18%2Fcombining-mule-with-a-bpel-engine%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.redstream.nl%2F2009%2F12%2F18%2Fcombining-mule-with-a-bpel-engine%2F&amp;source=redstreamlive&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>In my current project we are going to need a <a href="http://en.wikipedia.org/wiki/Business_Process_Execution_Language">BPEL</a> engine besides our <a href="http://www.mulesoft.org/display/MULE2INTRO/Home">Mule CE</a> implementation. Actually, we will use Mule for our stateless communication between systems and use BPEL for the stateful processes. One of the possible frameworks to use as a BPEL engine is <a href="http://ode.apache.org">Apache ODE</a>. In this post I will show you how you can start a BPEL process in Apache ODE with Mule. As you will see, it is merely a combination of posts I made earlier, but I think it is nice to have the complete thing in one post.<br />
<span id="more-1501"></span><br />
<strong>Step 0: Assumptions</strong>s<br />
Assumed is:</p>
<ul>
<li>an Apache ODE instance (preferably deployed in Tomcat)</li>
<li>Maven 2.2.0</li>
<li>JDK 1.6</li>
<li>Netbeans 6.8,</li>
<li>Mule CE 2.2.2-SNAPSHOT</li>
</ul>
<p>Of course, it might work with other version but these are the versions I used.</p>
<p><strong>Step 1: Create a running BPEL process</strong></p>
<p>The first step is to create a running BPEL example. I use the latest version of Netbeans for that and<br />
<a href="http://technology.amis.nl/blog/3355/running-a-bpel-process-created-with-netbeans-in-apache-ode">this post</a>. To make use of the SOA wizards in the new Netbeans you have to enable this as an extension as described <a href="http://www.redstream.nl/2009/12/15/creating-bpel-modules-using-netbeans-6-8/">here</a>.<br />
To create the BPEL example perform the following steps:</p>
<ol>
<li> Creating a new BPEL module named &#8216;TextModule&#8217;<br />
<img src="http://www.redstream.nl/wp-content/uploads/2009/12/bpel-module.jpg" alt="bpel-module" title="bpel-module" width="80%" class="alignnone size-full wp-image-1506" />
</li>
<li>Add a WSDL to the project</li>
<p> Add a WSDL that describes the web service (remark: I wasn&#8217;t able to create a document-literal web service with the wizard in Netbeans so I edited the source by hand afterwards). <a href="http://www.redstream.nl/wp-content/uploads/2009/12/TxtLengthService.wsdl">Here</a> is my WSDL.</p>
<li>Add a BPEL process to the module, name it &#8216;txtLengthProcess&#8217;<br />
<img src="http://www.redstream.nl/wp-content/uploads/2009/12/bpel-process1.jpg" alt="bpel-process" title="bpel-process" width="80%"  class="alignnone size-full wp-image-1511" /></p>
<p>This created process is empty so add functionality to it by following the guidelines as in <a href="http://technology.amis.nl/blog/3355/running-a-bpel-process-created-with-netbeans-in-apache-ode">this post</a>. I ended up with the following process diagram:<br />
<img src="http://www.redstream.nl/wp-content/uploads/2009/12/Screen-shot-2009-12-17-at-09.15.12.jpg"  width="100%" class="alignnone size-full wp-image-1511" /><br />
The mapping in the assignment step looks like this:<br />
<img src="http://www.redstream.nl/wp-content/uploads/2009/12/Screen-shot-2009-12-17-at-09.15.42.jpg" width="100%"  class="alignnone size-full wp-image-1511"/><br />
I created the necessary variables to assign the values to in the &#8216;receive&#8217; and &#8216;reply&#8217; step.
</li>
<li>Create a file &#8216;deploy.xml&#8217;<br />
My file has the following content:</p>

<div class="wp_codebox"><table><tr id="p150142"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code" id="p1501code42"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;deploy</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.apache.org/ode/schemas/dd/2007/03&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">xmlns:pns</span>=<span style="color: #ff0000;">&quot;http://www.redstream.nl/TxtLengthProcess&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">xmlns:wns</span>=<span style="color: #ff0000;">&quot;http://www.redstream.nl/TxtLengthService&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;process</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;pns:TxtLengthProcess&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;active<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>true<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/active<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;provide</span> <span style="color: #000066;">partnerLink</span>=<span style="color: #ff0000;">&quot;TxtLengthPartnerLink&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;service</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;wns:TxtLengthServiceService&quot;</span> <span style="color: #000066;">port</span>=<span style="color: #ff0000;">&quot;TxtLengthServicePort&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/provide<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/process<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/deploy<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

</li>
<li> Deploy it to the Tomcat instance that is running Apache ODE<br />
To deploy the process create a directory named &#8216;TxtLengthService&#8217; under &#8216;<tomcat-dir>/webapps/ode/WEB-INF/processes&#8217;. Copy the three files (deploy.xml, TxtLengthProcess.bpel and TxtLengthService.wsdl) to this directory. When your deployment was successful you’ll see the &#8216;TxtLengthService.wsdl&#8217; at http://localhost:8080/ode/services/listServices:<br />
<img src="http://www.redstream.nl/wp-content/uploads/2009/12/servicesList.jpg" alt="servicesList" title="servicesList" width="100%" class="alignnone size-full wp-image-1524" />
</li>
<li> (Optional) you can test the service with SoapUI<br />
With a successful request-response  you will get the following result:<br />
<img src="http://www.redstream.nl/wp-content/uploads/2009/12/soap-ui-call.jpg" alt="soap-ui-call" title="soap-ui-call" width="100%" class="alignnone size-full wp-image-1526" />
</li>
</ul>
<p>If you want more details on how to set up a Apache ODE service have look <a href="http://technology.amis.nl/blog/3355/running-a-bpel-process-created-with-netbeans-in-apache-ode">here</a>. It goes into more detail then I am in this post.</p>
<p><strong>Step 2: Generate Java client for web service to start ODE process</strong></p>
<p>We use Metro for this because we had <a href="http://www.redstream.nl/2009/07/01/mule2-cxf-and-serializable-classes/">some bad experiences</a> when using CXF for this. It is described <a href="http://www.redstream.nl/2009/03/14/make-serializable-jax-ws-clients-with-maven2/">here</a> how to do this in combination with Maven.<br />
I created a new Maven project with this <a href="http://www.redstream.nl/wp-content/uploads/2009/12/pom1.xml">&#8216;pom.xml&#8217;</a>.<br />
When the client is generated you can test it with a test class like this:</p>

<div class="wp_codebox"><table><tr id="p150143"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code" id="p1501code43"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">nl.redstream.ws.test</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">nl.redstream.txtlengthservice.TxtLengthService</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.Test</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 *
 * @author pascal
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TestService <span style="color: #009900;">&#123;</span>
&nbsp;
    @Test
     <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testIt<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        TxtLengthService service <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TxtLengthService<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> value <span style="color: #339933;">=</span> service.<span style="color: #006633;">getTxtLengthServiceSOAP11PortHttp</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">txtLengthOperation</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;RedStream&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;result = &quot;</span> <span style="color: #339933;">+</span> value<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><strong>Step 3: Create the Mule project</strong></p>
<p>To let Mule call the BPEL process I created a new Maven project that is able to test the call with a Mule client. The project is based on this <a href="http://www.redstream.nl/wp-content/uploads/2009/12/pom2.xml">&#8216;pom.xml&#8217;</a>.<br />
The used &#8216;ode-test-config.xml&#8217; looks like:</p>

<div class="wp_codebox"><table><tr id="p150144"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code" id="p1501code44"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mule</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.mulesource.org/schema/mule/core/2.2&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">xmlns:spring</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">xmlns:test</span>=<span style="color: #ff0000;">&quot;http://www.mulesource.org/schema/mule/test/2.2&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">xmlns:vm</span>=<span style="color: #ff0000;">&quot;http://www.mulesource.org/schema/mule/vm/2.2&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;</span>
<span style="color: #009900;">       http://www.mulesource.org/schema/mule/core/2.2 http://www.mulesource.org/schema/mule/core/2.2/mule.xsd</span>
<span style="color: #009900;">       http://www.mulesource.org/schema/mule/test/2.2 http://www.mulesource.org/schema/mule/test/2.2/mule-test.xsd</span>
<span style="color: #009900;">       http://www.mulesource.org/schema/mule/vm/2.2 http://www.mulesource.org/schema/mule/vm/2.2/mule-vm.xsd</span>
<span style="color: #009900;">       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;model</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;mule-ode&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;service</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;start&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;inbound<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;vm:inbound-endpoint</span> <span style="color: #000066;">path</span>=<span style="color: #ff0000;">&quot;msg-in&quot;</span> <span style="color: #000066;">synchronous</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/inbound<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;component</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;nl.redstream.mule.BpelProcessClient&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/service<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/model<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mule<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>The created component class that handles the call to the SOAP client looks like:</p>

<div class="wp_codebox"><table><tr id="p150145"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code" id="p1501code45"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">nl.redstream.mule</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">nl.redstream.txtlengthservice.TxtLengthService</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 *
 * @author pascal
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> BpelProcessClient <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> callProcess<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> request<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> TxtLengthService<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getTxtLengthServiceSOAP11PortHttp</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">txtLengthOperation</span><span style="color: #009900;">&#40;</span>request<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>And the used test class looks like:</p>

<div class="wp_codebox"><table><tr id="p150146"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
</pre></td><td class="code" id="p1501code46"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">nl.redstream.mule</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.Test</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mule.api.MuleException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mule.api.MuleMessage</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mule.module.client.MuleClient</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mule.tck.FunctionalTestCase</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> BpelProcessClientTest <span style="color: #000000; font-weight: bold;">extends</span> FunctionalTestCase <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> MuleClient client <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">protected</span> MuleClient getClient<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>client <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                client <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MuleClient<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>MuleException e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aruntimeexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">RuntimeException</span></a><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">return</span> client<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">final</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> getConfigResources<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #0000ff;">&quot;config/ode-test-config.xml &quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @Test
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testBpelTest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> MuleException
    <span style="color: #009900;">&#123;</span>
        MuleMessage msg <span style="color: #339933;">=</span> getClient<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">send</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;vm://msg-in&quot;</span>, <span style="color: #0000ff;">&quot;123456789012345&quot;</span>, <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;payload = &quot;</span> <span style="color: #339933;">+</span> msg.<span style="color: #006633;">getPayload</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>When the test class is executed this results in the following output:</p>
<blockquote><p>
**********************************************************************<br />
* Mule ESB and Integration Platform                                  *<br />
* Version: 2.2.2-SNAPSHOT Build: 15252                               *<br />
* MuleSource, Inc.                                                   *<br />
* For more information go to http://mule.mulesource.org              *<br />
*                                                                    *<br />
* Server started: 12/17/09 8:34 PM                                   *<br />
* Server ID: 3d3eb71b-eb43-11de-bca6-7b92b51f04e0                    *<br />
* JDK: 1.6.0_17 (mixed mode)                                         *<br />
* OS encoding: MacRoman, Mule encoding: UTF-8                        *<br />
* OS: Mac OS X (10.6.2, x86_64)                                      *<br />
* Host: macbook-van-pascal-alma.local (192.168.1.204)                *<br />
*                                                                    *<br />
* Agents Running: None                                               *<br />
**********************************************************************<br />
INFO  2009-12-17 20:34:50,730 [main] org.mule.module.client.MuleClient: Using existing MuleContext: org.mule.DefaultMuleContext@1d6b6c55<br />
INFO  2009-12-17 20:34:50,756 [main] org.mule.transport.vm.VMMessageDispatcher: Connected: endpoint.outbound.vm://msg-in<br />
payload = 15<br />
INFO  2009-12-17 20:34:51,784 [main] org.mule.transport.vm.VMConnector: Removing listener on endpointUri: vm://msg-in<br />
INFO  2009-12-17 20:34:51,784 [main] org.mule.transport.vm.VMMessageReceiver: Disconnected: VMMessageReceiver{this=5a56182f, receiverKey=msg-in, endpoint=vm://msg-in}<br />
INFO  2009-12-17 20:34:51,785 [main] org.mule.component.DefaultJavaComponent: Stopping: org.mule.component.DefaultJavaComponent component for: SedaService{start}<br />
INFO  2009-12-17 20:34:51,785 [main] org.mule.model.seda.SedaService: Mule Service start has been stopped successfully<br />
INFO  2009-12-17 20:34:51,787 [main] org.mule.transport.vm.VMConnector: Stopping: VMConnector{this=75d709a5, started=true, initialised=true, name=&#8217;connector.VM.0&#8242;, disposed=false, numberOfConcurrentTransactedReceivers=4, createMultipleTransactedReceivers=true, connected=true, supportedProtocols=[vm], serviceOverrides=null}<br />
INFO  2009-12-17 20:34:51,787 [main] org.mule.transport.vm.VMConnector: Disconnected: VMConnector{this=75d709a5, started=false, initialised=true, name=&#8217;connector.VM.0&#8242;, disposed=false, numberOfConcurrentTransactedReceivers=4, createMultipleTransactedReceivers=true, connected=false, supportedProtocols=[vm], serviceOverrides=null}<br />
INFO  2009-12-17 20:34:51,787 [main] org.mule.transport.vm.VMConnector: Stopped: VMConnector{this=75d709a5, started=false, initialised=true, name=&#8217;connector.VM.0&#8242;, disposed=false, numberOfConcurrentTransactedReceivers=4, createMultipleTransactedReceivers=true, connected=false, supportedProtocols=[vm], serviceOverrides=null}<br />
INFO  2009-12-17 20:34:51,788 [main] org.mule.util.queue.TransactionalQueueManager: Stopping ResourceManager<br />
INFO  2009-12-17 20:34:51,788 [main] org.mule.util.queue.TransactionalQueueManager: Stopped ResourceManager<br />
INFO  2009-12-17 20:34:51,788 [main] org.mule.transport.vm.VMConnector: Disposing: VMConnector{this=75d709a5, started=false, initialised=true, name=&#8217;connector.VM.0&#8242;, disposed=false, numberOfConcurrentTransactedReceivers=4, createMultipleTransactedReceivers=true, connected=false, supportedProtocols=[vm], serviceOverrides=null}<br />
INFO  2009-12-17 20:34:51,788 [main] org.mule.transport.vm.VMMessageDispatcher: Disconnected: VMMessageDispatcher{this=1915470e, endpoint=vm://msg-in, disposed=false}<br />
INFO  2009-12-17 20:34:51,788 [main] org.mule.transport.vm.VMConnector: Disposed: VMConnector{this=75d709a5, started=false, initialised=false, name=&#8217;connector.VM.0&#8242;, disposed=true, numberOfConcurrentTransactedReceivers=4, createMultipleTransactedReceivers=true, connected=false, supportedProtocols=[vm], serviceOverrides=null}<br />
INFO  2009-12-17 20:34:51,789 [main] org.mule.config.spring.MuleApplicationContext: Closing org.mule.config.spring.MuleApplicationContext@356f144c: display name [org.mule.config.spring.MuleApplicationContext@356f144c]; startup date [Thu Dec 17 20:34:49 CET 2009]; root of context hierarchy<br />
INFO  2009-12-17 20:34:51,789 [main] org.springframework.beans.factory.support.DefaultListableBeanFactory: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@29abc69: defining beans [customEditorConfigurer,_muleObjectNameProcessor,_mulePropertyPlaceholderProcessor, _muleSimpleRegistryBootstrap,_muleNotificationManager,_muleConfiguration,._muleNotificationManager: notification.1,._muleNotificationManager:notification.2,._muleNotificationManager:notification.3, ._muleNotificationManager:notification.4,._muleNotificationManager:notification.5,._muleNotificationManager: notification.6,._muleNotificationManager:notification.7,._muleNotificationManager:notification.8, ._muleNotificationManager:notification.9,._muleNotificationManager:notification.10,_muleSystemModel, _muleQueueManager,_muleSecurityManager,_muleProperties,_muleEndpointFactory,_muleStreamCloserService, _defaultThreadingProfile,_defaultMessageDispatcherThreadingProfile,_defaultMessageRequesterThreadingProfile, _defaultMessageReceiverThreadingProfile,_defaultServiceThreadingProfile,_defaultRetryPolicyTemplate, mule-ode,start,.start:inbound.11,.start:inbound.11:inbound-endpoint.12,.start:component.13]; root of factory hierarchy<br />
INFO  2009-12-17 20:34:51,995 [main] org.mule.DefaultMuleContext:<br />
**********************************************************************<br />
* Mule shut down normally on: 12/17/09 8:34 PM                       *<br />
* Server was up for: 0 days, 0 hours, 0 mins, 1.318 sec              *<br />
**********************************************************************<br />
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.103 sec
</p></blockquote>
<p>So by finishing this post you should be able to execute a (simple) BPEL process in Apache ODE by using Mule. However, it is not certain we will use Apache ODE like this. I think we would like <a href="http://www.intalioworks.com/products/bpm/opensource-edition/server/">Intalio|server</a> more because of the handy features/tooling they have added to Apache ODE.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redstream.nl/2009/12/18/combining-mule-with-a-bpel-engine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deploying with Maven2 to a remote JBoss instance</title>
		<link>http://www.redstream.nl/2009/12/06/deploying-with-maven2-to-a-remote-jboss-instance/</link>
		<comments>http://www.redstream.nl/2009/12/06/deploying-with-maven2-to-a-remote-jboss-instance/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 10:07:09 +0000</pubDate>
		<dc:creator>Pascal Alma</dc:creator>
				<category><![CDATA[JBoss]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[JBoss AS]]></category>

		<guid isPermaLink="false">http://www.pascalalma.net/?p=962</guid>
		<description><![CDATA[Some time ago I already explained how you could use Maven and the jboss-plugin to deploy your war or ear to your JBoss server. Now this works fine as long as your JBoss is a local installation running on the &#8230; <a href="http://www.redstream.nl/2009/12/06/deploying-with-maven2-to-a-remote-jboss-instance/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.redstream.nl%2F2009%2F12%2F06%2Fdeploying-with-maven2-to-a-remote-jboss-instance%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.redstream.nl%2F2009%2F12%2F06%2Fdeploying-with-maven2-to-a-remote-jboss-instance%2F&amp;source=redstreamlive&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://www.redstream.nl/2008/02/03/creating-an-ejb3-webservice-with-maven2-running-on-jboss-421/">Some time ago</a> I already explained how you could use <a href="http://maven.apache.org">Maven</a> and the <a href="http://mojo.codehaus.org/jboss-maven-plugin/">jboss-plugin</a> to deploy your war or ear to your <a href="http://www.jboss.org/jbossas/">JBoss</a> server. Now this works fine as long as your JBoss is a local installation running on the same machine as the one that is running Maven.<br />
Of course there is a big chance that this is not the case in your development environment. <span id="more-962"></span>In that case you can do the following in Maven to deploy your ear to the JBoss instance:</p>
<ol>
<li>Transfer the war or ear file to the remote machine</li>
<li>Run a script on the remote machine</li>
</ol>
<p>Actually it isn&#8217;t doing anything JBoss specific, so you could use it for other application servers too (like Tomcat, at least when they are using hot deployment).<br />
To perform step 1 you have to add the following plugin in your &#8216;pom.xml&#8217;:</p>

<div class="wp_codebox"><table><tr id="p96251"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
</pre></td><td class="code" id="p962code51"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;build<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.codehaus.mojo<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>wagon-maven-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.0-beta-1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>upload-artifact<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;phase<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>deploy<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/phase<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>upload<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;serverId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${project.deploy.serverId}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/serverId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fromDir<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>target<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fromDir<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;includes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>*.war<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/includes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${project.deploy.url}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;toDir<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${project.deploy.toDir}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/toDir<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    ...
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/build<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>And this plugin needs the &#8216;distributionManagement&#8217; section to be filled like this:</p>

<div class="wp_codebox"><table><tr id="p96252"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code" id="p962code52"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;distributionManagement<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;repository<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>m2-internal-repo<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://local.redstream.nl:8888/artifactory/libs-releases-local/<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/repository<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;snapshotRepository<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>m2-internal-repo<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://local.redstream.nl:8888/artifactory/libs-snapshots-local<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/snapshotRepository<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/distributionManagement<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>The second step is a bit more complicated. I want to execute a script on the remote server using SSH. This can rather easily be done by using an Ant target, so to get this working in Maven we have to use the plugin to run an Ant target. It will ook like this:</p>

<div class="wp_codebox"><table><tr id="p96253"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
</pre></td><td class="code" id="p962code53"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.apache.maven.plugins<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>maven-antrun-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.3<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.apache.ant<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>ant-jsch<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.7.1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.jcraft<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>jsch<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>0.1.41<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
           <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
             <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>deploy-artifact<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
             <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;phase<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>deploy<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/phase<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
             <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
               <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>run<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
             <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
             <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
               <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tasks<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sshexec</span> <span style="color: #000066;">host</span>=<span style="color: #ff0000;">&quot;${project.deploy.host}&quot;</span></span>
<span style="color: #009900;">                                  <span style="color: #000066;">username</span>=<span style="color: #ff0000;">&quot;${projecte.deploy.username}&quot;</span></span>
<span style="color: #009900;">                                  <span style="color: #000066;">password</span>=<span style="color: #ff0000;">&quot;${project.deploy.password}&quot;</span></span>
<span style="color: #009900;">                                  <span style="color: #000066;">trust</span>=<span style="color: #ff0000;">&quot;true&quot;</span></span>
<span style="color: #009900;">                                 <span style="color: #000066;">command</span>=<span style="color: #ff0000;">&quot;bin/deploy_web.sh&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
               <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tasks<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
             <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
           <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Thta&#8217;s it. These two plugins together do the job. For completeness I show the used properties that I have setup in my &#8216;settings.xml&#8217;:</p>

<div class="wp_codebox"><table><tr id="p96254"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code" id="p962code54"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;profiles<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;profile<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>develop<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;properties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;project.deploy.serverId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>mule-server<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mule.deploy.serverId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;project.deploy.url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>scp://mule-server<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mule.deploy.url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;project.deploy.toDir<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/home/pascal<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mule.deploy.toDir<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;project.deploy.host<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>mule-server<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mule.deploy.host<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;project.deploy.username<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>pascal<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mule.deploy.username<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;project.deploy.password<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>pascal<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mule.deploy.password<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/properties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/profile<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  ...
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/profiles<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>And the script that is executed at the remote server &#8216;deploy_web.sh&#8217;:<br />
[code]<br />
#<br />
# Deploy Mule applications<br />
#<br />
#<br />
source /etc/profile</p>
<p>echo "Start deploying"</p>
<p>for archive in ~/deploy/*.war; do<br />
  echo "Copying to tomcat: web-archive \"$archive\""<br />
  cp $archive /$TOMCAT_HOME/webapps/<br />
done</p>
<p>echo "Deploying finished"</p>
<p>echo "Clean up ~/deploy directory"<br />
rm -rf ~/deploy/*.war<br />
[/code]<br />
If all this is in place you can deploy the ear/war file by using the command:<br />
<code>mvn clean deploy</code><br />
Like I said before there is nothing JBoss specific to this and actually I am using the script to deploy my Mule applications to our Tomcat server.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redstream.nl/2009/12/06/deploying-with-maven2-to-a-remote-jboss-instance/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
	</channel>
</rss>

