Tag Archives: JBoss

Review of JBoss AS 7 Configuration, Deployment and Administration

JBoss AS 7JBoss 7 is the latest Java EE application server to be released by Red Hat. Version 7 is certified against the Java EE 6 Web Profile and has been developed with productivity and speed in mind – the current version offering significant speed enhancements over previous versions. Not only is AS7 available as a download for developers, it is also an important aspect of Red Hat’s OpenShift Platform-as-a-Service (PaaS) offering. JBoss AS 7 Configuration, Deployment and Administration explains how to use all the components that make up the application server covering (as you would expect from the title) configuration,management, deployment and administration. Many of these features are different in AS 7 from previous versions of JBoss AS so this book is in invaluable resource. The book is aimed at administrators,developers and testers, so whatever your role, chances are you will find something useful in the book.

The book starts by showing how to download and install AS7. The procedure here is pretty much the same as for other versions of JBoss, so if you’ve used it before, you shouldn’t experience any problems here. What is different however is the structure of the application server itself and the tools used to interact with it. The first chapter of the book explains how the new server is different from previous releases and begins to explain the basics of the server.

After introducing AS7,the book continues to go further into depth on the configuration side of the server. Configuration of thread pools, logging, datasources and EJB etc. is all covered in depth. Plenty of sample XML and diagrams are used to help with the discussions. The book also includes a chapter on configuring and managing JBoss domains which includes useful reading for those implementing and installing JBoss servers.

One of the main pieces of functionality in an enterprise application is probably handled via the Web Container. The book provides plenty of details on how to configure the JBoss Web Container and includes sample Eclipse based source code showing how to create and deploy a basic web application. Note that the emphasis throughout the book is on how the application server can be configured and maintained and not on how to develop Java EE applications. It is useful, from a developer’s perspective,to occasionally see some source code to see the interaction with the server however.

In previous versions of the JBoss Application Server, managing the application server (for example creating datasources or JMS queues) was typically performed via manually editing XML files or via the JMX console. With AS 7,both a comprehensive CLI and Web Console are provided. The book contains extensive details of these together with details of how they can be configured.

For those interested in installing JBoss AS, the next few chapters will be extremely useful. Clustering and load balancing are described in-depth with many details included, for example different caching configuration and integration with Apache HTTP Server using mod_jk.

The final chapter of the book discusses cloud computing and how this relates to JBoss AS 7in the form of OpenShift Express and OpenShift Flex. The author explains these services and then shows how to deploy and manage a simple Java EE application to the services. Given the nature of cloud computing, I believe these chapters will be essential reading for most developers.

If you’re developing Java EE applications using JBoss AS 7, or planning to upgrade to AS 7 sometime soon, then I’d recommend this book. The book is useful to new users of AS 7 as well as to those that have been using the AS since it was first released as version 7 last year. Different sections of the book will appeal to different audiences(administrator, developer, tester etc.), but I think the use you’ll get from this book will be invaluable.

Recommended reading for all users of JBoss AS 7.

Thanks to Sean at Packt Publishing for sending me a copy of this book to review.

JBoss AS 7 Configuration, Deployment, and Administration by Francesco Marchioni. ISBN 978-1-84951-678-5

Creating Calendar Based Timers in Java EE 6

Java EE 6 allows developers to create application timers that are initialized when either a Stateless Session Bean, a Singleton Bean or a Message Driven Bean are deployed to the application server.

To indicate that a method on any of these beans is to be invoked on a timed basis, the method must be annotated with either the @Schedule annotation (for single timer schedules), or the @Schedules annotation (for multiple timer schedules).

The code below shows a very simple Stateless Session Bean configured with 2 scheduled timers. The first timer is configured with one schedule whereas the second is configured with 2 schedules.

package com.acme.timer;

import javax.ejb.Schedule;
import javax.ejb.Schedules;
import javax.ejb.Stateless;
import javax.ejb.Timer;

@Stateless
public class CalendarTimer {

  @SuppressWarnings("unused")
  @Schedule(second = "*/10",
            minute = "*",
            hour = "8-17",
            dayOfWeek = "Mon-Fri",
            dayOfMonth = "*",
            month = "*",
            year = "*",
            info = "Scheduled Timer")
  private void scheduledTimeout(final Timer t) {
    System.out.println(t.getInfo().toString() + " called at: " + new java.util.Date()); }

  @SuppressWarnings("unused")
  @Schedules({ 
    @Schedule(second = "15",
              minute = "*",
              hour = "8-17",
              dayOfWeek = "Mon-Fri",
              dayOfMonth = "*",
              month = "*",
              year = "*",
              info = "2nd Scheduled Timer"),
    @Schedule(second = "45",
              minute = "*",
              hour = "8-17",
              dayOfWeek = "Mon-Fri",
              dayOfMonth = "*",
              month = "*",
              year = "*",
              info = "2nd Scheduled Timer")
  })
  private void scheduledTimeout2(final Timer t) {
    System.out.println(t.getInfo().toString() + " called at: " + new java.util.Date()); System.out.println(); 
  }
}

As can be seen, the first timer is annotated with the @Schedule annotation. This annotation takes several parameters that define the timer schedule:

second Number of seconds: 0 through 59
minute Number of minutes: 0 through 59
hour Number of hours: 0 through 23
dayOfWeek Day of the week.  This can take textual values (Sun, Mon, Tue, Wed, Thu, Fri, Sat) or numerical values 0 through 7 (both 0 and 7 indicate Sunday)
dayOfMonth Day of the month. This can take textual values (1st, 2nd etc), or numeric values 1 through 31. Negative values can also be used to indicate days before the end of the month. The value Last can also be used to indicate the last day of the month.
month Month of the year. This can take textual values (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec) or numerical values 1 through 12
year The year. This can take numeric years in the format yyyy.
info Additional information passed to the timer function.

The table above shows the allowable values that can be used for each expression used to build up a schedule. These values can also be expanded into expressions to make more complex schedules.

Wildcard: A wildcard character (*) is used to indicate that the schedule will fire for every valid value of the specific operand. For example, setting the value second=”0″, minute=”*” would cause a timer to be invoked every minute at 0 seconds.

Lists: Comma separated lists of values allow timers to occur at every value in the list rather than at all valid values as specified by the wildcard character.  For example second=”0″, minute=”0, 15, 30, 45″ would cause a timer to be invoked every quarter of an hour.

Ranges: Hypen separated ranges allow timers to occur within the specified range.  For example dayOfMonth=”1-5″ would cause a timer to be invoked every day for the first 5 days of each month.

Intervals: Intervals are defined in the format start/interval and are valid only for hours, minutes and seconds.  An interval is defined as the start value for a timer and then the interval at which a timer will be invoked.  For example hour=”12/1″ would cause a timer to be invoked on the hour, every hour in an afternoon. It’s possible to combine the wildcard and interval expressions to cause a timer to be invoked every x hours, minutes or seconds.  For example  minute=”*/10″ would cause a timer to be invoked every 10 minutes.

The second method in the example above shows how 2 different schedules can be applied to a timer.  In this instance, the method is annotated with the @Schedules annotation rather than the @Schedule annotation.

JBoss AS 6 Released with support for Java EE 6 Web Profile

In case you missed the announcement last week, JBoss AS 6.0 has been released for General Availability. JBoss AS 6.0 provides an fully certified implementation of the Java EE 6 Web Profile Specification (JSR-316).

So, what does this give to Java EE developers exactly? JBoss AS 6.0 is the latest in the line of community supported Java EE application servers. From the first milestone release to the final release of AS 6 has taken nearly a year of development and testing.

JBoss AS is easy to install (simply unzip it) and run requiring only a compatible JDK to run. Configuration and management of JBoss AS can be done either via the excellent web based Administration Console, via XML file manipulation (this is particularly useful for integration with Maven or Ant) or via the command line Twiddle tool.

The Java EE Web Profile was designed to provide developers with all the tools that they need to build Rich Internet Applications. The Web Profile Specification describes the profile as offering:

a reasonably complete stack, composed of standard APIs, and capable out-of-the-box of addressing the needs of a large class of web applications.

The web profile mandates that the following APIs are available to developers:

  • Servlet 3.0
  • Java Server Pages (JSP) 2.2
  • Expression Language (EL) 2.2
  • Debugging Support for Other Languages 1.0
  • Standard Tag Library for Java Server Pages (JSTL) 1.2
  • Java Server Faces (JSF) 2.0
  • Common Annotations for the Java Platform
  • Enterprise Java Beans (EJB) 3.1 Lite
  • Java Transaction API (JTA) 1.1
  • Java Persistence API (JPA) 2.0
  • Bean Validation 1.0
  • Managed Beans 1.0
  • Interceptors 1.1
  • Contexts and Dependency Injection for the Java EE Platform 1.0 (CDI) 1.0
  • Dependency Injection for Java 1.0

JBoss AS 6 can be downloaded from here.

JBoss AS Server Configurations (all, minimal, etc.)

JBoss 5 is supplied with 5 different server configurations:

  • minimal
  • default
  • all
  • standard
  • web

When JBoss AS is started, the server configuration can be specified using the -cswitch, so for example, to start the minimal configuration, you would start JBoss as:

run.bat -c minimal

But what do the different configurations include? Each configuration contains a different set of services, for example clustering, which is only supported by the all configuration.

The JBoss Installation and Getting Started Guide contains details of what is in each different server configuration.