JOnAS 5.1.0

Download JOnAS 5.1: OW2 JOnAS v5.1.0 OW2 JOnAS v5.1.0 OW2 JOnAS (5.1.0) Java Web Start Installer
Copyright © OW2 Consortium 2006-2009 Java, and all Java-based trademarks, JMX and all JMX based trademarks, are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. OSGi is a trademark, registered trademark, or service mark of The OSGi Alliance in the US and other countries. Bull is independent of Sun Microsystems, Inc.


{image:jonas-5.1.png}
Download PDF version of this document 1 Introduction
Java EE Compatible

OW2 JOnAS
*JOnAS 5.1.0*, the new generation [OW2>http://www.ow2.org]' Java EE application server, is available for [download>Main.Downloads].

This is a major version providing many innovative features to Java EETM platform administrators, operators and developers. Its brand new OSGiTM-based architecture, combined with [OW2 JASMINe>http://jasmine.ow2.org], enables complex but non-intrusive administration operations on production environments. Its powerful and dynamic clustering solution is adaptable to any kind of usage. Furthermore, it relies on recent and robust components such as Apache Tomcat, OW2 JORAM, Apache CXF and Apache Felix. Finally, its EJB3 container [EasyBeans>http://www.easybeans.net] makes application development and deployment even easier.

JOnAS 5.1.0 is the result of wide and fruitful open development community whichcombines research and work from its members across Europe (Bull, France Telecom, Serli, INRIA, LIFL, UJF, UPM), Brazil (UNIFOR), and China (CVICSE, Peking University). The common objective is to provide a platform for the next level of dynamic SOAs, while solving today's enterprise needs for mission-critical scalability and availability.

This article aims at providing a walk through some of the JOnAS 5.1’s main innovations and highlight the major improvements compared to the JOnAS 4.x series. Some sections are oriented towards *developer's concerns*: benefits of [OSGi for a Java EE application>#HApplicationsadvantages], improvements in [IDE integration>#HIDEIntegration], new [deployment facilities>#HDeployment]. Other sections are dedicated *to software architects*: [versioning>#HVersioning] and [clustering>#HClustering] features as well as [web administration console>#HWebConsole] novelties.
1 The OSGi Shift
Nowadays, [OSGi>http://www.osgi.org] is gaining a lot of momentum, not without a reason: modularity (loose coupling), dynamism (dynamic bindings, module updates) and extensibility (hot plug/unplug) are key concepts of the OSGi universe.

Theses key properties are heavily used in the distributed and scalable architecture of the JOnAS 5 application server. Additionally, JOnAS 5 benefits from advanced research works in component and services models conferring a major differentiator to other open source or commercial servers.

OSGi is the core building block of the JOnAS platform, giving it a great flexibility, but it also offers tremendous advantages to user's application.
{image:logo-osgi-alliance.png}
1.1 Server flexibility JOnAS is the only Java EE application server natively built on top of OSGi. This inner OSGi nature grants to JOnAS a rare flexibility: entire parts of the server are designed as modules and can be deployed on demand. OSGi also enforces the usage of best practices (loose coupling, interface coding, limited dependencies...) and it provides JOnAS with a much cleaner Java EE implementation. Modularity is another key point for JOnAS: because of the module dependency control achieved by the OSGi framework itself (often described as 'ClassLoader on Steroïds'), JOnAS modules are more intrinsically independent, transforming JOnAS into an "à la carte" application server. The "à la carte" feature is the basis of the extensibility provided by JOnAS.

All theses capabilities, combined with the dynamism offered by OSGi, results in a lightweight (JOnAS core is < 10MB), extensible, adaptive and dynamic application platform: new modules can be added, on demand and at runtime.

This extensibility is not limited to the Java EE scope, but also makes of JOnAS the ideal basis platform for building SOA applications. Recently, two extensions have been provided which are typical SOA technical building blocks: * The Apache Camel extension bridges JOnAS and Camel together and makes mediation in an OSGi environment as easy as possible * The new Drools extension brings Rules and Event Processing inside of the application server, making easy the implementation of CEP (Complex Event Processing) oriented application. 1.1.1 On-demand Application Server
OW2 JOnAS comes with a number of native mechanisms to enable on-demand features.

For example, the web container (both Tomcat and Jetty) now supports lazy loading: the container itself is only loaded at the first web-app access and the web applications themselves are only started when required (when the first HTTP request hits the server side). This lazy loading also improves the server start-up time: only a handful of seconds are required to start a JOnAS instance.

Besides the lazy-loading feature of the web container, JOnAS also supports application-driven server composition. In other words, any application deployed by JOnAS can, just by adding a simple entry in its MANIFEST, influence the architecture of the server.

Any JOnAS service is described in an XML file (a deployment plan, more on this later) and this service can be referenced from the application.

The service management system will handle any service deployment required by an application: it will trigger the download of the artifacts (bundles or other types of archive, anything that can be deployed by JONAS) described in the plan, will activate them (start the service instances) and automatically link them together (dependency injection). Then the caller application deployment will be resumed.

Example of MANIFEST entry requiring the installation and start-up of 2 JOnAS technical services ('resource' and 'mail'): {code}Require-JOnAS-Services resource, mail{code}
On Demand service Figure 1. JOnAS On-demand Services
As the above sequence indicates, the JOnAS services can be added at runtime (hot deployment), just like any Java EE application. JOnAS services also declare their services dependencies just like any other Java EE application, using the 'Require-JOnAS-Services' Manifest entry. This is particularly useful for simplifying JOnAS configuration: all required service dependencies no longer need to be placed in the 'jonas.services' list since they will be automatically installed and started when needed, avoiding erroneous configuration and minimizing server memory footprint.

For example, in the above MANIFEST, declaring the 'resource' service will also trigger the 'wm' service installation (because the resource adapter container needs a WorkManager for its thread's pool). 1.1 Applications advantages Bridging OSGi and Java EE also offers some fairly compelling advantages for the applications. JOnAS supports the deployment of hybrid OSGi/Java EE applications, which is a unique feature in the domain of application servers. In clear words, a JOnAS application can be composed of EE modules, such as EjbJars, WebApplication, Resources, and also of OSGi modules (bundles): OSGi modules being unrestricted bundles (import/export packages, register services, listen to events, ...) and Java EE modules being standard compliant. The better part of this is that EJBs or Servlets can even use the OSGi services, enabling a Java EE application to gain dynamism!

This hybrid approach offers an integrated best of breed solution for agile enterprises: it leverages the strengths of Java EE (standard persistence, transaction handling, well known programming model based on annotations...) and the flexibility granted by OSGi.

Besides bringing Java EE benefits to OSGi, JOnAS also helps OSGi developers take advantages of Java EE. Java EE is a well known, enterprise concerns focused specification, it means that a number of issues that OSGi/enterprise developers have to face are already solved in Java EE: Transaction, Persistence and so on. JOnAS offers to OSGi developers the ability to provide their business code as standard EJB components, e.g. allowing them to benefit from transaction handling and from Ease of Development through annotations; moreover they also have the ability to provide these EJBs business interfaces as regular OSGi services, accessible from any other API compatible service. OSGi developers can natively benefits from JPA persistence that will be available behind a stateless EJB facade.

The reader is invited to take a look at the JOnAS Showcase ([article here>http://blog.akquinet.de/2009/07/27/jonas-showcase-having-the-best-of-jee-and-osgi/], [project here>http://code.google.com/p/jonas-showcase/]) that demonstrates the power of the Java EE/OSGi combination.

{image:jonas-showcase-arch.png}

Figure 2. JOnAS showcase architecture (courtesy of [akquinet AG>http://www.akquinet.de/en])
Here is a code sample of a Stateless EJB, packaged in a bundle. It exposes its business interface as an OSGi service, using transaction just like any other Java EE component, accessing JPA beans and other beans through Java EE standard annotations (@PersistenceContext, @EJB) and using OSGi services (@OSGiResource). {code} @Stateless @Local(IBuyService.class) // This interface will be published as OSGi service public class BuyServiceBean implements IBuyService { // Standard JPA injection @PersistenceContext private EntityManager em; // Standard (JNDI based) EJB reference injection @EJB private IDeliveryService delivery; // Dynamic OSGi service references injection // This reference is backed by an EJB exposed as service @OSGiResource private IWarehouseService warehouse; // Dynamic OSGi service references injection using LDAP filter @OSGiResource(filter="(name=org.acme)") private LogService log; // Use a non default transaction type for this method @TransactionAttribute(TransactionAttributeType.SUPPORTS) public void buy(String vendorId, int amount) { // Get the item provider from JPA Vendor vendor = em.find(Vendor.class, vendorId); // Order him vendor.addOrder(amount); // The warehouse should prepare the given amount of items List items = warehouse.prepare(amount); // The delivery service will deliver the prepared items delivery.deliver(items); log.info("Buy and deliver " + amount + " from " + vendorId); } }{code} 1 Ease of Development The EoD (Ease of Development) has been at the heart of the JOnAS components development strategy: a great care has been taken to satisfy application development requirements expressed by the JOnAS users community.

Thanks to the 'new' bytecode modification technologies in use within EasyBeans, even large EJB3 applications are deployed in a handful of seconds. This is a rather impressive improvement compared to the EJB2 Java sources generation and compilation approach that was much more time consuming.

The deployment process has also been re-worked. A brand new development mode has been introduced and provides developer dedicated tools aiming to reduce time between development iterations, allowing quick feedback on the code. The main feature regarding these deployment facilities is the new "auto deploy" directories: the user can define one or several auto deploy directories (default one is $JONAS_BASE/deploy/); theses are drop-in directories, meaning that any archive dropped in such a directory will be automatically deployed by the server. Moreover, any modification to observed archives will result in auto redeployment. As it can be expected, removing an archive from these directories will undeploy it without any further manual action. 1.1 IDE Integration The JOnAS [Eclipse>http://www.eclipse.org] and [NetBeans>http://www.netbeans.org] plug-ins have been heavily reworked during the JOnAS 5.x development phase to provide a best-of-breed integration and a seamless developer experience. 1.1.1 Eclipse (JOPE/WTP)
[JOPE (JOnAS Plugin for Eclipse)>http://jope.ow2.org/update/jope/] is the [Eclipse Server Adapter>http://www.eclipse.org/webtools/] dedicated to JOnAS. It is compatible with Europa, Ganymede and Galileo Eclipse/WTP releases and provides JOnAS 4 and JOnAS 5 support (configuration, server management).

The main objective of this plug-in is to significantly reduce development time and ease the work of application developers: * Java EE applications developed as Eclipse projects * Automatically performs packaging and deployment of applications on a JOnAS server when a project resource is modified * Supports hot deployment of WEB and EJB applications
Jope - JOnAS WTP Server Adapter
1.1.1 NetBeans (JOnbAS)
[JOnbAS>http://jonbas.sourceforge.net/] is the server plug-in allowing JOnAS to be tightly integrated within the NetBeans IDE. It frees the developer from time-consuming, hand-performed and highly repetitive tasks (deploy/undeploy at each iteration).

It supports JOnAS 4 and JOnAS 5 (using Tomcat as web container) and works with the latest versions of NetBeans (>= 6.5).

This plugin handle deployment and undeployment of NetBeans web projects, Enterprise Java Beans and Enterprise applications as easily as pushing a button. It is also able to manage JOnAS configuration (port number, ...).

JOnbAS includes several advanced functions: * Java and JSP debugging * Generating the default JOnAS deployment descriptors (jonas-web.xml and jonas-ejb-jar.xml) * Browsing deployed WAR, EJB and EAR modules * Accessing WAR and Servlets web page from NetBeans * Re-deploy an application when a project resource is modified ** Drastically reduce waiting time between development micro-iteration, improving feedback
JOnbAS - JOnAS NetBeans Plug-in
1.1 Build and test tools JOnAS can be used with many build tools, mainly for easy packing and testing of applications on JOnAS. 1.1.1 Maven OW2 JOnAS and most of its components (OW2 EasyBeans, ...) are now build using [Maven>http://maven.apache.org]. This system is easily extensible thanks to the Maven plug-ins, so JOnAS now provides a set of plug-ins that can help Java EE developers in some situations: * 'maven-wsgen-plugin': this plugin is useful for JAX-RPC (webservices for J2EE 1.4) developers: it applies the JOnAS' WsGen processor on their webservices enabled modules (generating webservices artifacts). * 'maven-genic-plugin': this plugin is useful for EJB 2.x developers: it applies the GenIC processor to their EjbJars module and produces RMI stubs and skeletons in addition to the JOnAS interposition classes. Besides of JOnAS, EasyBeans (EJB3 container) also provides a great maven plug-in. Those who likes the ease of use of the jetty plugin and miss that within the EJB3 development process will be pleased: the [maven-easybeans-plugin>http://fisheye.easybeans.org/browse/~raw,r=4942/EasyBeans/trunk/easybeans/plugins/maven-easybeans-plugin/documentation/index.html] is very simple to use, but also very powerful. It can start/stop an EasyBeans instance that will be used to deploy the project's artifact and then, during the integration-test phase, will launch EJB testing. 1.1.1 Cargo [Codehaus Cargo>http://cargo.codehaus.org] is a thin wrapper around Java EE containers. Cargo 1.0 ships with native support for many servers, including [JOnAS 5>http://cargo.codehaus.org/JOnAS+5.x].

Cargo can be used to configure, start and stop the Java EE containers. It has also support for deploying and undeploying many kinds of applications (WARs, JARs, EARs, RARs but also generic files; including OSGi Bundles).

Cargo can be run as part of any Java program, as an [Ant task>http://cargo.codehaus.org/Ant+support] or as a [Maven plugin>http://cargo.codehaus.org/Maven2+plugin].

Configurations supported by the [Cargo JOnAS 5 module>http://cargo.codehaus.org/JOnAS+5.x] include: * *Standalone local configuration*: creates a JONAS_BASE, starts the JOnAS server, deploys applications on top of it and stops the server. * *Existing local configuration*: starts the JOnAS server (with an existing JONAS_BASE), deploys applications on top of it and stops the server. * *Remote deployer*: connects to a remote JOnAS server (via remote JMX Connector or MEJB), supports application deployment and undeployment. Cargo is most used when doing integration tests. Some OW2 projects that use Cargo for these tests include: * The [JOnAS project's itests module>http://svn.forge.objectweb.org/cgi-bin/viewcvs.cgi/jonas/jonas/tags/JONAS_5_1_0/modules/itests/cargo/] does some tests with Java EE modules (WARs in particular) * [JASMINe Monitoring>http://jasmine.ow2.org] uses Cargo for testing tens of Java EE components (WARs, EARs and RARs) as well as OSGi bundles 1.1.1 Pax Exam
{image:pax-exam.png}
The [OPS4J Pax Exam plugin>http://wiki.ops4j.org/display/paxexam/] is useful for launching JOnAS and running JUnit-like tests on it.

The Pax Exam tools focus on the OSGi side of JOnAS, giving access to the BundleContext during the tests. This way, TestCases have total control on the OSGi context and services.

The [JOnAS with Tomcat exposed as an OSGi HTTPService>http://svn.forge.objectweb.org/cgi-bin/viewcvs.cgi/jonas/sandbox/jonas-tomcat-osgi-httpService/tags/jonas-web-container-tomcat-6.0-with-http-service-5.1.0/] subproject uses Pax Exam to test its OSGi HTTPService binding.
1 Focus on Features 1.1 Deployment JOnAS 5.1 provides an advanced deployment mechanism based on special XML files. The JOnAS deployment system is a highly configurable and extensible piece of software: it basically orchestrates the deployment of artifacts stored in repositories. Artifacts being the piece of code to be installed and referenced through a set of coordinates, repositories being locations where the system can find the artifacts. JOnAS comes natively with the support of simple (URL based) and maven2 (maven2 coordinates) repositories. Supported artifacts includes (but are not restricted to) any Java EE module (EjbJar, WebApp, ResourceAdapter, ApplicationClient, Application), OSGi bundles and handling of XML files.

Repositories are a kind of XML files supported by the deployment system, meaning that any repository can be added to the supported list, just by dropping a file in the deploy/ directory of JOnAS.

Deployment plans are another kind of XML files: they describe an ordered list of artifacts coordinates. Maven2 artifacts are supported (all M2 repositories will be searched until one can retrieve the artifacts).

A deployment plan's artifact have numerous useful options: * 'reloadable': tell the deploying system that the plan must be observed and that any change have to be applied. This is particularly helpful in a cluster/distributed environment where the main deployment plan can be shared on a central (therefore unique) location. * 'atomic': The deploying system must handle all the artifacts in this plan as if it was a unique resource: any failure in the deployment of a part will fail the whole plan.

A basic example is given: {code} /myproject/app2.ear ... com.mycompagny app2 1.0 ear ... {code}
{image:deployment-plan-thumbnail.png}

Figure 3. Example of deployment plan usage
1.1 Versioning 1.1.1 Rationale Today, many client applications and services are hosted on Java EE servers. The operational experience of a telco operator (OrangeTM) has shown that such applications constantly evolve along three main lines: typically weekly updates of parameters contained in the configuration files, weekly minor application updates and three-monthly major application updates.

For now, in order to carry out these updates, the application server must be stopped and re-started, leading to an interruption in the service and, in particular, users connected at the time are forced to disconnect.

JOnAS 5.1 tackles this high-availability problem for 24x7 critical applications by providing an advanced deployment facility on top of Tomcat and EJB containers. Through the versioning feature, Java EE applications can be migrated smoothly without interruption of service and without users' sessions being lost. 1.1.1 Principle Versioning feature enables dynamic redeployment of web applications in a single JOnAS instance (see Figure 1). * Deployment of a new version of an application does not require the undeployment of any previous version. * An unlimited number of versions of an application can be deployed simultaneously. * Users that were on a previous version keep on using that version as long as their session on that version is active (for example, as long as they have not finished buying items on the previous version of the online trade web site). This guarantees that no user data will be lost, and that if there is any problem with the new version the old version is still available instantly. * New versions of the application can be deployed using various strategies, for instance allowing testing of the new version by a small community to ensure its readiness for production.
{image:versioning.png}

Figure 4. Web application version routing
The design relies on the following concepts: * The versioning mechanism is enabled if the 'versioning' service is started and if an application is considered as being versioned, ie. if its archive (ear, ejb-jar or war) has the '''Implementation-Version''' attribute defined in its MANIFEST file. * Each version of application is associated with a virtual context (user context) shared by all versions, and a versioned context, specific to each version and built from the Implementation-Version. When accessing through the virtual context, the requests are intercepted and the versioning routing is applied. * Each version of the application is associated with a versioning policy: ** *Reserved* enables only access from the versioned context ** *Disabled* enables access through the user context only for the existing session ** *Default* enables access through the user context by all clients that do not fit in any other policy (new sessions) 1.1 Clustering JOnAS provides full scalability and high availability thanks to End-to-End Clustering solutions (Web and EJB / Load Balancing and HA). Load-balancing is achieved on the web side with mod_jk/mod_proxy_balancer, and on the EJB side with the OW2 CMI project. Web session replication is achieved through Tomcat mechanisms while EJB2/EJB3 replication is implemented by the JOnAS HA Service (currently JGroups based, and in the future Terracotta and Pair to Pair based). JOnAS clustering is characterized by its flexibility, ease of use and dynamic configuration features.

EJB3 clustering can be fully configured with annotations (@Cluster, @Policy, ...). {code} @Stateless @Remote(StatelessRemote.class)‏ @Cluster(name="mycluster")‏ @Policy(RoundRobinPolicy.class)‏ public class StatelessBean implements StatelessRemote { public String bm(String msg) { ... } }{code} The load balancing logic is not wired in the stubs, but is dynamically downloaded by the clients from the server, and consequently can be changed at runtime, through the console. Different load-balancing policies are available such as round robin, first available, ha singleton, random and the user can define its own policies as well. A « smooth stopping » feature is provided for cluster nodes, meaning that one server belonging to a cluster can be disabled and finally stopped without service/session interruption.

Moving from standalone to cluster mode can be now totally transparent for client. The whole configuration is driven from the server side and is accessible through the management console which permits to control the cluster nodes as well.

To quickly builds a cluster, JOnAS provides a simple command line tool named newjc for generating a collocated configuration (single machine), [JASMINe Design>http://jasmine.ow2.org] provides an Eclipse based graphical tool for describing and deploying much more complex and distributed configuration.

{image:jasmine-design-thumbnail.jpg}

Figure 5. JASMINe Design
1.1 Web Console
The JOnAS web administration console (jonasAdmin) has been refactored to benefit from a fresh re-looking. The new console offers a WebOS-like user interface providing a highly responsive and ergonomic Flex based (Adobe Flash) user experience.

After the login, the main page presents a web desktop: available console's features (modules) are on the left, a tasks bar is displayed at the bottom leaving enough space in the center for multiple windows. The tasks bar offers windows organizing buttons (cascade/tile) helping to quickly switch between windows as well as a notification area that keeps the user informed about system feedback.

This new console is modular and easily extensible (see the JDBC connection leaks extension). It marks the beginning of a new era of harmonization between jonasAdmin and [JASMINe>http://jasmine.ow2.org]'s monitoring console (EoS).

Moreover, this generation of web console provides more dynamism and usability as well as a better user experience.
jonasAdmin - JOnAS Web Administration Console

Figure 6. JOnAS Web Console
1.1 Java EE 6 Ready The Java EE 6 specification, that promotes more lightweight and modular application server products through the concept of profiles will be finalized in November 2009, but the current JOnAS architecture already provides similar concepts. They are called dynamic profiles, because profiles can be dynamically added to a running JOnAS platform.

The JOnAS Java EE6 profiles will be built on top of the fundamental micro profile that provides the core of JOnAS, offering standard profiles (Web profile and Full profile) as well as user provided profiles (Building an application server for/around an application).

The next major version (JOnAS 6) will be Java EE 6 certified. 1 Conclusion All of the nice features described above are part of OW2 JOnAS 5.1.0 ! This version provides a graphical installer (IZPack powered) that eases the way to quick start a JOnAS: it handles JOnAS configuration (using as input the port numbers provided by the user), creates shortcuts (works with multiple OSs) and start the newly generated configuration in one click.

This latest release of JOnAS is declared as stable (and as bug free as possible). It has been extensively tested on different platforms and JDKs (from Solaris to Windows, adding platform available JDKs into the mix) to guarantee its platform neutrality.

To conclude, JOnAS is a pure open source project hosted by OW2, an independent industry consortium dedicated to developing Open Source code middleware. It benefits from a worldwide developers and users community. It is an enterprise class application server, supported by industrial contributors and users, and providing advanced key features in the area of administration and clustering. JOnAS now adopts a native OSGi architecture, providing modularity and flexibility; it is implemented as a set of OSGi bundles, with technical services implemented as OSGi services.

The new server architecture allows new services to be added, or JOnAS provided services to be replaced by alternative service implementations. Services can be started, stopped and re-configured at runtime.

JOnAS re-uses several other OW2 projects ([JORAM>http://joram.ow2.org], [Carol>http://carol.ow2.org], CMI, Util) and is tightly coupled to two other OW2 projects, [EasyBeans>http://www.easybeans.net] the lightweight EJB3 container and [JASMINe>http://jasmine.ow2.org], a powerful tool for designing, configuring, deploying and monitoring JOnAS clusters. It is also the cornerstone of the OW2 reference architecture, combining middleware components and targeting dynamic SOAs which are the basis of the flexible, self-adapting information systems of tomorrow.

JOnAS answers the needs of organizations that want to deploy open Java EE application services, while benefiting from the low TCO, the innovations, the flexibility and the large solution ecosystem of a leading international open source software community.



Thank You