How to create Java-J2EE project using AndroMDA?

create Java-J2EE project using AndroMDA

Spider Web Model (gradders52, Flickr)

AndroMDA (pronounced as “Andromeda”) is an extensible generator framework that adheres to the Model Driven Architecture (MDA) paradigm.  It transforms UML models into deployable components for Java/J2EE & Microsoft .NET; using AndroMDA means one main thing:write less code.  Not only that, AndroMDA also lets you create better applications and maintain order on large projects.  AndroMDA enforces best practices and lets developers focus on high level problems.

During development of large applications, most architects and developers already create class diagrams and data diagrams.  These diagrams are usually made in tools like Microsoft Visio, and the resulting artifacts are static pictures.  When code changes, the diagrams must be updated.  With AndroMDA, these diagrams become a living part of your application – they are used to generate large portions of your application, and hence always reflect the current state of the system. When you need to modify your application, you change the model first, regenerate the code, and then add or update custom code as necessary.

“AndroMDA Tool can be used for Java/J2EE and Microsoft .NET based projects”

AndroMDA provides several cartridges out-of-the-box:

  • The Hibernate and Spring cartridges generate robust service and data layers for your Java/J2EE based application
  • The NHibernate and NSpring cartridges generate robust service and data layers for your .NET based application
  • JSF cartridges generate robust presentation layer
  • BPM4Struts(Business Process Modeling for Struts) – this cartridge is to generate Struts web pages from an input UML model in which the flow of the application is modeled
  • jBPMworkflow engine – this cartridge is able to generate process definitions and handlers from UML activity graphs
  • EJB & EJB3
  • Java
  • WebService – generates WSDD (Web Service Descriptor files and WSDL) files for Apache Axis and Apache CXF also generates WebService Client for consuming these generated WebService
  • XmlSchema – used for generating an XML Schema from a class model. It will be used to WebService marshalling and unmarshalling

Article goal is provide detailed info for “create Java-J2EE project using AndroMDA

When to use AndroMDA?

With highly useful MDA tool (AndroMDA uses EMF to generate the code based on architecture models), you must know when to make use of it.  Use it wisely!

AndroMDA is a best choice

  • Starting a new project, or completely rewriting a project/layer of an existing application
  • Want to save time by generating as much code as possible
  • Building an application that stores its data in a database
  • Familiar with UML Modeling tools and want to create more than just pretty pictures

AndroMDA might not be the best choice

  • Application uses an existing database that cannot be easily mapped to an object model (for example, it does not use primary keys and object relationships are not clear)
  • Already have a mature application with existing business objects and the incremental effort to model existing components is too high to provide enough value

Benefits of Model Driven Architecture (MDA) & Model Driven Development (MDD)

There are several benefits using MDA/MDD in larger applications:

  • Lower the risk of large applications
  • Less error-prone
  • Empowers domain experts
  • Brings solid structure/surface between business and IT
  • Simplified development
  • Enforces architecture
  • Enables to focus on business goals instead of technology
  • Increase in Quality of the application
  • Cost effective – leverage open source
  • Provides up-to-date documentation – Model reflects up-to-date application structure


Now we will starting project generation steps so, I assume Maven 2.2.1 or above version; already installed on your machine.

Generating J2EE based application using AndroMDA tool

Step 1

Follow this article How to generate Maven based Java/J2EE Project using Archetype? to create maven sample application.  Because we have to download AndroMDA project generation plugin to local maven repo

Note: AndroMDA version 3.4 has been released on Sep 08, 2012.  Please use 3.4 instead of 3.4-SNAPSHOT in below steps in the article, Thanks.

Step 2

Go to the created sampleapplication directory, as per example directory is /Users/jeeva/Documents/my-contributions/generic-repo/sampleapplication and Edit the pom.xml; add the below entry after end of </dependencies> tag.  Don’t forget to save the edited file.

Step 3

Build the sampleapplication project, run mvn without any arguments.  Ensure the command execution completes successfully by displaying the BUILD SUCCESSFUL message.  If you face any issues building sampleapplication, please click here (Tips below)

Step 4

Now AndroMDA maven plugin have been download into your local maven repo and we are ready to create a project.  Execute the below maven command to create AndroMDA J2EE Application

Step 5

Maven will download required POM and jar files then AndroMDA plugin will start the interactive mode for application generation

Choose your application type (j2ee or richclient)

Provide base directory for project generation and project creator First Name and Last Name

Now choosing a modeling tool for your project

Provide Maven project description, Maven artifactId of your project, project version, Maven groupId (root package of the project)

Provide project packaging type

Choosing Transactional/Persistence cartridge of project

Choosing a programming language of project (Java or Groovy)

Choosing a wide range of Database backend for persistence layer (Oracle, Microsoft SQL, DB2, Informix, My SQL, Sybase, Postgres, Derby, etc.)

Whether workflow engine capabilities required in project or not

Choice of exposing project services as WebService or not

Selecting project WebService stack (Axis, CXF, Sun JAX-WS)

Selecting JAX-WS REST producer/consumer media type

Finally, would like to use embedded jetty web server or not

Now AndroMDA will generate the Java/J2EE application from Archetype

Step 6

Most of the question form interactive mode of archetype are self explanatory. However there is one question “Which kind of modeling tool will you use? (uml1.4 or uml2 for files, emf-uml22 for .uml files, rsm7 for .emx files) [uml1.4, uml2, emf-uml22, rsm7]:”.

Based on your choice you can use following modeling tools:

  • MagicDraw UML Modeling (this is best bet for AndroMDA)
  • IBM Rational Software Modeler
  • ArgoUML

Step 7

Go to newly generate AndroMDA J2EE application directory and followed by directory called ‘mda’.  Now we have to get all the AndroMDA UML 2/UML 1.4 profiles for modeling

Note: If you get message as BUILD ERROR, Don’t worry currently our goal to download required AndroMDA profiles to local maven repo. This error occurred because, we have not yet done a UML modeling.

Step 8

Ready to start, project UML modeling for new created J2EE project.  Use Modeler tool of your choice mentioned in  Step 6

For example: as per this article model location is /Users/jeeva/Documents/my-contributions/generic-repo/andromdaapplication/mda/src/main/uml/andromdaapplication.xml


That’s it, now you have successfully created AndroMDA J2EE project (create Java-J2EE project using AndroMDA) and it’s ready to model and generate code.


This article generated andromdaapplication has been checked-in to GitHub

Also downloadable zip archive available click here!

Tips for Errors

Error 1

If you get following error, ensure your maven settings.xml has below settings. Else add it

Settings for correcting Error 1