Nav
You are viewing an older version of this section. Click here to navigate to the latest version.

Working with an IDE

This document offers tips for importing and working on Mule source code in Mule Studio, Eclipse or IntelliJ IDEA. There are no restriction on the type of integration development environment you use to develop Mule, we simply chose to discuss the above-listed three as common IDEs.

Mule Studio

Mule Studio is an open-source, Eclipse-based graphical user interface you can use to access Mule ESB’s functionality. More than just a GUI interface for building projects with Mule, you can use Mule Studio as an IDE to work with Mule source code in Java.

Importing

  1. Follow the instructions to download, install and launch Mule Studio.

  2. Follow the procedure to add the studio:studio plug in in your Maven settings.xml file.

  3. Within the directory to which you cloned the Mule source code, resolve all library dependencies and generate IDE project files by running the following command:  mvn studio:studio

  4. In Studio, Select File > Import.

  5. In the Import wizard, click to expand the General folder, then select Existing Projects into Workspace, then click Next.

  6. In the Select root directory field, use the Browse button to navigate to the directory into which you downloaded the cloned fork of Mule source code from your Github account.

  7. Ensure all Projects are checked, then click Finish. Studio imports the mule source code.

  8. Open source code files as you need to edit or add content.

  9. Click the Save icon to save locally.

Debugging

  1. In Studio, select Window >  Open Perspective > Other…​ , then select Java to open the Java Perspective.

  2. Select File > New > Java Project. You are creating a new project just for launching Mule.

  3. In the New Java Project wizard, select a Name for your project, such as Mule Launcher, then click Next.

  4. In the Java Settings panel of the wizard, select the Projects tab, then click Add.

  5. Click Select All, then click OK, then Finish.

  6. In the Package Explorer, right click your launcher project’s name, then select Debug As > Debug Configurations…​

  7. In the Debug Configurations wizard, double-click Java Application.

  8. In the Main class field, enter the following content:  org.mule.MuleServer

  9. Click the Arguments tab. In the Program Arguments field, enter the following content: -config <path to a Mule config>

  10. Click Apply, then click Debug.

  11. Studio requests permission to switch to the Debug Perspective; click Yes to accept and open.

You can now set breakpoints anywhere in any of the Java files in any of the Mule projects in the workspace. link: When you change java files and rebuild, the debugger hot swaps the rebuilt Java class file to the running Mule server. Note that you only need to follow the procedure above to set your Debug configurations once; thereafter, simply right-click the project name, then select Debug As > Java Application for subsequent debugging.  

Debugging Remotely

  1. From the command line, edit the JPDA_OPTS variable in the Mule startup script and specify the debugger port.

  2. Start the Mule server with the -debug switch. The server waits until a debugger attaches.

  3. In the Package Explorer in studio, right-click your Mule source code project’s name, then select Debug > Debug Configurations…​

  4. Double-click Remote Java Application.

  5. Under Connection Properties, enter a value for Host and Port, then click Apply.

  6. Click Debug. Studio requests permission to switch to the Debug Perspective; click Yes to accept and open.

Testing

Use Maven to run unit test on your project using the following command: mvn test

In addition to the unit tests for each sub-project, the Mule parent project has a separate sub-project containing integration tests. These tests verify "macroscopic" functionality that could not be tested by any single sub-project alone.

Eclipse

An open-source integration development platform, use Eclipse to modify or add to your cloned version of Mule source code.

Importing

  1. Download and install Eclipse on your local drive.

  2. From the command line, in the directory into which you downloaded the Mule source code, enter the following command to generate the classpath and project files for each sub-project:  mvn eclipse:eclipse.

  3. Before launching Eclipse, make the Maven repository known in Eclipse using the following command: 
    mvn -Declipse.workspace=/path/to/eclipse/workspace eclipse:configure-workspace

  4. Launch Eclipse, selecting the workspace you just "mavenized".

  5. Under the Project menu, select Build Automatically to disable it; this action speeds up the import process.

  6. Select File > Import.

  7. In the Import wizard, click to expand the General folder, then select Existing Projects into Workspace, then click Next.

  8. In the Select root directory field, use the Browse button to navigate to the directory into which you downloaded the cloned fork of Mule source code from your Github account.

  9. Ensure all Projects are checked, then click Finish. Eclipse imports the mule source code. 

  10. Select Project > Build Automatically once again to re-enable build automation.

  11. Open source code files as you need to edit or add content.

  12. Click the Save icon to save locally.

Debugging

  1. In Eclipse, select Window >  Open Perspective > Other…​ , then select Java to open the Java Perspective.

  2. Select File > New > Java Project. You are creating a new project just for launching Mule.

  3. In the New Java Project wizard, select a Name for your project, such as Mule Launcher, then click Next.

  4. In the Java Settings panel of the wizard, select the Projects tab, then click Add.

  5. Click Select All, then click OK, then Finish.

  6. In the Package Explorer, right click your launcher project’s name, then select Debug As > Debug Configurations…​

  7. In the Debug Configurations wizard, double-click Java Application.

  8. In the Main class field, enter the following content:  org.mule.MuleServer

  9. Click the Arguments tab. In the Program Arguments field, enter the following content: -config <path to a Mule config>

  10. Click Apply, then click Debug.

  11. Eclipse requests permission to switch to the Debug Perspective; click Yes to accept and open.

You can now set breakpoints anywhere in any of the Java files in any of the Mule projects in the workspace. When you change java files and rebuild, the debugger hot swaps the rebuilt Java class file to the running Mule server. Note that you only need to follow the procedure above to set your Debug configurations once; thereafter, simply right-click the project name, then select Debug As > Java Application for subsequent debugging. 

Debugging Remotely

  1. From the command line, edit the JPDA_OPTS variable in the Mule startup script and specify the debugger port.

  2. Start the Mule server with the -debug switch. The server waits until a debugger attaches.

  3. In the Package Explorer in studio, right-click your Mule source code project’s name, then select Debug > Debug Configurations…​

  4. Double-click Remote Java Application.

  5. Under Connection Properties, enter a value for Host and Port, then click Apply.

  6. Click Debug. Eclipse requests permission to switch to the Debug Perspective; click Yes to accept and open.

Testing

Use Maven to run unit test on your project using the following command: mvn test

In addition to the unit tests for each sub-project, the Mule parent project has a separate sub-project containing integration tests. These tests verify "macroscopic" functionality that could not be tested by any single sub-project alone.

Setting Eclipse Startup Parameters

The table below lists a number of command-line parameters you can use to alter Eclipse’s startup behavior, if you wish. 

Parameter Action

-clean

enables clean registration of plug-in (some plug-ins do not always register themselves properly after a restart)

-nosplash

does not show Eclipse or plug-in splash screens

-showLocation

puts the full path of the workspace in the window title

-vm

allows you to explicitly set which JDK to use

-vmargs

allows you to pass in standard VM arguments

IntelliJ IDEA

Use IntelliJ’s IDEA integration platform to modify or add to your cloned Mule source code.

Importing

  1. Download and install IntelliJ IDEA.

  2. Open IDEA, then select File > Open…​

  3. Browse to the directory into which you downloaded the Mule source code, then select the pom.xml file. 

  4. Click OK. IDEA takes awhile to process all the pom.xml files.

  5. Set the correct source for the JDK on your local drive. Right click the mule-transport-jdbc directory, then select  Module Settings > Sources > src > main > jdk6 or jdk7. Repeat this step for test sources, as tests.

Troubleshooting
If you IDEA presents any compilation errors in test classes from the CXF module when you create the project, it is safe to ignore them. Those classes depend on some test classes generated by the Maven build during execution. Right click the error message, then select Exclude from compile.  Alternatively, you can run mvn install from the command line to fix the errors.

Debugging Remotely

  1. Start the Mule server with the -debug switch. The server waits until a debugger attaches.

  2. In IDEA, select Run > Edit Configurations…​ to open the Run/Debug Configurations window.

  3. Click Add New Configuration (plus sign), then select Remote.

  4. Enter a name for the configuration, then update the host and port values if required (You can use the default values, localhost:5005, for debugging a local mule instance).

  5. Click OK to start the debugging session.

Testing

Use Maven to run unit tests on your project using the following command: mvn test

In addition to the unit tests for each sub-project, the Mule parent project has a separate sub-project containing integration tests. These tests verify "macroscopic" functionality that could not be tested by any single sub-project alone.