      All Examples  All WebLogic Enterprise Connectivity Examples

WebLogic Enterprise Connectivity EJB Simpapp Example

package examples.wlec.ejb.simpapp

- Converter
- ConverterHome

- Client
- ConverterBean
- ConverterResult
- ProcessingErrorException
- ejbSimpappServlet

Deployment

- ejb-jar.xml
- weblogic-ejb-jar.xml

About This Example

This example demonstrates how to use WebLogic Enterprise Connectivity (WLEC) to access a WebLogic EnterpriseTM (WLE) CORBA object from a stateless Enterprise JavaBean (EJB) on WebLogic ServerTM (WLS). The example combines a WLS EJB and the WLE Simpapp example. There are two ways to run this example:

- From a Java application
- From an Internet client and servlet

The following figure illustrates the WLEC EJB Simpapp example.

When you run the WLEC EJB Simpapp example, the following events occur:

1. At startup:

   1. WLS creates a WLEC Internet Inter-ORB Protocol (IIOP) connection pool for the WLE Simpapp domain.
   2. The EJB ejbCreate method obtains a connection from the IIOP connection pool.

   The remaining steps are performed at run time.

2. If you are running this example from the Java application, the Java application sends a request, including an input string, to the EJB.

   or

   If you are running this example from an Internet client, the Internet client sends a request and input string to the ejbSimpapp servlet. The servlet sends the request and input string to the EJB.

3. Acting as a WLE client, the EJB:

   1. Activates the connection to the Simpapp domain.
   2. Invokes the desired operation on the Simple CORBA object with the data that it received from the Java application or servlet.

4. The Simple object performs the specified operation and returns the results to the EJB. The Simple object can perform two operations:

   - Accept a string and return the string in upper case.
   - Accept a string and return the string in lower case.

5. The EJB sends the results to the Java application or the ejbSimpapp servlet.

6. If you are running the example that uses the Internet client and the ejbSimpapp servlet, the servlet compiles the results into a dynamically generated HTML page and sends the page to the Internet client.

   If you are running the example that uses the Java application, the application displays the output.

How To Use This Example

This section describes how to set up and run the EJB Simpapp example.

Prerequisites

Install and set up the following:

- WebLogic Server (WLS)
- Java Development Kit (JDK)
- WebLogic Enterprise (WLE)

See Platform Support for WebLogic Enterprise Connectivity for information about the supported versions for each of these products.

Setting Up the Example

1. Build and run the WLE Simpapp sample.

   See the Java Simpapp Sample Application in the WLE documentation:

   1. Go to J2EE Topics on the Web.
   2. Scroll down and click Sample Applications.
   3. Click Java Simpapp Sample Application.

   The build procedure for the Java version of the Simpapp sample generates the client stubs and puts them in your working directory. Client stubs provide the programming interface for CORBA object operations.

2. Set up your WLS development environment as described in Setting Your Development Environment.

3. Copy the compiled WLE Simpapp client stubs to your WLS SERVER_CLASSES directory, where SERVER_CLASSES is an environment variable that you set when you set up your development environment. The files you need to copy are:

   - Simple.class
   - SimpleFactory.class
   - SimpleHelper.class
   - SimpleFactoryHelper.class
   - _SimpleStub.class
   - _SimpleFactoryStub.class

4. Build the ejbSimpapp EJB application.

   Run the build.cmd (Windows NT) or build.sh (UNIX) command in the SERVER_CLASSES directory. On UNIX, you might need to change the permissions on the build.sh file.

5. Copy the file ejbSimpapp.html into your registered document root, which defaults to myserver\public_html.

6. Register the servlet by adding the following properties to the weblogic.properties file:

   weblogic.httpd.register.ejbSimpappServlet=examples.wlec.ejb.simpapp.ejbSimpappServlet
   weblogic.allow.execute.weblogic.servlet.ejbSimpappServlet=everyone

   Additionally, to let everyone request HTML files by way of the servlet, add the following line to the weblogic.properties file:

   weblogic.allow.execute.servlet.file=everyone

   For information about the weblogic.properties file, see HTTP and Servlet Related Properties in the WebLogic Administrator's Guide.

7. Initialize an IIOP connection pool by modifying the weblogic.properties file.

   You can uncomment and edit the weblogic.CORBA.connectionPool.simplepool property in the weblogic.properties file. See Setting Up WebLogic Enterprise Connectivity.

8. Deploy wlec_ejb.jar by adding the wlec_ejb.jar file to the weblogic.ejb.deploy property in the weblogic.properties file.

   See Enterprise JavaBeans (WebLogic EJB) in the Administrator's Guide.

Running the Example

1. Modify classpaths:

   - Add wleorb.jar to CLASSPATH in %WL_HOME%\setenv.cmd (NT) or $WL_HOME/setenv.sh (UNIX).

   - Add %WL_HOME%\lib\wleorb.jar (NT) or $WL_HOME/lib/wleorb.jar (UNIX) to JAVACLASSPATH.

     If you are going to start WLS by running startweblogic, set JAVACLASSPATH in the startweblogic.cmd file (NT) or the startweblogic.sh file (UNIX). Otherwise, set JAVACLASSPATH by means of another method such as the command line or the NT System Properties dialog.

   For information about setting classpaths for WLS, see Setting Up and Starting WebLogic Server.

2. Start WLS in your server shell.

3. To run the example from the HTML client and servlet:

   1. Start a Web browser and enter the URL for ejbSimpapp.html.

      Depending on the location of ejbSimpapp.html, the URL might be something like http://localhost:7001/ejbSimpapp.html.

   2. On the HTML form:

      - Enter some text in either uppercase or lowercase.
      - Select the operation (TO UPPER or TO LOWER).
      - Click GO.

   3. Watch for the results. An uppercase string converts to lowercase and vice versa.

   To run the example from the Java application:

   1. In your development shell, execute the following command:

      java examples.wlec.ejb.simpapp.Client [url] [user] [password]

      The parameters are optional, but if any are supplied, they are interpreted in this order:

      url

        WLS URL. For example, t3://localhost:7001.

      user

        User name, default null.

      password

        User password, default null. It should be at least 8 characters.

      For more information, see the Client class.

   2. Watch for the results. The Java application generates output similar to the following:

          Beginning simpapp.Client...

          Start of Conversion for: It Works

          Converting to lower case: It Works

          ...Converted: it works

          Converting to upper case: It Works

          ...Converted: IT WORKS

          Removing Converter

          End simpapp.Client...

Related Documents

For information about WLS EJBs:

- Overview of WebLogic Enterprise JavaBeans
- BEA WebLogic Server Enterprise JavaBeans
- WebLogic Server EJB Design and Development
- Enterprise JavaBeans Examples

For information about WLE CORBA objects:

- The WLE CORBA Programming Environment:

  1. Go to Getting Started on the Web.
  2. Click The WLE CORBA Programming Environment.

- Developing WLE CORBA Applications:

  1. Go to Getting Started on the Web.
  2. Click Developing WLE CORBA Applications.

- CORBA Topics on the Web.

For information about the WLE Simpapp example:

1. Go to J2EE Topics on the Web.
2. Scroll down and click Sample Applications.
3. Click Java Simpapp Sample Application.

See also Using WebLogic Enterprise Connectivity.

Copyright © 2000 BEA Systems, Inc. All rights reserved. Required browser: Netscape 4.0 or higher, or Microsoft Internet Explorer 4.0 or higher. Last updated 4/25/00