EJB/J2EE Frequently Asked Questions (FAQ)

17-654: Analysis of Software Artifacts
18-846: Dependable Distributed Middleware Systems

 

Created 1/26/04

Updated 2/5/04

Author Mike Merideth (mgm @ cs.cmu.edu)

Version 1.1

 

Strong words of caution: If you have never programmed in Java before, werecommend that you consider using CORBA rather than EJB to make your learningcurve easier.  See the CORBA FAQ(can be accessed via Blackboard).

Overview: How can I get started with EJB? 1/26/04

 

You should choose an application server and then try atutorial targeted for that server; I suggest JBossand the O’ReillyJBoss Workbook.  See morecomplete answers later in this FAQ.

 

Which should I use, JBoss or the J2EE Reference Implementation (orsomething else)? 1/26/04

 

This is a personal choice and depends on your level ofexperience with the products.

 

That said, I have been experimenting with the two (JBoss andJ2EE), and, for new users, I am going to have to recommend JBoss, as it wouldappear to be used in production environments more frequently and has a moreactive user base.  It is also easier to install on the game/asl labmachines.  The J2EE reference implementation is not intended forproduction use (and, based on anecdotal evidence, seems to put a larger load onthe machines). The more recent versions of JBoss also have Eclipse integrationthrough JBoss-IDE.

The JBoss binaries (and source) are available for free download at http://www.jboss.org/downloads.

 

There is a summary of free and open source tools for EJB here.

 

Do we have an instance of a J2EE application server for class use?  How can I install JBoss?  How can I install the J2EE referenceimplementation? 1/26/04

 

First, do we have an installed J2EE application server? Yesand no.  We have JBoss installed at/afs/ece/class/ece846/java/jboss-3.2.3.  Thegeneral problem is that each team that decides to use this installation ofJBoss will need its own deployment/server directory created in a location thatis not writeable by the class. 

 

We have also cached a copy of the 3.2.3 binary distribution (/afs/ece/class/ece846/java/jboss-3.2.3.tgz). Installing this is as simple extracting this archive to your localdirectory.  See either the O’ReillyJBoss Workbook or GettingStarted with JBoss for more information.

 

In summary, JBoss is very easy to install, so, you have twooptions: (1) you can install JBoss in your own directory, or (2) if you contactMike Merideth, he will set up a server instance in the ece846 JBoss installation for youthat points to one of your own directories.  If you choose option (2) you will still be able to start,stop, and configure your own instance directories, but you will not have fullcontrol of the JBoss distribution. However, option (2) will save you approximately 50M of disk space (andmay ease some aspects of administration).

 

After some experimentation, wehave decided not to support a common installation of the J2EE referenceimplementation application server. However, you can download it for linux, windows, or solaris from http://java.sun.com/j2ee/1.4/download.html#sdk.  If the linux version fails to installbecause it thinks that your JRE is invalid, see http://forum.java.sun.com/thread.jsp?forum=136&thread=468069&message=2190181and then set your LD_LIBRARY_PATH to include the extracted package directory.

 

How can I start using JBoss quickly? 1/26/04

 

We will be covering this in the J2EE recitation, in which wewill borrow material from the O’ReillyJBoss Workbook.  This link showscommands and output that I captured while working through example 4.1. You canalso look at the following:

 

O’Reilly Tutorials

http://www.oreilly.com/catalog/entjbeans3/workbooks/index.html

 

JBoss.org Quick StartGuides

Getting Started with JBoss (3.2.x servers) 

http://jboss.org/docs/jbossj2ee.pdf

 

Others:

 

Jumping Into JBoss

http://www.developer.com/java/ejb/article.php/3071661

 

Thread discussing running the J2EE examples on JBoss

http://www.jboss.org/index.html?module=bb&op=viewtopic&t=19436

 

How can I start using the J2EE Reference implementation quickly? 1/26/04

 

The J2EE 1.4 Tutorial(Chaper 18)  (June 2003)

About This Tutorial -> About the Examples -> Buildingand Running the Examples (Gives important information on configuring yourenvironment)

http://java.sun.com/j2ee/1.4/docs/tutorial/doc/

 

Developing EnterpriseApplications Using the J2EE Platform(August 2002)

This tutorial updates and expands the tutorial "WritingEnterprise Applications for the Java 2 Enterprise Edition (J2EE) ReferenceImplementation" originally written by Monica Pawlan in June 2000. Thetutorial provides an introduction to the Java 2 Enterprise Edition (J2EE)Platform.

http://java.sun.com/developer/onlineTraining/J2EE/Intro2/j2ee.html

 

Writing EnterpriseApplications for the Java 2 EnterpriseEdition Reference Implementation by Monica Pawlan - Release Java 2, version1.2.1 (June 2000)

This tutorial introduces you to the APIs, tools, andservices provided in the Java 2 Enterprise Edition (J2EE) ReferenceImplementation.

http://java.sun.com/developer/onlineTraining/J2EE/Intro/

 

What are other sources for information on EJBs? 1/26/04

 

EnterpriseJavaBeans (EJB) Technology Fundamentals (May 2000)  (jGuru)

http://java.sun.com/developer/onlineTraining/EJBIntro/

 

EnterpriseJavaBeans  Tutorial by Tom Daly& Uday Shetty — Release Enterprise  JavaBeans 1.0 (Feb 1999)

Learn how to write a simple session Bean using theEnterprise JavaBeans component model.

http://java.sun.com/developer/onlineTraining/Beans/EJBTutorial/index.html

 

Java tutorials

http://java.sun.com/developer/onlineTraining/index.html

 

TheServerSide.com

http://www.theserverside.com/articles/index.jsp

 

Which version of the JDK are we using for the project? 1/26/04

 

We highly recommend that you stick to using JDK 1.4.2 onLinux for your software development. If you need Linux machines to run your software on, please contact theinstructor.

 

Is there IDE integration for JBoss? 1/26/04

 

Yes.  Eclipseintegration has been added recently. See JBoss-IDE.

 

Is there an easy way to run multiple instances of JBoss on the same machine yet not have the port numbers conflict? 2/5/04

 

You should use the BindingService.  Read the following instructions, or click here for more information.

 

Preliminaries: My JBOSS_HOME variable is set to /afs/ece.cmu.edu/class/ece846/java/jboss-3.2.3/

 

There is a file called ${JBOSS_HOME}/docs/examples/binding-manager/sample-bindings.xml.  This file specifies a number of jboss port configurations such as ports-default, ports-01, and ports-02. Please note, however, that the number of port configurations is less than the number of groups in the class using the installed version of jboss.  Therefore, you should create your own configuration, following the conventions (increment the second digit of each port number in the configuration, i.e., ports-default specifies port 8080 for the web server, ports-01 specifies 8180, and ports-02 specifies 8280).  You must update the value of each of the ports in the configuration, not just port 8080.

 

To use a port configuration from sample-bindings.xml, you must make a few modifications to the file ${JBOSS_HOME}/server/<your-server>/conf/jboss-service.xml.  Find the section of the file that looks like the XML code below.  Note that <!-- is an open comment character in XML, and --> is the close comment character.  Therefore, notice that this section is currently entirely commented out.  Instead, you want only the textual description to be commented out.  Once the XML code is uncommented, you should specify the port configuration that you want to use.  By default, once this code is uncommented, the system will use the ports-01 configuration.  Instead, choose the port configuration that you want from your modified sample-bindings.xml file.

 

   <!--

      | Binding service manager for port/host mapping. This is a sample

      | config that demonstrates a JBoss instances with a server name 'jboss1'

      | loading its bindings from an XML file using the ServicesStoreFactory

      | implementation returned by the XMLServicesStoreFactory.

      |

      | ServerName: The unique name assigned to a JBoss server instance for

      | lookup purposes. This allows a single ServicesStore to handle mulitiple

      | JBoss servers.

      |

      | StoreURL: The URL string passed to org.jboss.services.binding.ServicesStore

      | during initialization that specifies how to connect to the bindings store.

      | StoreFactory: The org.jboss.services.binding.ServicesStoreFactory interface

      | implementation to create to obtain the ServicesStore instance.

 

   <mbean code="org.jboss.services.binding.ServiceBindingManager"

     name="jboss.system:service=ServiceBindingManager">

     <attribute name="ServerName">ports-01</attribute>

     <attribute name="StoreURL">../docs/examples/binding-manager/sample-bindings.xml</attribute>

     <attribute name="StoreFactoryClassName">

       org.jboss.services.binding.XMLServicesStoreFactory

     </attribute>

   </mbean>

 

   -->

 

What is Enterprise JavaBeansQuery Language? 1/26/04

 

It is used to define the abstract schema for an entity bean.

 

I have been reading the JBoss documentation and have come across the termXDoclet.  What is the purpose ofXDoclet? 1/26/04

 

Intuitively, for our purposes, XDoclet allows you to workwith a single file (the EJB implementation) and manage the creation of otherrequired EJB files via JavaDoc comments.

 

GettingStarted with JBoss states that EJB XDoclet tags can be used to generate

 

  EJB andvendor (JBoss, WebLogic, WebSphere, Orion) specific

deploymentdescriptors

  Home andRemote Interface

  PrimaryKey Class for Entity Beans

  BulkData Object (also know as Value Object)

  EJBWrapper classes

 

Why do I see JNDI names that begin with ‘java:’ in client access code?  How does the system know which serverto look for? 1/26/04

 

Theexamples in the O’Reilly workbook use a jndi.propertiesfile for each example which specifies theserver location.  The classpath tothe jndi.properties file is set in the ant script to include thisproperties file.

 

More information (from Getting Started with JBoss):

 

   In J2EE we have two types of clients; the web clientis a

   composition of servlets and JSPs, and other clientsrunning outside

   of the application server. The separation is importantbecause web

   clients can take advantage of running inside theapplication server

   like accessing the local (java:) namespace of the JNDIserver or

   using local interfaces on EJBs.

 

Can an EJB get services from its container? 1/26/04

 

According to http://java.sun.com/developer/onlineTraining/EJBIntro/EJBIntro.html#EJBContainer,an EJB can access its container in one of three ways:

·        Callbackmethods

·        EJBContext

·        JNDIENC