We need to create a Mavenized Mule Project in Eclipse. This project is the one that will be used for running the mule application.
1. Create a simple maven project in Eclipse.
Select the Maven Project |
Select Create a Simple Project |
Provide Group Id & Artifact Id and Click Finish |
<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/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.mybusiness</groupId> <artifactId>ShippingService</artifactId> <version>1.0</version> <packaging>jar</packaging> <repositories> <repository> <releases> <updatePolicy>always</updatePolicy> </releases> <snapshots> <updatePolicy>always</updatePolicy> </snapshots> <id>MuleRepo</id> <name>Mule Repository</name> <url>http://repository.muleforge.org/ </url> </repository> <repository> <releases> <updatePolicy>always</updatePolicy> </releases> <snapshots> <updatePolicy>always</updatePolicy> </snapshots> <id>JBossRepo</id> <name>JBoss Repository</name> <url> https://repository.jboss.org/nexus/content/groups/public/ </url> </repository> <repository> <releases> <updatePolicy>always</updatePolicy> </releases> <snapshots> <updatePolicy>always</updatePolicy> </snapshots> <id>MuleDependencies</id> <name>Mule Dependencies</name> <url>http://dist.codehaus.org/mule/dependencies/maven2/</url> </repository> </repositories> <dependencies> <dependency> <groupId>org.mule</groupId> <artifactId>mule-core</artifactId> <version>2.2.1</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>org.mule.transports</groupId> <artifactId>mule-transport-vm</artifactId> <version>2.2.1</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>org.mule.transports</groupId> <artifactId>mule-transport-http</artifactId> <version>2.2.1</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>org.mule.modules</groupId> <artifactId>mule-module-xml</artifactId> <version>2.2.1</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>org.mule.modules</groupId> <artifactId>mule-module-saaj</artifactId> <version>2.2.1.0</version> <type>pom</type> <scope>compile</scope> </dependency> </dependencies> </project>
3. Create log4j.properties file under src/main/resources location. This file helps in seeing the logs on the Eclipse console when the Mule service gets started.
#------------------------------------------------------------------------------ # # The following properties set the logging levels and log appender. The # log4j.rootCategory variable defines the default log level and one or more # appenders. For the console, use 'C'. For the daily rolling file, use 'R'. # For an HTML formatted log, use 'H'. # # To override the default (rootCategory) log level, define a property of the # form (see below for available values): # # log4j.logger. = # # Possible Log Levels: # FATAL, ERROR, WARN, INFO, DEBUG # #------------------------------------------------------------------------------ log4j.rootCategory=INFO, C #------------------------------------------------------------------------------ # Also we can define the levels for different packages. #------------------------------------------------------------------------------ log4j.logger.org.mule=INFO #------------------------------------------------------------------------------ # # The following properties configure the console (stdout) appender. # See http://logging.apache.org/log4j/docs/api/index.html for details. # #------------------------------------------------------------------------------ log4j.appender.C = org.apache.log4j.ConsoleAppender log4j.appender.C.layout = org.apache.log4j.PatternLayout log4j.appender.C.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss} %c{1} [%p] %m%n
4. Create a sample mule-config.xml under src/main/resources folder. This is used to test the workspace and check whether the service is getting started without any issues.
<?xml version="1.0" encoding="UTF-8"?> <mule xmlns="http://www.mulesource.org/schema/mule/core/2.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:vm="http://www.mulesource.org/schema/mule/vm/2.2" xmlns:http="http://www.mulesource.org/schema/mule/http/2.2" xsi:schemaLocation=" http://www.mulesource.org/schema/mule/core/2.2 http://www.mulesource.org/schema/mule/core/2.2/mule.xsd http://www.mulesource.org/schema/mule/vm/2.2 http://www.mulesource.org/schema/mule/vm/2.2/mule-vm.xsd http://www.mulesource.org/schema/mule/http/2.2 http://www.mulesource.org/schema/mule/http/2.2/mule-http.xsd"> </mule>
5. Create a run configuration and start the server. The server should get started successfully.
Right click on mule-config.xml and select Run As->Run Configurations. Double click on the Java Application and create a new instance.
Create a new Run Configuration for this project |
Provide the location of the mule-config.xml as an argument |
Server Startup logs - Started Successfully |
No comments:
Post a Comment