Packaging the Enterprise Bean

The next few sections show how to package and deploy the enterprise bean and run the sample client in WebLogic Server. The corresponding steps for JBoss are presented later today.

The following snippet shows the directory structure for the SignOn bean files for WebLogic Server:

C:styejbexamples
              day05
                   SignOn.java
                   SignOnHome.java
                   SignOnEJB.java
                   InvalidLoginException.java
                   ejb-jar.xml
                   weblogic-ejb-jar.xml

For JBoss, replace the vendor-specific weblogic-ejb-jar.xml file with jboss.xml.

As you learned on Day 2, packaging is the process of assembling the enterprise bean files into an ejb-jar file. To package the SignOn component, you must perform the following steps:

1.
Set up the environment for the build in a new command window using the following commands:

								C:>cd styejbexamples
C:styejbexamples>setEnvWebLogic.bat
C:styejbexamples>cd day05
C:styejbexamplesday05>

Caution

Getting the proper environment is necessary to run the example correctly. You can verify the environment by using the env command as follows:

C:styejbexamplesday05>env
APPLICATIONS=c:eaweblogic700configmydomainapplications
CLASSPATH=C:eajdk131_03lib	ools.jar;
c:eaweblogic700serverlibweblogic_sp.jar;
c:eaweblogic700serverlibweblogic.jar;
c:eaweblogic700samplesserverevalpointbaselibpbserver42ECF17 2.jar;
c:eaweblogic700..;. . .
PATH=c:eaweblogic700in;C:eajdk131_03in;. . .

Make sure that the environment variables PATH and CLASSPATH point to valid directories.

2.
Create a stating area for the build using the following commands:

C:styejbexamplesday05>mkdir build buildMETA-INF
C:styejbexamplesday05>copy %STYEJB_HOME%day05ejb-jar.xml buildMETA-INF
C:styejbexamplesday05>copy %STYEJB_HOME%day05weblogic-ejb-jar.xml buildMETA-INF
							

The preceding commands create a build directory in which the compiled files and deployment descriptors will be placed before they are packaged into an ejb-jar file. The .xml files are placed under META-INF within the build directory.

3.
Compile the Java files using the following commands:

C:styejbexamplesday05>javac -g -d build SignOn.java SignOnHome.java SignOnEJB.java
 InvalidLoginException.java
							

4.
Package the enterprise bean files into an ejb-jar file using the following commands:

C:styejbexamplesday05>cd build
C:styejbexamplesday05uild>jar cv0f tmp_day05_SignOn.jar META-INF day05
C:styejbexamplesday05uild>cd ..
							

5.
Generate the container classes using the WebLogic tool ejbc as follows:

C:styejbexamplesday05>java weblogic.ejbc -keepgenerated -g
								-deprecation build
	mp_day05_SignOn.jar buildday05_SignOn.jar
							

The ejbc tool generates and inserts the container classes into the ejb-jar file day05_SignOn.jar. The ejbc tool is specific to WebLogic.

The day05_SignOn.jar file is now ready for deployment into WebLogic Server.

Deploying the Enterprise Bean

The process of installing and customizing the ejb-jar file in the EJB container is known as deploying. To deploy the day05_SignOn.jar file into WebLogic Server, you must perform the following steps:

1.
Start WebLogic Server in a new command window as follows:

C:>cd styejbexamples
C:styejb>setEnvWebLogic.bat
C:styejb>startWebLogic.bat
								

Caution

You must wait for the application server to completely start before proceeding to the next step. For example, WebLogic Server displays the following message when it is completely started and ready to accept client requests:

<Notice> <WebLogicServer> <Started WebLogic Admin Server "myserver"
for domain "mydomain" running in Development Mode>

2.
Deploy the component by copying the ejb-jar file into the WebLogic applications directory. You can deploy the bean in the same command window you used for packaging the bean by using the following command:

C:styejbexamplesday05>copy buildday05_SignOn.jar %APPLICATIONS%
								

We use the hot deployment feature of both WebLogic (version 6.1 and higher) and JBoss (version 2.4 and higher). Deployment is performed by simply copying the bean's JAR file into the application deployment directory.

Note

You can verify the bean deployment by using the WebLogic administrative console (http://localhost:7001/console). When prompted, enter system as the username and administrator as the password. In the left panel, click mydomain->Deployments->EJB. If the day05_SignOn.jar is properly deployed, you should see it under the EJB node. Click on day05_SignOn to see more information about it. Figure 5.3 shows a corresponding screen shot.

Figure 5.3. Enterprise bean deployment verification in WebLogic Server.



The following shows the contents of the ejb-jar file:

META-INF/
        ejb-jar.xml
        vendor-specific deployment files
day05/
     SignOn.class
     InvalidLoginException.class
     SignOnHome.class
     SignOnEJB.class

The ejb-jar file includes the standard deployment descriptor ejb-jar.xml, and other vendor-specific files such as weblogic-ejb-jar.xml, under the directory META-INF. In addition, it contains the class files for each enterprise bean, such as home and component interfaces, enterprise bean classes, and any dependent classes.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.164.34