Skip navigation.
Downloads | Product Documentation | Support

WebLogic Builder Online Help

# Porting and Deploying Applications with WebLogic Builder

This tutorial shows you how to rapidly deploy Sun's BluePrint wireless application Smart Ticket to WebLogic Server using the WebLogic Builder utility. WebLogic Builder is a visual environment that enables you to generate and edit deployment descriptor files. Smart Ticket is a J2EE application that lets you browse and purchase movie tickets using a wireless device such as a cell phone. Smart Ticket has both web application and EJB components.

In particular, the tutorial shows how to:

- Generate and edit Smart Ticket's deployment descriptor files using WebLogic Builder
- Configure Smart Ticket's data sources using the WebLogic Server Administration Console
- Run Smart Ticket on WebLogic Server using a device emulator in the J2ME Wireless Toolkit

This tutorial contains the following sections:

- Prerequisites
- Procedures
- Big Picture
- Best Practices
- Related Reading

# Prerequisites

Before starting this tutorial:

- Read about Java Smart Ticket 1.1.1 at http://java.sun.com/blueprints/wireless/ .
- Read about WebLogic Builder at WebLogic Builder Online Help.
- Install Java 2 Platform, Micro Edition 1.0.4_01 at http://java.sun.com/j2me/docs/.
- Install and start WebLogic Server. See http://www.bea.com.

# Procedures

Follow these steps to deploy Smart Ticket on WebLogic Server.

- Step 1: Set up your applications and environment.
- Step 2: Generate deployment descriptors for Smart Ticket.
- Step 3: Specify <context-root> for the web application.
- Step 4: Specify JNDI names.
- Step 5: Define Smart Ticket's data sources.
- Step 6: Deploy Smart Ticket on WebLogic Server.
- Step 7: Run Smart Ticket.

## Step 1: Set up your applications and environment.

In this step you install Smart Ticket and J2ME, Sun's Wireless Toolkit. You also set up your environment so you can build the application.

1. If you have not already done so, install and start WebLogic Server 8.1.

Download WebLogic Server 8.1 from `http://www.bea.com` and install it. The WebLogic Server installation directory, `c:\bea\weblogic810` unless you specify another location, is called `WL_HOME`.

2. Download and install Smart Ticket 1.1.1.

Download the Smart Ticket demo application source code at http://developer.java.sun.com/developer/releases/smarticket/. Extract it into a new directory on the same machine or accessible from `WL_HOME`. We will call this directory `SMARTICKET_HOME`.

3. Download and install J2ME to a location we will call `J2MEWTK_HOME` (say, `C:\J2mewtk`).

Download the Sun Wireless toolkit at: http://java.sun.com/products/j2mewtoolkit/download.html. Install the toolkit. During installation you will be prompted to select a JDK. You can select the JDK included in your `BEA_HOME/jdk141` directory.

4. Set `J2MEWTK_HOME=C:\J2mewtk`, assuming `C:\J2mewtk` is where you installed J2ME. Note: if you do not set `J2MEWTK_HOME`, you will not be able to build the application.
5. Set your environment by running the `setExamplesEnv` script located in `WL_HOME\samples\domains\examples`.
6. Open `SMARTICKET_HOME \smarticket\localant.bat` and add `"%CLASSPATH%"` to the end of the `ANT_CLASSPATH` line.
7. In the`SMARTICKET_HOME\smarticket` directory, build Smart Ticket by running `localant.bat`. . WebLogic Builder requires compiled`.class` files and cannot use `.java` files.

## Step 2: Generate deployment descriptors for Smart Ticket.

In this sequence, WebLogic Builder reads the deployment descriptor files that are included with the Smart Ticket application and introspects the application's `.class` files to create the deployment descriptor files that help an application to run on WebLogic Server.

WebLogic Builder will not overwrite the application's existing deployment descriptor files.

1. Open WebLogic Builder. In Windows select Start->Programs->BEA WebLogic Platform->WebLogic Server 8.1 | WebLogic Builder. In UNIX use the following command:

`startBuilder.sh`

2. In WebLogic Builder's File->Open menu, select the folder `SMARTICKET_HOME \build\server` and click Open. A dialog asks: "Unable to locate deployment descriptors. Would you like deployment descriptors created for you?" Click Yes to have WebLogic Builder introspect the Smart Ticket class files and generate `weblogic.xml` and `weblogic-ejb-jar.xml`.
3. Select File->Save.
4. In WebLogic Builder, create `smarticket.ear` by selecting File->Archive and specifying `SMARTICKET_HOME\bin\smarticket.ear`.

`smarticket.ear` is the application archive that you will configure and then deploy on WebLogic Server.

## Step 3: Specify <context-root> for the web application.

In this step, you set the Smart Ticket web application's context path using the `<context-root>` element.

1. In WebLogic Builder, select the \web node's Context Path tab.
2. In the Context Path text field, enter SmarTicketApp.

Now the application's `<context-root>` element is specified.

## Step 4: Specify JNDI names.

In this sequence, you assign JNDI names to references in the web application and in EJBs so that the data in the entity beans is accessible from the web application.

- to the web application's EJB references and resource references, and
- to the EJB resource references

1. Select Builder's EJB Refs panel in the J2EE Refs node, and specify the JNDI names for the EJB Refs as follows:

Reference Name | EJB Type | JNDI Name
--- | --- | ---
`ejb/MovieInfo` | `Session` | `MovieInfo`
`ejb/TicketSales` | `Entity` | `TicketSales`
`ejb/Customer` | `Entity` | `Customer`
`ejb/LocaleInfo` | `Session` | `LocaleInfo`

2. In the Resource Refs panel in Builder's J2EE Refs node, set the Ref Name, EJB Type, and JNDI Name according to the following table. Set the Resource Authentication Type to Container.

Reference Name | Reference Type | JNDI Name
--- | --- | ---
`jdbc/MovieInfoDataSource` | `java.sql.DataSource` | `MovieInfoDataSource`
`jdbc/TicketSalesDataSource` | `java.sql.DataSource` | `TicketSalesDataSource`
`jdbc/CustomerDataSource` | `java.sql.DataSource` | `CustomerDataSource`
`jdbc/LocaleInfoDataSource` | `java.sql.DataSource` | `LocaleInfoDataSource`

3. In the Resource References panel from Builder's EJB Resources node, set JNDI names for EJB Resources according to the following table.

Resource Reference Name | Resource Reference Type | JNDI Name
--- | --- | ---
`jdbc/MovieInfoDataSource` | `java.sql.DataSource` | `MovieInfoDataSource`
`jdbc/TicketSalesDataSource` | `java.sql.DataSource` | `TicketSalesDataSource`
`jdbc/CustomerDataSource` | `java.sql.DataSource` | `CustomerDataSource`
`jdbc/LocaleInfoDataSource` | `java.sql.DataSource` | `LocaleInfoDataSource`

4. In Builder, select File->Save to save changes to the archive.

## Step 5: Define Smart Ticket's data sources.

In this step, start the Examples server and use the WebLogic Server Administration Console to configure the Data Sources for each of the four EJBs the Smart Ticket application uses. Also in this step, replace Smart Ticket's Cloudscape database with the Pointbase RDBMS included with WebLogic Server.

The JNDI names for the data sources must match the JNDI names for the web application resource references and the EJB resources you set in Step 4.

1. Start the Examples server from: Start->Programs->BEA WebLogic Platform-> WebLogic Server 8.1->Server Tour and Examples->Launch Examples Server.

The Examples Server launches the WebLogic Server Examples page.

2. Open the WebLogic Server Administration Console by navigating to http://localhost:7001/console (or by following the link from the WebLogic Server Examples page), and sign in using username `weblogic` and password `weblogic`.
3. Select the JDBC node and click Tx Data Sources.
4. Select Configure a new JDBC Tx Data Source.
5. Enter a name for the data source. The first one is `MyCustomerDataSource`. Enter `CustomerDataSource` in the JNDI field. Enter `demoPool` as your Pool Name; this is the default connection pool that WebLogic Server examples use. Click Create.
6. Click the Targets Tab, then select the examplesServer in the Available column and click on the right arrow to target it. Click Apply.
7. Repeat steps 4 and 5 for the other three data sources (`MyMovieInfoDataSource`, `MyLocaleInfoDataSource`, and `MyTicketSalesDataSource`).
8. To replace Smart Ticket's Cloudscape database with Pointbase, the evaluation RDBMS included with WebLogic Server 8.1, add the following to `SMARTICKET_HOME\smarticket\populate.bat`:

>     set POINTBASEHOME=%SAMPLES_HOME%\server\eval\pointbase

>     java utils.Schema jdbc:pointbase:server://localhost/demo,database.home=%POINTBASEHOME% com.pointbase.jdbc.jdbcUniversalDriver -u examples -p examples -verbose ./src/smarticketPointBase.sql

9. We are also making the `smarticket.sql` Pointbase friendly by replacing it with a script that substitutes "int" data types with "integer." Extract `smarticketPointBase.sql` from http://edocs.bea.com/wls/docs81/quickstart/smarticket-patch.zip and copy it into `SMARTICKET_HOME\smarticket\src`.
10. Set up the database by running `SMARTICKET_HOME\smarticket\populate.bat`.

## Step 6: Deploy Smart Ticket on WebLogic Server.

Now you are ready to deploy and run Smart Ticket on the WebLogic Server 8.1 Examples Server.

1. Specify the server for the application using the Connect to Server dialog in WebLogic Builder's Tools menu.

2. Deploy Smart Ticket by selecting Deploy Module from the WebLogic Builder tools menu.
3. Set the port in Smart Ticket's executable, `SMARTICKET_HOME\bin\smarticket.jad`, by replacing the given port number (8000) with the port number of the Examples server, which by default is 7001.
4. Optionally, open the J2ME Wireless Toolkit and select the default device and specify preferences. There are several options available for using the emulator.
5. Start `SMARTICKET_HOME\bin\smarticket.jad` by double-clicking it or by selecting Start->J2ME Wireless Application->Run MIDP Application and selecting it.

A J2ME wireless emulator, either the one you selected in step 4 or the default emulator, `DefaultGrayPhone`, appears. The Smart Ticket asks you to create a user account and log in.

## Step 7: Run Smart Ticket.

When creating a user account for the Smart Ticket Application, enter 95130 or 95054 for your zip code. Your password must be six characters long.

Try selecting the 'Poster' mode when you create an account; this will enable your phone or other wireless emulator to display a preview poster for the movies as you browse them.

# Big Picture

WebLogic Builder is a visual environment for generating and editing an application's deployment descriptor files. You can view descriptor files while you visually edit them in WebLogic Builder, and you won't need to make textual edits to the XML. See WebLogic Builder.

The sample application Smart Ticket illustrates how the J2EE platform interoperates with the J2ME platform to create enterprise applications that serve mobile client devices, such as cell phones, two-way pagers, and palmtops.

# Best Practices

View the progress and status of the Smart Ticket application on WebLogic Server by monitoring the Launch Examples Server command window that appeared when you started the server.

When selecting a device emulator from the J2ME Wireless Toolkit's Default Device menu, the DefaultGreyPhone is the easiest to work with.

If you are redeploying the Smart Ticket application, clear the database of the previous user's information. To do so:

1. Run the J2ME Wireless Ticket Utility (available from the Windows start menu, or as an executable in `J2ME_HOME/bin`.
2. Click Clean Database.
3. Restart Smart Ticket by double-clicking `SMARTICKET_HOME\bin\smarticket.jad` or from Start->J2ME Wireless Application->Run MIDP Application.

# Related Reading

See the procedure for porting Smart Ticket to WebLogic Server 8.1 without using WebLogic Builder: Java Smart Ticket Demo 1.1 at http://edocs.bea.com/wls/docs81/quickstart/smarticket.html.