A framework for J2EE with open source software.


General J2EE: A framework for J2EE with open source software.

  1. A framework for J2EE with open source software. (2 messages)

    A framework for J2EE with open source software.

    Often companies spend immense amounts of money to get the best possible software products for their project. While these amounts are fine for the Fortune 100 companies, they can end up being a heavy investment for the small to middle sized company. Most of the current J2EE packages available provide a development tool (IDE), a server and a database. A package like this will come with telephone support, documentation, automatic code generation wizards, etc. And with the price you pay you should!

    How ever there is another possibility. You can use open source software:


    Open source software is free to use for anyone. There are many possibilities to choose from and making the right choice is important for a working framework. In this article I will go thru all J2EE layers and propose an open source solution which is most effective. Also I will talk about the best free IDE s available, free J2EE servers and free databases.

    All Software listed here is free of charge. I would recommend however checking the license for the frameworks if integrated into company products.

    The Environment

    For a working J2EE environment you will need development tools, a server, and a database. For instance having an Oracle database together with a J2EE server (Weblogic, Websphere) is a common combination. These J2EE systems come with extencive documentation and tools to aid in development. Using these tools can be advantageous, but they also hide much of the implementation under nice looking wizards and automated code generation. This for an experienced programmer can be very frustrating as you can not see what is happening under the hood.
    Anyhow to get back to the point, what you need is a J2EE server, development tools, and a database.

    The tools

    For development tools some people are happy with a plain text editor, but for some of us a good IDE is just a necessity. For an Java IDE I recommend Sun One Studio community edition http://wwws.sun.com/software/sundev/jde/ , I have also heard that eclipse www.eclipse.org/ is popular among developers. But Sun one studio is more suitable for web applications development. ( In my opinion ). I like the code completion functionality and the possibility to add new code libraries to this powerfull tool it makes developing much faster and less painful. A powerfull text editor is what every programmer needs also, for this my (and everyone elses) favourite is: textpad www.textpad.com. For the Linux developer my favourite would be nedit. www.nedit.org, but the amount of text editors is overwhelming and everybody has their own personal favourites!

    The server:

    For J2EE there are 2 main server types: a servlet container server, and an EJB server. In a J2EE project you often don’t need to use EJB: s and therefore don’t need a heavy server for this. The best known JSP server is:

    Tomcat http://jakarta.apache.org/tomcat/

    Tomcat is easy to install and provides all the posibilies any other commercial servlet engine would. I recommend Tomcat for servlet only driven web applications.

    In other cases you want to design your webapplication to be ready for clustering (attach multiple servers to allow for more users and failure tolerancy to your appliation) .If you need to host heavy EJB applications then you should use:

    Jboss: www.Jboss.org .

    Jboss is a full J2EE server with support for EJB: s. The Jboss forum is a great place or support. Jboss has many great features like hotswapping, clustering, EJB and others required by the J2EE specification.

    The Database:

    For the database there are many possibilities. Databases vary in size,performance and features.
    Choosing the right one is important. The most well known free database is Mysql and I would make that the number 1 choise for a free DB.

    MySQL, MySQL is the world’s most popular open source database. www.mysql.com/.

    If your web application is only a small website which has a a few tables I would use hsqldb, which is a small footprint Java based database.
    http://hsqldb.sourceforge.net/ HSQLDB is a small database which can be integrated into applications if needed.

    For advanced databases PostgreSQL http://www.PostgreSQL.org provides functionality seem in major databases like Oracle.

    All of these are free to use and work reliably if used properly, the documentation is good with Mysql.

    PostgresSQL has advanced features, which some developers need for their project (pl/sql, views, joins, online backup, Isolation levels, etc)

    Hsqldb has a bit less documentation, but if you are familiar with JDBC and databases in general Hsqldb is not any different to a mainstream package.

    The J2EE framework.

    The J2EE framework is a layered approach defined by Java. The framework can be divided into 4 layers (or more if needed also referred as n-tier) according to their function:

    1. Client tier (Application clients , applets, apps, and other GUIs)

    2. Presentation tier (JSP, Servlets and other UI elements)

    3. Business Tier (EJB and other business objects)

    4. Integration Tier (JMS, JDBC, Connectors)

    5. Resource Tier (Databases, external systems and legacy resources).

    For each tier you can find ready made open source software which can help your development by providing tested solutions quick and easy.

    1. The Client tier

    The client tier is generated by the presentation tier and refers to a browser accessing the J2EE application from a remote location. (Mobile phone, computer or TV)

    2. The Presentation tier.

    The presentation tier generates views for the clients; it also passes information from the client tier into the business tier for processing.

    There are many ready made frameworks, which take away the repetitive task of writing the same tasks again, and again.

    The best one for displaying data in my opinion is the Jakarta taglibs project: http://jakarta.apache.org/taglibs/ taglibs have ready made xml tags, which allow data do be queried and displayed on a web page, this takes away the pain of coding iterators, vectors, and connections for every query made, also it makes the resulting JSP pages clean and easy to modify for the web designers.

    More documentation can be found for The dbtags library at:


    The model view controller architecture.

    The J2EE patterns define the model-view architecture as the architecture of choice for the J2EE presentation tier. These patterns are the best way to make good J2EE applications because they are patterns which have been derived from years of web system development. Patterns should always be used when in doubt about how to do something.


    Jakarta struts provide an excellent ready made framework for implementing MVC. It has functions for form submission, internationalization, form validation etc. Also it provides a ready made controller servlet, for forwarding page requests, which is the most common part in every web application.


    Struts does things exactly as they are supposed to be done in the J2EE world. If you use struts you are doing things right. However using struts is not necessary if you do not intend to have many submission forms or internationalization.

    3. Business tier.

    The Business tier processes information, returns results to the presentation tier and passes information onwards to the Integration tier which usually persists data into a database, or a file for instance an xml file.

    The business tier consists of Java Beans, EJB: s and other java classes required for application logic. The amount of tools for this tier is immense. How ever I have categorized the main tool categories and listed the most significant ones under each category.

    EJB generation tools.

    These tools can generate EJB: s from the database or from a properties file, they save time and take away the repetitive tasks.


    XDoclet is a code generation engine. It enables Attribute-Oriented Programming for java. In short, this means that you can add more significance to your code by adding meta data (attributes) to your java sources. This is done in special JavaDoc tags.


    EJBGen is an Enterprise JavaBeans 2.0 code generator. Instead of having to edit and maintain several files (Bean, Remote and Home classes, and the deployment descriptors), EJBGen will allow you to limit your editing to one file (the Bean class) and annotate it with Javadoc tags. EJBGen will then parse your source and will generate all the needed files.


    Object relational frameworks.

    Using object-relational mapping instead of JDBC can reduce your development time and improve your performance when using RDBMS with Java.

    The idea of JDO (Java Data Objects) www.jdocental.com is to simplify database access by integrating the database schema into java objects, this allows the developer to think of saving and retrieving data in the object oriented world. It takes away the process of writing SQL. Also often the Data Objects can be generated automatically so that coding different classes with set and get methods is in the past, this I think is the best feature as writing repetitive code can be a real pain sometimes.

    I have included the best object relational frameworks here, these are not actually Java Data Objects frameworks, but the idea is similar, I have not found a reliable JDO specification compliant open source implementation yeat. But the Object relational bridge: http://jakarta.apache.org/ojb/ seems to provide an implementation, however this project is still under development.

    1. Hibernate.

    Hibernate is a powerful, ultra-high performance object/relational persistence and query service for Java. Hibernate lets you develop persistent objects following common Java idiom, including association, inheritance, polymorphism, composition and the Java collections framework.
    To support a rapid build procedure, Hibernate rejects the use of code generation or bytecode processing. Instead runtime reflection is used and SQL generation occurs at system startup time. Hibernate supports Oracle, DB2, MySQL, PostgreSQL, Sybase, SAP DB, HypersonicSQL, Microsoft SQL Server, Progress, Mckoi SQL, Pointbase and Interbase. Hibernate supports an ODMG 3 interface alongside a more expressive custom API. Of course, Hibernate integrates elegantly with J2EE application servers


    2. Object relational bridge:

    ObJectRelationalBridge (OJB) is an Object/Relational mapping tool that allows transparent persistence for Java Objects against relational databases

    Object relational bridge seems to be still evolving and I would recommend going with a more mature JDO Implementation for a little cost. See www.jdocental.com for available implementations.

    Hibernate seems to offer a mature implementation of a object relational mapping. I would recommend using it on a new project. Im not sure how it integrates with EJB but it does not need to.


    Often xml needs to be parsed or formatted into different forms for this you can get free api:s from:


    Of these the most noticeable is:
    Xerces (named after the Xerces Blue butterfly) provides world-class XML parsing and generation.
    4. Integration Tier
    The integration tier is a set of drivers which transforms the data to a format which can be stored or sent to a data storage solution or another J2EE server.
    For this the most common is the JDBC driver, which talks to the underlying data store. Every database has its own JDBC driver, which usually comes with the DB.
    As can be seen from the article there are a lot of technologies out there. The ones presented here are merely a fraction of the available ones. Open source provides many possibilities to implement projects without investing large amounts of capital into licenses. However in some cases the documentation can be poor, support can be non existent, and there are no guarantees incase of failure. However if you manage to have a team that is fluent with open source then you will be saving a big buck. When choosing open source software it is important to assess the maturity of the software as projects in their early stages tend to be unreliable.
    Toni Karhu
  2. Where's the beef? I guess I missed the point behind this article.
  3. Well the idea was to say that dont use expencive software,
    when everythings out there free. I admit the end isnt good it kind of leaves everuthing open,cheer, for the comments anyhow