Sams Teach Yourself BEA WebLogic Server 7.0 in 21 Days

Now, the next step is to configure your application domain to run your MVC application. You need to configure the connection pool in your domain and then deploy the EAR file.

Configuring the Connection Pool

Through the administration console, create a new connection pool called mvc_app_conn_pool. For this connection pool, specify the URL as jdbc:pointbase:mvcapp and the Driver Classname as com.pointbase.jdbc.jdbcUniversalDriver. Specify the user name of the Pointbase database in the properties as user=mvcapp. Specify the password of the database in the Properties attribute. Now, click the Testing tab, and enter the test table name Test. Select Test Reserved Connections and Test Released Connections. Select the server name in the Targets tab.

Your MVC application is a transactional one. Hence, you need to configure Tx Data Sources and not plain Data Sources. The Tx Data Sources link is under the Data Sources link. Create the Tx Data Source with the name mvcapp_tx_data_source and JNDI name mvc_app_tx_ds. Specify mvc_app_conn_pool as the connection pool name. Select Emulate Two-Phase Commit for non-XA driver. Also select Row Prefetch Enabled. Select the server name in the Targets tab. You have now deployed your Tx Data Sources, which are used in the MVC application.

Deploying Your EAR File

There are four methods of deploying your MVC application. You will do it each way. The first method is the hot deployment technique. The second method is the production deployment technique, also called two-stage deployment. The third method is to deploy your application using WebLogic Builder. Finally, the fourth method is to deploy your application via the command prompt using the weblogic.Deployer tool.

Hot Deployment

The hot deployment technique is the simplest and the fastest. It is meant for development purposes and is not recommended for production purposes. To employ this technique, put the EAR file into the applications directory of your mvc_app_domain. The server then automatically deploys your application. The server has to be running in development mode in order to perform a hot deployment.

Two-Stage Deployment

When an application was deployed in the WebLogic Server before the 7.0 release, the deployment sent a copy of the application to all the servers targeted by the deployment of this application. These would then deploy the application. If for some reason, such as a configuration pool not existing on one of these servers, the deployment of the application on one of these servers failed, the deployment state across all these servers would be inconsistent.

Now, with the two-stage deployment, the deployment first prepares all the targeted servers. This is called the preparation phase. The next phase, called the activation phase, activates the application across all these servers. Most errors in deployment are indicated in the preparation phase itself, and deployment of the application on the targeted servers does not proceed to the activation phase. If any error occurs in either of the phases, the deployment across the whole cluster fails. You can set the order of the applications' activation at startup.

You can carry out two-stage deployment in several ways. You'll first see how it can be done through the Administration Console.

Note

It is a good practice to test-deploy your Web components and EJB components separately. In this way, you can test whether your applications work properly. You can then deploy your whole EAR file, or you can deploy your application components separately. If you deploy your application components separately, they are considered to be separate applications.

The base application class loader loads the EJB component, whereas a child class loader is created to load the Web component. You will need to include the EJB remote and home interfaces within the Web component. The WebLogic Server uses stub and skeleton calls for calling the EJB classes. If you load your application as an EAR file, however, it is considered to be a single application, and a single class loader is used. In this case, you don't need to add the remote and home interfaces of the EJB component into the Web component. Also, the performance greatly improves when you deploy your application as a whole, rather than as components, because the WebLogic Server makes a direct Java method call by using call by reference to interact between the components. However, when your components are deployed as separate applications in order to avoid class loader conflicts, the WebLogic Server uses call by value and uses the RMI's subsystem to marshall and unmarshall facilities, even if the applications are within the same JVM. If you use EJB 2.0 local interfaces, you must deploy your application as an ear file.

Deploying Through the Administration Console

To deploy through the Administration Console, follow these steps:

  1. Log on to your WebLogic Administration Console.

  2. Expand the Deployments link in the left frame of the Administration Console.

  3. Click the Applications link in the left frame.

  4. Click the Configure a New Application link in the right frame.

  5. You will get a screen that guides you through the installation process. In Step 1, you will see a link to upload your EAR file through your browser. Click the link and upload your EAR file. The deployer uploads this file to a staging directory. You will be brought back to the earlier screen, and you will see a link to your EAR file in the listing, as shown in Figure 16.3.

    Figure 16.3. Listing of your EAR file for mvc_app_domain domain.

  6. Click the AirlinesApp.ear file, which is the deployable file for your MVC application. You will now be shown a screen with steps 3, 4, and 5, like the one shown in Figure 16.4.

    Figure 16.4. Selecting the targeted server, naming your application, and deploying.

  7. Select the server mvc_app_server and transfer it to the Target Servers select list box. (Note: If you had servers in a cluster and had to deploy your application on this cluster, you would get to see a listing of your available servers here, and you could select the servers on which you want your application to be deployed.)

  8. Name your application AirlinesApp. Be sure to name your application with this name because the web.xml file contains a mapping for your servlets and JSPs with this application name. If you decide to name it differently here, you will have to go back to your web.xml file, change it appropriately there, and perform the entire deployment procedure again.

  9. Click the Configure and Deploy button. This was the second phase of your deployment. If for any reason the deployer is unable to deploy your file, you will see a screen like the one in Figure 16.5. You must then look at the server console, and you will see a stack trace of the error, where you can understand where the error has occurred. Notice that in the Administration Console, you will see False under the column Deployed. You will see a link Edit Application Descriptor on the top of the page. You can edit your application.xml file through this link. You will also see buttons to undeploy and redeploy your application.

    Figure 16.5. An error in deploying the application through the Administration Console.

  10. Once your application is successfully deployed, you will see Running marked as the Status of your application in the Deployment Activity section of your Administration Console. You will see a screen similar to the one in Figure 16.6.

    Figure 16.6. Successful deployment of the MVC application through the Administration Console.

Deploying Through the WebLogic Builder

You can start your WebLogic Builder either through the Start Menu or through a command prompt. The link in the Start Menu calls the same command, which you will execute through the command prompt.

The command file to start the WebLogic Builder resides in the C:\bea\weblogic700\server\bin directory under the name startWLBuilder.cmd or startWLBuilder.sh file. To start this, open a DOS prompt, navigate to the directory containing the startWLBuilder file, and execute the command startWLBuilder.

When the builder starts up, select the AirlineApp.ear file through the File link in the toolbar. You will see a screen like the one in Figure 16.7.

Figure 16.7. Selecting the application file in the WebLogic Builder.

After selecting the file and deploying it through the WebLogic Builder, you will see a screen like the one shown in Figure 16.8.

Figure 16.8. Deployed application on WebLogic Builder.

Deploying Through the Command Prompt Using weblogic.Deployer

Open a DOS prompt and set the environment using the setEnv file in your domain directory. Deploy your application using the following command:

java weblogic.Deployer activate nostage source C:\MVC_Application\ deployable_components\AirlinesApp.ear user mvcappserver password mvcappserver

Категории