Lab 7 - Container-based Entity Beans

Milestone 3. due May 16, 11:59pm

In this lab you'll implement and use container-based entity beans. More specifically the following example demonstrates:

Part 1. Deploy and run the code example. The source code is in /stage/classes/current/51024-1/labs/lab7/Product. The bean client creates 6 separate products (beans) and retrieves back some of them. Then it removes them all.

Steps:

  1. More configuration stuff:

    At the bottom of your Weblogic start script (~/weblogic/weblogic700/samples/server/config/examples/startExamplesServer.sh), more precisely, right before this line

        . "${HOME}/weblogic/weblogic700/server/bin/startWLS.sh"

    add the following lines:

    # Stuff for Oracle --------------------
    CLASSPATH=$CLASSPATH:/opt/java/jdbc/oracle12.jar
    export CLASSPATH
    # -------------------------------------------

  2. Even more configuration steps:

For this:  stop your WebLogic server if it is running and add the following two definitions at the end of your configuration file (but before </Domain> tag):  ~/weblogic/weblogic700/samples/server/config/examples/config.xml

You'll need to replace the user name and password with your own username and password for the Oracle database.

<JDBCConnectionPool DriverName="oracle.jdbc.OracleDriver"
Name="MateiOraclePool"
Properties="user=YOUR_USERNAME;password=YOUR_PASSWORD;dll=ocijdbc9;protocol=thin"
Targets="examplesServer" TestTableName="Products" URL="jdbc:oracle:thin:@limani.cs.uchicago.edu:1521:cs51024"/>

<JDBCTxDataSource JNDIName="MateiJDBCTxDataSource"
Name="MateiJDBCTxDataSource" PoolName="MateiOraclePool"
RowPrefetchEnabled="true" Targets="examplesServer"/>

  1. Copy the example somewhere in your user space:
       
      mkdir <YOUR_DIR>
      cp -r /stage/classes/current/51024-1/labs/lab7/Product <YOUR_DIR>
       
  2. Compile:
        
    cd <YOUR_DIR>/Product
          make
this will create a jar file ejb_product.jar (in $WL_HOME/samples/server/config/examples/applications/) that contains all  compiled code needed for your bean. It will also compile your client and put all .class file in the $WL_HOME/samples/server/stage/examples/clientclasses/ directory  ( this is already in your CLASSPATH).  Please take a look at the Makefile to understand what's going on. The build process is explained in more detail here.
  1. For this example the you do not need to modify the deployment descriptors: ejb-jar.xml, weblogic-ejb-jar.xml or weblogic-cmp-rdbms-jar.xml but please take a look.  

    Notice in your deployment descriptors weblogic-cmp-rdbms-jar.xml the name of the table that will be used in this example. Please create this table with:

    create table Products (name varchar(50), productid varchar(50), description varchar(100), basePrice Integer)

  1. cd to your weblogic examples directory: ~/weblogic/weblogic700/samples/server/config/examples, and start WebLogic
  2. Run the client with ./run_client.sh or:

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


Work on Milestone 3: Implement your own entity beans that should take you closer to completing the final project ...