devxlogo

Get Started with JBoss Application Server

Get Started with JBoss Application Server

he JBoss Application Server is an open-source EJB solution that deserves your attention. Why? Because not only does the JBoss server have some impressive features that Weblogic, WebSphere, and the other big players don’t, it also boasts more than 50,000 downloads per month and more than 1,000 developers worldwide.

JBoss is a complete J2EE application server providing enterprise-class security, transaction support, resource management, load balancing, and clustering. Heard enough to consider JBoss a viable EJB solution for your environment? Then use this month’s 10-Minute Solution as a step-by-step guide through the installation and configuration of the JBoss Application Server. You’ll also learn how to deploy a simple session bean.

Note: You’ll need at least an intermediate understanding of Java, J2EE, and EJB to follow the instructions.



How can I get up and running with the JBoss Application Server?



Download, install, and configure the application server and then follow the simple “hot deployment” procedure.

Setting Up JBoss
JBoss 3.0 is currently in Alpha stage (and expected to make significant strides in the area of clustering). The current stable release is version 2.4.4.

The first step in getting up and running with JBoss is to download and install the server:

  1. Make sure you have a 1.3+ version of the JVM.
  2. Download the latest stable version of the JBoss distribution at http://www.jboss.org/.
  3. Uncompress the archive into the desired directory. An installation directory (JBoss-x.x.x/) will be created there.
  4. Create an environment variable (variable name: JBOSS_DIST) pointing to the location of the JBoss directory (variable value: path_to_jboss).
  5. Test the installation by executing the run script from the /bin directory.
When you start the server up, you should see a bunch of output from the script giving you more information than you could ever want about exactly what is going on with JBoss. Your eyes will glaze over from several screens of text scrolling past, but you’ll know everything went well if it ends with a single line indicating that the JBoss server started in a certain number of seconds. (Actually, you’ll want to glance back at the text output and make sure that no exceptions were thrown during startup).

One file note: If you want to configure the server security, transaction handling, database access, or resource management, use the jboss.jcml file under the conf/default directory.

Deploying a Simple Bean
JBoss has three deployment descriptors for declaring the deployment properties for enterprise beans:

  • ejb-jar.xml – This is the standard EJB deployment descriptor, declaring the available enterprise beans, their logical names, interfaces, and other deployment properties (security, transactions, etc.). For a look at a sample ejb-jar.xml file, click here.
  • jboss.xml – This optional file is used to specify a different JNDI name for a bean’s home interface. The default JNDI name for a bean is the ejb-jar.xml ejb-name element value.
  • jaws.xml – This file is necessary only for CMP entity bean deployment.

We are concerned with only the ejb-jar.xml and jboss.xml files.

Deployment Process
Ultimately, enterprise beans are packaged in a JAR file with the appropriate XML files in the META-INF folder. Most J2EE app servers require the deployment of an EJB JAR within a WAR file, and even within an EAR file. The process of packaging up an enterprise bean with deployment descriptors into a larger archive with its deployment descriptors can become rather complex. This process may be necessary in a production environment, but in development, you need quick, efficient deployment. JBoss provides the best of both worlds.

All you do to deploy EJBs in JBoss is drop the archive into the deploy directory. The JBoss engine immediately inspects the contents of the archive and attempts to deploy the bean(s). Undeploying is as easy as deleting the archive from the deploy directory.

Making the deployment process highly efficient are the following features:

  • JBoss supports the deployment of EJB JARs contained within WARs and EARs, but it also supports the native deployment of EJB JARs.
  • JBoss does not require the inclusion of the server-specific XML file unless you make specific changes.

Download this JAR file for a sample EJB application to test on your JBoss server.

Accessing a Bean
To access the deployed bean(s), take the following four steps:

  1. Write the client code.
  2. Set up JNDI environment settings for the client (best done via a JNDI properties file).
  3. Set up the classpath for the client and add the following file locations to it: jboss-client.jar, jnp-client.jar, EJB interfaces, and the directory where the JNDI properties file is stored (not the file itself, only the directory).
  4. Invoke the client.

Only the second step really needs to be discussed further. Two JNDI settings must be made, the initial context factory and the provider URL. These properties are best established in a JNDI properties file.

Once you have set up a jndi.properties file, you should place it in a directory and place that directory into the client’s classpath (the file itself should not, only the directory where the property file is located).

That’s it. You are ready to fire up the server, drop the JAR into the deploy directory, start the client, and invoke the EJB service.

Another Tool to Increase Productivity
The JBoss App server is a full-featured, J2EE app server with robust EJB support. It is the most popular and robust open-source EJB solution, and is packed with some interesting features that are bringing?and should continue to bring?attention to the software.

Downloading and installing JBoss should provide you with another tool to increase your productivity when developing J2EE and EJB. See you next month!

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist