Lab 6: Starting with EJB.  

Assignment 4 due May 11. 11:59 pm. 

Resources:

Basics

  1. Installing WebLogic server.

    Install Weblogic under your home directory using the script :

     /stage/classes/current/51024-1/pub/weblogic_install2009.sh

  2. To start your WebLogic server:

      cd $WL_HOME/samples/domains/wl_server
      startWebLogic.sh

    Note that it may take a few minutes for the server to start. Verify that your browser is running ( http://<machine>.cs.uchicago.edu:7001 ).

    To use the management console go to: http://<machine>.cs.uchicago.edu:7001/console   where <machine> is the host where you started your Weblogic server.  You'll need to enable applets for full functionality.

    Login using username = weblogic and password = weblogic.

A number of bean examples are already deployed.

IMPORTANT: To cleanly stop the server don't use Ctrl-C but:

Deploy a Stateless EJB 

  1. Take a look at the simple stateless session example in /stage/classes/current/51024-1/pub/EJB/HelloWorldExample/ .
  2. Copy this example somewhere to your home directory:
    mkdir $WL_HOME/samples/server/examples/src/examples/<YOUR_DIR>
    cd $WL_HOME/samples/server/examples/src/examples/<YOUR_DIR>
    cp -r /stage/classes/current/51024-1/pub/EJB/HelloWorldExample/ .
  1. Go to your bean directory:

      cd $WL_HOME/samples/server/examples/src/examples/<YOUR_DIR>/HelloWorldExample

    and use the magic Makefile to compile your bean (the building process briefly explained):

      make 

    this will create a jar file ejb_helloWorld.jar that contains all the compiled code needed for your bean and copy it to $WL_HOME/samples/domains/wl_server/autodeploy/

    It will also compile your client and put all .class file in the $WL_HOME/samples/server/examples/build/clientclasses/examples/helloworld directory  ( which  is already in your CLASSPATH).

    Then, for this example, you do not need to modify the deployment descriptors: ejb-jar.xml and weblogic-ejb-jar.xml but please take a look at them.

    1. You now need to deploy the bean.  There are a number of ways to do this.

    Info on deploying applications.  More info on editing deployment descriptors.

    1. Run your client:

        java -Djava.naming.factory.initial=weblogic.jndi.WLInitialContextFactory -Djava.naming.provider.url=t3://localhost:7001 examples.helloworld.HelloClient

      Also take a look at the server's output to see the sequence of methods called.

    2. A stateful  session example is available here: 

    /stage/classes/current/51024-1/pub/EJB/Count

     

    Assignment 4 (due May 11, 11:59 pm). Create and deploy your own Stateless EJB

    Now that you  have successfully deployed your first EJB, the next step is to create a bean yourself.  Implement and deploy the calculator from Lab 1 and 4 as an EJB.

    Submit your code in a gzipped tarball by the due date to the TAs (sravana@cs and soner@cs). Use the structure from milestone 1.