EJB Deployment Procedures
The process for deploying J2EE applications involves establishing environment variables, configuring server properties, compiling Java code, creating XML-based deployment descriptors, packaging archive files, and deploying archives to a J2EE server environment. I focus on the deployment of J2EE-based EJB applications in this article, which might differ slightly between vendor-specific application server implementations. However, the general procedure for deploying J2EE-based EJB applications assumes the following general steps:
Set J2EE server environment variablesEnvironment variables must be set for running a J2EE server environment and vary per vendor implementation and operating-system platform.
Configure J2EE server propertiesConfiguration properties for most J2EE server implementations can be set to suit your particular network and operating environment.
Compile J2EE EJB application codeAll J2EE EJB implementation, home, remote, and dependent utility code must be compiled using a standard Java compiler.
Create a J2EE EJB application deployment descriptorAn XML-based deployment descriptor is created according to the EJB application DTD. Some vendor products can create this file for you from a GUI-based configuration tool.
Create vendor-specific deployment descriptorsBecause no standard means exists to bind J2EE standard EJB reference names to a J2EE server's JNDI-based naming service, a vendor-specific deployment descriptor mechanism is required to perform this mapping. This deployment descriptor must map EJB reference names used by J2EE components to the actual JNDI names associated with EJB home interfaces. Other vendor-specific properties may also be set for customizing both session and entity beans. Vendors may provide a GUI-based means to configure these files.
Package J2EE EJB application codeThe EJB deployment descriptors, all compiled J2EE EJB implementation classes, all compiled J2EE EJB implementation interfaces, and all other compiled classes dependent on your EJBs need to be packaged into an EJB JAR file with a .jar extension. J2EE-based products might supply command-line or GUI-based utilities for this purpose.
Start the J2EE serverThe J2EE-compliant server must generally be started at this stage. The exact mechanism for starting a server is often vendor-dependent but can be as simple as invoking a single startup command from the command line.
Create a J2EE application deployment descriptorA J2EE application deployment descriptor must be created to collect one or more Web, EJB, and application client modules into a cohesive J2EE application. Many products will create this file for you automatically or via a GUI-based configuration tool.
Package J2EE application codeThe application and JNDI mapping deployment descriptor, Web applications, EJB applications, and application clients need to be packaged into an enterprise archive (EAR) file with an extension of .ear. Many products also create this archive for you automatically or via GUI-based development tools.
Deploy the J2EE enterprise application codeFinally, the integrated J2EE application is deployed to the J2EE server environment for access by enterprise application clients. This step is also often automated via GUI tools.