UML2EJB Open Source Code Generator Released


News: UML2EJB Open Source Code Generator Released

  1. UML2EJB Open Source Code Generator Released (23 messages)

    UML2EJB is an open source J2EE code generator - it takes a Unified Modeling Language (UML) model from a CASE-tool in XMI format and generates Enterprise JavaBeans classes with tags for the XDoclet tool. You will get EJBs that can readily be deployed into JBoss and others. With the latest 1.2 release, the generator has reached production quality.

    Check out UML2EJB.

    UML2EJB Team announcement
    Born during summer 2002 and published on SourceForge, it has
    become a really valuable tool for template-based generation of EJBs (and related classes) out of UML models. It is implemented as a custom task for Ant and reads models from popular CASE tools like Poseidon, Rational Rose and Together via the XML metadata interchange (XMI) file format.

    Matthias Bohlen, author of the original version, says:

    "Originally, I wrote the generator to be able to demonstrate the advantage of model-driven architecture to my customers in day-to- day mentoring work in software development projects. Now, I am excited about the attention that UML2EJB has attracted among users as well as developers in the short time since it went public. The number of contributors has increased, several qualified developers have offered to extend it which is good because the project does not depend entirely on my availability any more. Vendors have asked to incorporate UML2EJB in their products, since we have changed the license from GPL to BSD."

    UML2EJB sits on top of XDoclet (which many of you will already know) and leverages its capability to configure and deploy the resulting beans into the most common J2EE containers like JBoss, Weblogic, WebSphere, Orion, OC4J, etc.

    So what now?

    If you know EJBs and want to try it, point your browser to the project website at and read the instructions for download, installation, modeling and usage. We support UML2EJB and answer questions on the uml2ejb-user mailing list.

    See you there!
    The UML2EJB team.

    Threaded Messages (23)

  2. It looks really great !

    How does it compare with EMF, an Eclipse sub project ?

    Could I write my own template to generate any kind of component from the UML model ? For example a WSDL file (web service) for a Stateless Session Bean stereotype ?

    Thanks !
  3. Hi Guys,
    Incidently today i release a multipurpose code generator. Visit for details
  4. Looks a little bit like the WMEE from Sygel. UML2EJB is OSS though, whereas WMEE is not - with all the pros and cons associated. WMEE does seem to offer a lot more facilities for GUI development: typical J2EE applications not only require the implementation of a Model, but also of a View (using Struts frontend as an example). WMEE - as I understand it - also generates default Views based on your Model.


  5. The easiest way to answer your question, plus the others already asked in this forum is to read the web site. It has a full explanation of how the code generation works.

    1. "Could I write my own template to generate any kind of component from the UML model"


    2. " I am interested to know if code generation is acheived
    via XSLT scripting."

    No, it uses Velocity
  6. Actually, UML2EJB uses both XSLT and Velocity. XSLT is used as an intermediate step to convert the (monstrous) XMI output from the Case tool to a more manageable XML. Then UML2EJB unmarshals this XML document to java objects with JAXB and hands them over to Velocity. -At least this is my understanding of it.

    Matthias and I have discussed integrating Middlegen and UML2EJB. This would be achieved by letting Middlegen generate XMI to describe database tables and relationships in UML. Sort of a RDBMS2UML plugin for Middlegen. Then this could be picked up by UML2EJB and enhanced with e.g. Session Beans to create a more complete application.

  7. I need to put in my own

    innoQ's iQgen is a template-driven code-generator that supports XMI exported from a large number of different CASE tools and uses JSPs as its template language. The new release, 1.1, has just been made available. iQgen is free for non-commercial use.

    Find out more about iQgen at

  8. Hi Rodolfo,

    sure - this is the philosophy of UML2EJB: The templates which ship with the generator are only samples (although they produce already fully functional EJBs). The lead architect of the target project should take them and customize them for the project's needs.

    You can generate WSDL of course - no problem. The website describes exactly how to write and invoke your own templates.

    How it compares to EMF? Well, I have installed EMF on my machine a few days ago and I must say: I did not quite get the clue - maybe I need a seminar ;-) I succeeded to generate a few Java classes that directly reflected the UML classes, but I did not understand the philosophy of the product (the online help files did not work in my Eclipse installation).

    So, sorry, I can't yet tell you very much about this. Maybe, if someone points me to the right EMF documentation, I will be able to say more in the near future.

    Matthias Bohlen
  9. I am interested to know if code generation is acheived
    via XSLT scripting.

    UML in XML form --> XSLT script --> Plain text code

    Since last one and half year, inn our project I have been
    doing code generation and published a paper at XML Journal.

    "Model Driven Programming by XSLT"

    Currently in our project 62% is generated code.

    Soumen Sarkar.
  10. Hi Soumen,

    this question has been asked by many users of UML2EJB. The answer is no, it does not use XSLT for code generation (but for other purposes, as Aslak Hellesoy correctly pointed out).

    You may ask: why? and you will find the architectural answer in the forum Open Discussion of the UML2EJB project site.

  11. Generating EJBs from UML is awesome, but why stop there? Why not generate the entire application - EJB, Java objects, Database schema, XML schemas, servlets, Swing UI, etc? Each component requires a different representation of the same business objects. Code generation has become quite popular in the last couple of years (in J2EE-land, anyway) but so far each solution has concentrated on solving one piece of the puzzle - like generating EJBs for persistence.

    Furthermore, there's a whole class of problems that haven't been tackled by the code generators I've seen. Most generators attack the business object piece, but ignore the application configuration/control/communication piece. That is, you can't declare the way components interact with each other in the application. This might not sound like a big deal, but it becomes a problem when trying to set up and configure (or reconfigure!) distributed systems.

    Now, the shameless plug. :) There's a project over on Sourceforge that handles the entire declaration of a distributed, message-based application. You define your objects, and a series of generators build all of the representations you need, from the UI all the way back to the database. Next you define your components and they way the interact, and more generators build the messaging + control code. All that you have to do is implement your business logic - the stuff your application actually does.

    The architecture the project uses is called "Structs and Nodes Development" (SAND); the SF project is Sandboss. I've used a similar but less-powerful tool in production before, where it saved many man-years of development time.
  12. Hi Steve,

    the project you describe sounds absolutely cool - I'll surely have to check it...

    Generating EJBs from UML is awesome, but why stop there? Why not generate the entire application - EJB, Java objects, Database schema, XML schemas, servlets, Swing UI, etc?

    No, we do not stop there. At the moment, I'm writing some templates to generate Struts model-view-controller web apps. You'll be able to describe forms, actions and pages as UML classes and connect them with relationships to model the entire workflow. UML2EJB will then generate code frames and strutsconfig.xml for you (Aslak: sorry, I'll not use the XDoclet tags for Struts :-) because then I would need an additional implementation class per action class).

    This is where the name UML2EJB is not appropriate any more - I should call it UML2J2EE or UML2Anything.

    See you...
  13. One addition that I forgot: Chris dot Shaw at ecb dot int also generates database schemas for his project. I also heard of one user who generates Apache OJB code.

  14. What about using:

    UML Modeling Tool --> XMI --> JMI (JSR 40) --> Your Engine --> Template Engine Interface -->> Any Template Engine Implementation (Velocity, XSL, JSP)

    XMI is input to the JMI implementation.
    Your Engine genenerates events, filter model elements, etc. and call the Template Engine interface.
    Template Engine implementation making final stuff :)

    In this case it wiil be UML2Anything & Using Anything :)

  15. Hi Sergey,

    several people have pointed me into that direction. I always was reluctant to use JMI because so many systems that write XMI write it with little deviations from the standard so that I am afraid a decent JMI implementation cannot (or will not) cope with that.

    However, I'll run a number of tests with JMI and see what happens to typical XMI files.

  16. Hi Matthias.

    I believe, you right.
    Only one suggestion/question:

    * Why dont you implement JMI by yourself and provide access to it for template builders?

    In this case it will remove any possible limitations, mentioned by you. And, from other point of view, JMI became an standard (good or bad - it is different story).
  17. Hi, Sergey,

    implement JMI by myself? Huh! I'll have to read more about JMI, first! :-)

  18. Hi Matthias.

    I know. It was terrible proposal :)

    My point is: would be better to follow standard way.

    I believe, the Reference Implementation of JMI, developed by Unisys, allows to integrate at least with Rational Rose (XMI export also developed by Unisys)

  19. This looks a lot like Sun's ACE project :
  20. Gilles Philippart wrote: &#8220;This looks a lot like Sun's ACE project&#8221;

    You right. Almost :) But there are several differences.

    <Quote from Project Ace: A Better Way to Build Enterprise Applications>

    Ace is unique because it provides a natural way for developers to describe the &#8220;intent&#8221; of the application precisely, as opposed to manually writing the code that implements that intent. In other words, developers use Ace to create a high-level specification that provides enough information so that Ace can automatically generate the optimal code for the application. It completely separates the implementation details of a distributed application from its specification.

    This high-level specification consists of:
    &#61482;&#61472;A set of business objects that describe the entities, relationships, business rules,
    constraints, and procedures of the business. This collection of objects, called the
    Business Object Specification (BOS), is typically shared across many applications.
    &#61482;&#61472;A set of task states and transitions that describe how the application and its user
    interacts with the underlying business objects, and a set of transactions that describe
    changes that the application makes to the values of these objects, called the Application
    Usage Specification (AUS).

    Ace is a research project, not a product. The team has developed an implementation of the Ace technology that runs within the Forte/NetBeans Integrated Development Environment (IDE). It includes GUI editors for the two specification languages (BOS and AUS) as well as a way to view the specifications in a natural textual way and synchronously edit either the textual or GUI view.

    </Quote from Project Ace: A Better Way to Build Enterprise Applications>

    IMHO, there is no reason to design and implement Business Object Specification language or Application Usage Specification language, or another architecture-neutral application specification language. Moreover, it is senseless act :(

    Why don&#8217;t we use Unified Modeling Language (UML) & Model Driven Architecture (MDA) as architecture-neutral? UML model should be the ONLY source of app implementation. Other existing technologies can only help to generate required architecture and platform specific models &#8211; PIM-to-PSM translation (see and

    Every &#8220;good&#8221; Software Engineer should know about UML, and use it in real life (at least use case & class diagram). There is no problem to perform PIM-to-PSM translation using ALREADY DESIGNED AND IMPLEMENTED technologies, such as Velocity (open source project), XSLT (industrial standard de-facto), JAVA SERVER PAGES &#8211; yes, yes, yes &#8211; JSP also can be used to perform such transformation (see Stefan, why don&#8217;t you buy me a bottle of beer for promoting your product :) :) :)
    This is right way &#8211; many of us need to learn HOW TO USE on 100% existing technologies and do not invent the wheel!!!

    Otherwise in few month a lot of people will require more simplest specification on Business Object Specification (BOS), and someone will have to design it and name it SIMPLEST BOS. IMHO, this is escape from reality, because it does not really help to achieve the primary goal.
  21. yes, yes, yes ; JSP also can be used to perform such >transformation (see <href="http://iqgen.innoq.org">>).

    >Stefan, why don't you buy me a bottle of beer for
    >promoting your product :) :) :)

    Send me your address and I'll have it delivered to you ;-)

    Honestly, what I think is a lot more important than which MDA product you use is that you use one *at all*. Once you've made up your mind, you can choose from one of the several options available. But I can't see any reason for not using one for all but the most trivial projects.

  22. We didn't know the existence of any of those tools, so we did something totally new, from scratch.
    One XML file contains our data elemens and their relationships. A lot of XSLT files (about 10 or 15) generates
    * EJB beans, remote, homes
    * deployment description (ejb-jar and websphere specific)
    * client side java classes that access our EJBs
    All this XSLT files are coordinated using Ant.
    And it works fine !
    The counterback is that sometimes the XSLT files are too complicated.
  23. We didn't know the existence of any of those tools, so we

    > did something totally new, from scratch.

    Really? Either you didn't look at any of the commercial
    products, or you didn't read any press releases, or stories
    on this website...

    I get yelled at for standing on a soap box on this forum,
    and now this is a great example of why I do it :(

    CocoBase has been reading UML/XMI and generated EJBs, java
    classes, Database DDL, Runtime Navigation and O/R mapping
    models for almost 2 years... You could have saved yourself
    probably months of development effort with a single click,
    and saved your company a lot of wasted money in the

    If customers need this features, they should just download
    CocoBase - it's included out of the box, and you not only
    get EJBs, but you get beans, value objects, descriptors,
    ant build and deploy scripts and actual commercial support
    for the integrations...

    And it includes a variety of other features that are quite
    extensive and useful for EJB servers... Like clustered
    based data caching, Beans that map across more than one
    table, dependent value objects, a unified persistence layer
    that can be shared across component layers, both local
    and distributed (j2ee based) transparent persistence for
    complex object model management, a very lightweight runtime
    etc., etc., etc.

    Have fun all - and happy java coding!

    Ward Mullins
    THOUGHT Inc.
  24. Cocobase and OS hacking[ Go to top ]

    Hi Ward,

    I won't yell at you - the feature list of Cocobase sounds terrific.

    In spite of the existence of many decent generators in the market, I chose to write UML2EJB. Why? To show something (MDA and template engines) to my clients (I'm an independent consultant on component technologies). I have never thought that this would generate so much interest (honest: I'm not fishing for compliments, here!).

    Keep on doing the good work!


    P.S.: Besides that, Open Source hacking gives me a thrill. Did you read Jim Coplien's article on Christopher Alexander's book "The Nature of Order"? Maybe, the search for QWAN (see the article) is the reason why we do Open Source.