Welcome Guest!
Create Account | Login
Locator+ Code:

Search:
FTPOnline
Channels Conferences Resources Hot Topics Partner Sites Magazines About FTP RSS 2.0 Feed

Free Subscription to Java Pro

email article
printer friendly

Develop and Deploy a Simple EJB
Deploy an EJB with JBoss and build a client app that uses its service.
by Budi Kurniawan

Posted January 9, 2003

Those starting to learn Enterprise JavaBeans (EJB) often encounter problems with compiling their first enterprise bean and deploying it in their chosen J2EE server. First of all, compared to other J2EE technologies, the EJB learning curve is steep. Second, you have to deal with a number of files when writing an enterprise bean. Many EJB book authors enthusiastically talk about this technology in their first chapters, but few teach you how to get your first EJB running. Rather than discuss the EJB specification and technology, this article serves as a technical how-to that focuses on developing a simple EJB and deploying it with JBoss. Deploying with other J2EE servers follows the same path but with slight variation.

ADVERTISEMENT

EJB is one of the main technologies in J2EE. You've probably read a lot about this exciting technology, and now you're ready to take the next step: developing a real EJB and running it in an EJB container. You'll learn how to develop an EJB, deploy it, and build a client application that uses its service.

The EJB developed for this article is a simple one: It's called StringProcessor, and its only capability is to convert a string into upper case. That's right, given the input "ejb", StringProcessor will change it to "EJB". The important point here is to show the whole development process, so I'd like to keep the code simple. You can think of this small project as a proof of concept.

 
Figure 1. The Directory Structure for Your Small Project

You have to go through four steps to develop and deploy an EJB application:

  1. Write the classes for your bean.
  2. Write the deployment descriptor.
  3. Create a deployment file.
  4. Deploy the bean.

In addition, I'll show you how to build a client application so you can see your bean in action. I'll walk you through each step. To try this example, first build a directory called workspace that acts as your workspace. You'll put your bean classes in the com.javapro.ejb package, so you need to build several directories for the source files and Java classes (see Figure 1). After you finish the whole thing, the directories will contain 10 files (see Figure 2). Now shift your attention to the steps required to build your EJB.



Back to top













Java Pro | Visual Studio Magazine | Windows Server System Magazine
.NET Magazine | Enterprise Architect | XML & Web Services Magazine
VSLive! | Thunder Lizard Events | Discussions | Newsletters | FTP Home