Quick guide to start using Maven2 combined with JBoss server

I have just begun at a new project with some new technologies. I am currently developing applications using EJB3, JSF1.2 and Facelets. We deploy the application on a JBoss 4.2.1 server. For the building, testing and packaging we are using Maven2. I have used it before at other projects and I must say: it is a relieve to use it again after having use Ant for the last 6 months. Although there are some disadvantages when using Maven for which I haven’t found a solution yet, overall I find it a great step forward.
For those that haven’t used Maven2 before and are ending up in this blog here is a quick list of the necessary steps to get it running on your Windows machine behind a firewall.

  1. Unzip maven-2.0.7-bin.zip to the directory you wish to install Maven 2.0.7. These instructions assume you chose C:\maven-2.0.7
  2. Add the bin directory to your path, by opening up the system properties (WinKey + Pause), selecting the “Advanced” tab, and the “Environment Variables” button, then editing the PATH variable in the user variables. eg. “C:\maven-2.0.7\bin”;%PATH%
  3. In the same dialog, make sure that JAVA_HOME is set to the location of your JDK, eg. C:\jdk1.5.0_02
  4. Run mvn –version to verify that it is correctly installed.


You can specify your user configuration in ${user.home}/.m2/settings.xml . A full reference to the configuration file is available. This section will show how to make some common configurations. Note that the file is not required – defaults will be used if it is not found.

Configuring your Local Repository

  1. The location of your local repository can be changed in your user configuration. The default value is ${user.home}/.m2/repository/ .

    Note: The local repository must be an absolute path.

  2. Configuring a Proxy

    You can configure a proxy to use for some or all of your HTTP requests in Maven 2.0. The username and password are only required if your proxy requires basic authentication (note that later releases may support storing your passwords in a secured keystore – in the mean time, please ensure your settings.xml file (usually $user.home /.m2/settings.xml) is secured with permissions appropriate for your operating system).

    The nonProxyHosts setting accepts wild cards, and each host not to proxy is separated by the | character. This matches the JDK configuration equivalent.


    Please note that urrently NTLM proxies are not supported as they have not been tested. You may be able to use the relevant system properties on JDK 1.4+ to make this work.

  3. Using Mirrors for Repositories
    Repositories can be declared inside a project, which means that if you have your own custom repositories, those sharing your project easily get the right settings out of the box. However, you may want to use an alternative mirror for a particular repository without changing the project files.

    Some reasons to use a mirror are:

    * There is a synchronized mirror on the internet that is geographically closer and faster
    * You want to replace a particular repository with your own internal repository which you have greater control over
    * You want to run maven-proxy to provide a local cache to a mirror and need to use its URL instead

    To configure a mirror of a given repository, you provide it in your settings file, giving the new repository its own id and url , and specify the mirrorOf setting that is the ID of the repository you are using a mirror of. For example, the id of the main Maven repository included by default is central , so to use an Australian mirror, you would configure the following:

          <name>Australian Mirror of http://repo1.maven.org/maven2/</name>

Most of this info is just copied from the Maven website. This is just a summary with the most essential info. If you really want to use Maven2 for the first time I suggest you have a look there for more info.

Another thing which is good to know: sometimes you will need libraries that aren’t in any global repository (some Sun jars, at least until recently or some jars you made yourself). To have Maven work with these libraries you will have to install them in your local repository. You can do so with the following command:

mvn install:install-file -DgroupId=net.pascalalma.faces -DartifactId=my-validators
-Dversion=1.0 -Dpackaging=jar -Dfile=C:/tmp/my-validators-1.0.jar

One final thing I found very handy is the use of the JBoss plugin to deploy your application to JBoss. You can use the plugin by putting the following in your pom:


In my settings.xml I have defined the jboss.home property like this:




If al this is in place you can deploy your application to the default JBoss server with the command:
mvn clean package jboss:harddeploy

About Pascal Alma

Pascal is a senior software developer and architect. Pascal has been designing and building applications since 2001. He is particularly interested in Open Source toolstack (Mule, Spring Framework, JBoss) and technologies like Web Services, SOA and Cloud technologies. Lately he is having great fun by building iOS apps with Swift. Specialties: JEE AWS XML/XSD/XSLT Web Services/SOA Mule ESB/ WSO2 ESB Maven Cloud Technology Swift/ iOS
This entry was posted in JBoss, Maven and tagged , . Bookmark the permalink.

2 Responses to Quick guide to start using Maven2 combined with JBoss server

  1. jr says:

    I would love to see how you configure a maven multi module project (ejb3, web services, jsf+seam+facelets) that also has unit testing. If you also had integrated spring into this mess that would be great too!!!

    The fact that there doesn’t appear to be a public jboss maven repo makes things hard.

  2. Pascal Alma says:

    Hi JR,

    I do not have a complete solution for you (yet), but maybe this repository will help you:
    You will find a lot of (JBoss) libraries there.

    Hope this helps!

Comments are closed.