From Resin 3.0

Jump to: navigation, search

Mule and Resin

Mule can be run within Resin and use objects created by it as components. This allows Mule to take advantage of Resin IoC. This simple example shows how to have Mule use Resin IoC-created objects. To see how to configure Mule with Resin using servlets and Amber JPA, see this example.

(The following has been tested with Resin 3.1.5 and Mule 1.4.3)

  1. Download Resin from
  2. Unzip Resin into /usr/local/share/resin
  3. Create the Mule webapp directory structure:
    mkdir -p /usr/local/share/resin/webapps/mule/WEB-INF/lib/
    mkdir -p /usr/local/share/resin/webapps/mule/WEB-INF/classes/example/
    mkdir -p /usr/local/share/resin/webapps/mule/WEB-INF/classes/META-INF/
  4. Download Mule from
  5. Unzip Mule
  6. Copy all the jars included the Mule lib/ directory to
  7. Create the configuration file /usr/local/share/resin/webapps/mule/WEB-INF/resin-web.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="">
      <!-- Create the bean reference for the Mule component -->
      <bean class="example.HelloBean">
          <message>Hello, World!</message>
      <bean class="example.HelloComponent" name="helloComponent"/>
      <bean class="com.caucho.mule.MuleConfig">
  8. Create the configuration file for Mule /usr/local/share/resin/webapps/mule/WEB-INF/classes/META-INF/hello-config.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE mule-configuration 
      PUBLIC "-//MuleSource //DTD mule-configuration XML V1.0//EN"
    <mule-configuration id="Mule_Hello_Sample" version="1.0">
      <model name="helloSample">
        <mule-descriptor name="HelloUMO" implementation="helloComponent">
            <endpoint synchronous="true" address="http://localhost:8086"/>
  9. Create a bean to inject into the Mule component /usr/local/share/resin/webapps/mule/WEB-INF/classes/example/
    package example;
    import javax.webbeans.Component;
    public class HelloBean
      private String _msg = "Uninitialized";
      public void setMessage(String msg)
        _msg = msg;
      public String getMessage()
        return _msg;
      public String toString()
        return "HelloBean[" + _msg + "]";
  10. Create the Mule component /usr/local/share/resin/webapps/mule/WEB-INF/classes/example/
    package example;
    import javax.webbeans.In;
    import org.mule.umo.lifecycle.Callable;
    import org.mule.umo.UMOEventContext;
    public class HelloComponent implements Callable
      @In private HelloBean _hello;
      public Object onCall(UMOEventContext context)
        throws Exception
        return _hello.getMessage();
  11. Start Resin with java -jar /usr/local/share/resin/lib/resin.jar
  12. Look at http://localhost:8086
    It should show
    Hello, World!
Personal tools