Recent Posts
Archives

Archive for the ‘en-US’ Category

PostHeaderIcon Equivalent of ‘ps’ in MS-DOS

What is the equivalent of Unix’ ps in MS-DOS, to be used in a .BAT script?

Let’s use %tasklist%.
eg:
[java]tasklist /fi "IMAGENAME eq java.exe" /FI "MEMUSAGE gt 100000"
Image Name PID Session Name Session# Mem Usage
========================= ====== ================ ======== ============
java.exe 9972 Console 0 212,932 K
java.exe 9640 Console 0 219,328 K
java.exe 11040 Console 0 213,432 K
java.exe 11144 Console 0 214,232 K\[/java]

PostHeaderIcon Start Mule ESB as an NT service under a Windows server

Case

You would like to start a Mule ESB instance as an NT service, under a Windows server. You would also like to give a specific name and description

Fix

  • add an environment variable MULE_HOME, with value the path of Mule install, for instance: C:\jonathan\mule-standalone-3.0.1
  • edit the file %MULE_HOME%\conf\wrapper.conf
  • replace the following properties default values:
    [java]wrapper.ntservice.name=%MULE_APP%
    wrapper.ntservice.displayname=%MULE_APP_LONG%
    wrapper.ntservice.description=%MULE_APP_LONG%[/java]
  • (you can also set other properties related to NT service configuration)
  • launch the command:
  • [java]%MULE_HOME%\bin\mule.bat install -config %MULE_HOME%\bin\mule-conf.xml[/java]

  • then you can see in the administration services that the service has started
  • to remove the service, only launch the following command
  • [java]%MULE_HOME%\bin\mule.bat remove[/java]

Known issue:

On certain installations (among them the servers on which CygWin is installed), a conflict may happen between the files %MULE_HOME%\bin\mule (standard launcher for Unix and Linux) and %MULE_HOME%\bin\mule.bat (standard launcher for Windows). In this case, rename %MULE_HOME%\bin\mule as %MULE_HOME%\bin\mule.OLD

PostHeaderIcon How to access global variables in Mule 3?

Case

In Mule 2.2.1, getting the global variables was allowed. Therefore, such a block worked:

[xml]
<add-message-property key="jonathanProperty"
value="#[groovy:MULE_ORIGINATING_ENDPOINT]" />[/xml]

In Mule 3, this is no more possible. Therefore, how to access -former- global variables within a Mule 3 config file?

Fix

Access the global variables owing to their scope, such as Invocation, Inbound, Outbound, Session, thanks to the methods MuleMessage.get<Scope>Property(), eg:

[xml]<add-message-property key="jonathanProperty"
value="#[groovy:message.getInboundProperty(&quot;MULE_ORIGINATING_ENDPOINT&quot;)]" />[/xml]

PostHeaderIcon BEA / JMSExceptions 045101

Case

I used a RuntimeTest to send a JMS message on a WebLogic application, with native WebLogic hosting of the queues, distributed queues to me more accurate. The test was OK.
I clustered the application. When I execute the same test, I get the following error:

[java][JMSExceptions:045101]The destination name passed to createTopic or createQueue "JONATHAN_LALOU_JMS_DISTRIBUTED_QUEUE" is invalid. If the destination name does not contain a "/" character then it must be the name of a distributed destination that is available in the cluster to which the client is attached. If it does contain a "/" character then the string before the "/" must be the name of a JMSServer or a ".". The string after the "/" is the name of a the desired destination. If the "./" version of the string is used then any destination with the given name on the local WLS server will be returned.[/java]

Fix

Since the message error is rather explicit, I tried to add a slash ('/') or a dot ('.') or both ('./'), but none worked.
To fix the issue, you have to prefix the queue name with the JMS module name and an exclamation mark ('!'), in the RuntimeTest configuration file, eg replace:

[xml]<property name="defaultDestinationName" value="JONATHAN_LALOU_JMS_DISTRIBUTED_QUEUE"/>[/xml]

with:

[xml]<property name="defaultDestinationName" value="JmsWeblogicNatureModule!JONATHAN_LALOU_JMS_DISTRIBUTED_QUEUE"/>[/xml]

PostHeaderIcon Presentation on Mule and the ESBs

On December 13th, I led a presentation about the ESBs and especially Mule.
Here is the presentation file, available under licence Creative Commons CC-by-cc, hosted by Google Docs.

PostHeaderIcon Crash of Eclipse 3.6.1 on Linux x86 64 bits, because of OSGi file locking

Case:

On launching Eclipse 3.6.1 under Linux 64bits, I get the following error:

[java]Locking is not possible in the directory "/opt/eclipse/configuration/org.eclipse.osgi". A common reason is that the file system or Runtime Environment does not support file locking for that location. Please choose a different location, or disable file locking passing "-Dosgi.locking=none" as a VM argument. /opt/eclipse/configuration/org.eclipse.osgi/.manager/.fileTableLock (Permission denied)[/java]

Fix:

Edit /opt/eclipse/eclipse.ini, add or move the line:

[java]-Dosgi.locking=none[/java]

at the end of the file, or at least after the argument -vmargs

PostHeaderIcon Filter too large files in Mule ESB

Case

You use a filter connector in Mule ESB 2.2.1, to perform any operation (let’s say: to send them on JMS, but this does not matter). You would like to filter files owing to their size, ie stop the handling of files larger than 10,000,000 bytes for instance.

We assume the files you handle are text files (not binary).

Solution

In your Mule XML config file, add the following block, using a short Groovy script:

[xml]<message-properties-transformer name="add-properties">
<add-message-property key="fileSizeOK"
value="#[groovy:message.getPayload().size() &lt; 10000000]" />
</message-properties-transformer>[/xml]
In the tag <file:inbound-endpoint>, add the attribute: transformer-refs="add-properties"
Now, add a tag <message-property-filter pattern="fileSizeOK=true"/>. Your outbound should then be similar to:[xml] <outbound>
<filtering-router>
<jms:outbound-endpoint queue="lalou.jonathan.jms.queue"
connector-ref="jmsConnector"/>
<message-property-filter pattern="fileSizeOK=true"/>
</filtering-router>
<forwarding-catch-all-strategy>
<file:outbound-endpoint path="/my/folder/"
connector-ref="fileConnector" outputPattern="error/#[header:originalFilename].too_big.#[function:dateStamp:yyyyMMdd_HHmmss_SSSSS].KO" />
</forwarding-catch-all-strategy>
</outbound>[/xml]

Many thanks to Vincent N. for his help.

PostHeaderIcon Tutorial: Re-package Mule ESB as a standalone client

Case

You have to deliver Mule 2.2.1 as a standalone application, or, more accurately, as a simple archive ready-to-use by someone else (customer, co-team worker, etc.).

In this tutorial, we assume that:

  • you have to include external jars, eg. MQ and WebLogic jars
  • you have written your XML configuration file for Mule, of which all properties are externalized in an external property file. We don’t mind the actual workflow, we assume you’re skilled enough with Mule 😉

Build

Prerequisites

Prior to building standalone:

  • get Mule ESB 2.2.1 standalone archive, available on MuleSoft website
  • get the JARs needed by MQ
    • providerutil.jar
    • fscontext.jar
    • dhbcore.jar
    • connector.jar
    • commonservices.jar
    • com.ibm.mqjms.jar
    • com.ibm.mq.jar
  • get WebLogic’s wlfullclient.jar
  • install the zip and the jars on your local repository:
    mvn install:install-file -DgroupId=org.mulesource -DartifactId=mule-esb -Dversion=2.2.1 -Dpackaging=zip -Dfile=mule-standalone-2.2.1.zip
    mvn install:install-file -Dfile=wlfullclient.jar  -DgroupId=weblogic -DartifactId=wlfullclient -Dversion=10.3 -Dpackaging=jar -DgeneratePom=true
    mvn install:install-file -Dfile=fscontext.jar  -DgroupId=fscontext -DartifactId=fscontext -Dversion=1.2 -Dpackaging=jar -DgeneratePom=true
    mvn install:install-file -Dfile=providerutil.jar  -DgroupId=fscontext -DartifactId=providerutil -Dversion=1.2 -Dpackaging=jar -DgeneratePom=true
    mvn install:install-file -DgroupId=mq -DartifactId=com.ibm.mq -Dversion=6.0.2.0 -Dpackaging=jar -Dfile=com.ibm.mq.jar
    mvn install:install-file -DgroupId=mq -DartifactId=com.ibm.mqjms -Dversion=6.0.2.0 -Dpackaging=jar -Dfile=com.ibm.mqjms.jar
    mvn install:install-file -DgroupId=mq -DartifactId=dhbcore -Dversion=6.0.2.0 -Dpackaging=jar -Dfile=dhbcore.jar
    mvn install:install-file -DgroupId=mq -DartifactId=commonservices -Dversion=6.0.2.0 -Dpackaging=jar -Dfile=commonservices.jar
    mvn install:install-file -DgroupId=connector -DartifactId=connector -Dversion=1.0 -Dpackaging=jar -Dfile=connector.jar

Files to be edited

  • Create a mule-jonathan.xml file in src/main/resources/ folder.
  • Externalize all properties in mule-jonathan.properties file in src/main/resources/ folder. As you may anticipate it, you will have add this property file in Mule classpath
  • To perform that:
    • Copy the wrapper.conf of Mule standalone archive as src/main/resources/wrapper.conf
    • After the line:[java]wrapper.java.classpath.3=%MULE_HOME%/lib/boot/*.jar[/java]

      , add the line:

      [java]wrapper.java.classpath.4=%MULE_HOME%/etc[/java]

  • in src/main/resources/, create a file start-mule-jonathan.bat, with the content:[java]
    set MULE_HOME=%CD%
    cd %MULE_HOME%\bin
    mule.bat -config mule-jonathan.xml
    [/java]

Maven

Here is the pom.xml of our project:

[xml]
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>lalou-jonathan</groupId>
<artifactId>jonathan-parent</artifactId>
<version>1.0</version></parent>
<modelVersion>4.0.0</modelVersion>
<groupId>lalou.jonathan</groupId>
<artifactId>jonathan-lalou-standalone-esb</artifactId>
<packaging>jar</packaging>
<version>${jonathan.version}</version>
<name>jonathan-lalou-standalone-esb</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.mulesource</groupId>
<artifactId>mule-esb</artifactId>
<version>2.2.1</version>
<type>zip</type></dependency>
<dependency>
<groupId>weblogic</groupId>
<artifactId>wlfullclient</artifactId>
<version>10.3</version></dependency>
<dependency>
<groupId>fscontext</groupId>
<artifactId>fscontext</artifactId>
<version>1.2</version></dependency>
<dependency>
<groupId>fscontext</groupId>
<artifactId>providerutil</artifactId>
<version>1.2</version></dependency>
<dependency>
<groupId>mq</groupId>
<artifactId>com.ibm.mq</artifactId>
<version>6.0.2.0</version></dependency>
<dependency>
<groupId>mq</groupId>
<artifactId>com.ibm.mqjms</artifactId>
<version>6.0.2.0</version></dependency>
<dependency>
<groupId>mq</groupId>
<artifactId>commonservices</artifactId>
<version>6.0.2.0</version></dependency>
<dependency>
<groupId>mq</groupId>
<artifactId>dhbcore</artifactId>
<version>6.0.2.0</version></dependency>
<dependency>
<groupId>connector</groupId>
<artifactId>connector</artifactId>
<version>1.0</version></dependency></dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>**/*</exclude></excludes></resource></resources>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-2</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor></descriptors></configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

[/xml]

Maven Assembly

We will use Maven Assembly: this plugin allows unpack archives, copy files, insert files, delete folders, etc.

Here is the assembly.xml file that should be located in src/main/assembly/ folder of your project. The code is commented so that you understand what we do.

[xml]
<assembly xmlns="http://maven.apache.org/xsd/1.1.0/assembly" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/xsd/assembly-1.1.2.xsd http://maven.apache.org/xsd/1.1.2/assembly">
<id/>
<baseDirectory>jonathan-lalou-standalone-esb-${version}</baseDirectory>
<formats>
<format>zip</format></formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<includes>
<include>org.mulesource:mule-esb</include></includes>
<unpack>true</unpack>
<unpackOptions>
<excludes>
<!– excluse original wrapper.conf, to include our tuned wrapper.conf–>
<exclude>**/conf/wrapper.conf</exclude>
<!–remove the these folders, useless in a standalone client–>
<exclude>**/examples/**</exclude>
<exclude>**/docs/**</exclude>
<exclude>**/src/**</exclude></excludes></unpackOptions></dependencySet>
<dependencySet>
<outputDirectory>mule-standalone-2.2.1/lib/user</outputDirectory>
<excludes>
<exclude>org.mulesource:mule-esb</exclude></excludes></dependencySet></dependencySets>
<fileSets>
<fileSet>
<directory>${basedir}/src/main/resources</directory>
<outputDirectory>/mule-standalone-2.2.1/etc</outputDirectory>
<includes>
<!–include the property file –>
<include>**/*jonathan*.properties</include></includes></fileSet>
<fileSet>
<directory>${basedir}/src/main/resources</directory>
<outputDirectory>/mule-standalone-2.2.1/bin</outputDirectory>
<includes>
<!– include Mule XML config file–>
<include>**/*jonathan*.xml</include></includes></fileSet>
<fileSet>
<directory>${basedir}/src/main/resources</directory>
<outputDirectory>/mule-standalone-2.2.1/conf</outputDirectory>
<includes>
<!– modified wrapper.conf to stake in account the etc/ folder, containing the property file–>
<include>**/wrapper.conf</include></includes></fileSet>
<fileSet>
<directory>${basedir}/src/main/resources</directory>
<outputDirectory>/mule-standalone-2.2.1/</outputDirectory>
<includes>
<include>**/*-mule-jonathan.bat</include>
</includes>
</fileSet>
</fileSets>
</assembly>

[/xml]

Build process

To build go to the folder yourproject/jonathan, then launch a mvn clean install. A complete installation package is output on target folder: jonathan-lalou-standalone-esb-1.0.zip.

The archive is built thanks to Maven Assembly plugin.

Install

Install

Copy or move the archive jonathan-lalou-standalone-esb-1.0.zip to any folder of your choice. Then unzip it.

(optionnal) Checks

Tree

Here is a tree of the installation, with some important file that must appear:

+---start-mule-jonathan.bat
+---bin
¦   +---mule-jonathan.xml
+---conf
¦   +---wrapper.conf
+---etc
¦   +---mule-jonathan.properties
+---lib
¦   +---boot
¦   ¦   +---exec
¦   +---endorsed
¦   +---mule
¦   +---opt
¦   +---user
¦       +------com.ibm.mq-6.0.2.0.jar
¦       +------com.ibm.mqjms-6.0.2.0.jar
¦       +------commonservices-6.0.2.0.jar
¦       +------connector-1.0.jar
¦       +------dhbcore-6.0.2.0.jar
¦       +------fscontext-1.2.jar
¦       +------providerutil-1.2.jar
¦       +------wlfullclient-10.3.jar
¦       +------connector-1.0.jar
+---licenses
+---logs

Files

Check the files listed above in the tree appear. Besides, check the conf/wrapper.conf file contains the line wrapper.java.classpath.4=%MULE_HOME%/etc

Config

Edit etc/mule-jonathan.properties file and set the right properties.

Use

Execute start-mule-jonathan.bat to launch Mule on Windows. On first attempt, Mule will display the user licence and ask you your confirmation you accept the terms of the agreement.

PostHeaderIcon Equivalent of ‘pwd’ in MS-DOS

What is the equivalent of Unix’ pwd in MS-DOS, to be used in a .BAT script?

Let’s use %CD%.
eg:
[java]C:\cd "C:\Documents and Settings"
C:\Documents and Settings>set FOO=%CD%
C:\Documents and Settings>>echo Hello my folder: %FOO%
Hello my folder: C:\Documents and Settings\[/java]

PostHeaderIcon Mule / MQJE001 / MQJMS2007

Case

In a Mule ESB workflow, the endpoint is a <jms:outbound-endpoint>, pointing to a JMS queue hosted on MQ Series and accessed through WebLogic 10.3.3.

I get the following stracktrace

[java]Exception stack is:
1. MQJE001: Completion Code 2, Reason 2027 (com.ibm.mq.MQException)
com.ibm.mq.MQQueue:1624 (null)
2. MQJMS2007: failed to send message to MQ queue(JMS Code: MQJMS2007) (javax.jms.JMSException)
com.ibm.mq.jms.services.ConfigEnvironment:622 (http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/jms/JMSException.html)
3. Failed to create and dispatch response event over Jms destination "queue://MQSERVER/AMQ.4C8A5E112285475605?persistence=1". Failed to route event via endpoint: null. Message payload is of type: JMSObjectMessage (org.mule.api.transport.DispatchException)
org.mule.transport.jms.JmsReplyToHandler:154 (http://www.mulesource.org/docs/site/current2/apidocs/org/mule/api/transport/DispatchException.html)[/java]

Fix

On Mule config file, explicitly set the attribute disableTemporaryReplyToDestinations at true in the JMS outbound tag:

[xml]<jms:outbound-endpoint
queue="jonathan.lalou.jms.queue"
connector-ref="jmsConnector"
transformer-refs="foo" disableTemporaryReplyToDestinations="true"/>[/xml]