Java Data Objects (JDO)

EJB and JDO

Session EJB Facade to JDO Objects

Gopalan Suresh Raj

Note
To work with any of these samples, you will need the following:
.........................................JDK 1.2 or higher (I use JDK 1.3.1)
.........................................PE:JTM - The Productivity Environment for JavaTM (from HYWY Software Corporation)
.........................................BEA Weblogic 7.0 (beta) J2EE Compliant Application Server

 

Note: This article assumes that the reader has already created the simple bank project using PE:J and JDO.

Before you start off, create a jar file of all the files in the enhanced folder, name the jar file bank.jar and place it in the enhanced folder (for me the enhanced folder is C:\run\projects\bank\enhanced\). My bank.jar contains all the .class, .jdo, and .map files present in the  C:\run\projects\bank\enhanced\com\hywy\samples\bank\ folder.

Session EJB Facade to JDO Objects
 Teller.java
 TellerHome.java
 TellerBean.java
 Client.java
 build.xml
 application.xml
 ejb-jar.xml
 weblogic-ejb-jar.xml

Build the Sample Application.

Command Prompt 
C:\run\projects\bank\enhanced\com\hywy\samples\ejb20\session\stateless>ant
Buildfile: build.xml

clean:
[delete] Deleting directory C:\run\projects\bank\enhanced\com\hywy\samples\ejb20\session\stateless\build
[delete] Deleting directory C:\run\projects\bank\enhanced\com\hywy\samples\ejb20\session\stateless\dist

init:
[mkdir] Created dir: C:\run\projects\bank\enhanced\com\hywy\samples\ejb20\session\stateless\build
[mkdir] Created dir: C:\run\projects\bank\enhanced\com\hywy\samples\ejb20\session\stateless\build\META-INF
[mkdir] Created dir: C:\run\projects\bank\enhanced\com\hywy\samples\ejb20\session\stateless\dist
[copy] Copying 2 files to C:\run\projects\bank\enhanced\com\hywy\samples\ejb20\session\stateless\build\META-INF

compile_ejb:
[javac] Compiling 3 source files to C:\run\projects\bank\enhanced\com\hywy\samples\ejb20\session\stateless\build
[mkdir] Created dir: C:\run\projects\bank\enhanced\com\hywy\samples\ejb20\session\stateless\build\com\hywy\samples\bank
[copy] Copying 10 files to C:\run\projects\bank\enhanced\com\hywy\samples\ejb20\session\stateless\build\com\hywy\samples\bank

jar_ejb:
[jar] Building jar: C:\run\projects\bank\enhanced\com\hywy\samples\ejb20\session\stateless\dist\teller_session.jar

ejbc:
[java] <Jun 2, 2002 2:02:48 PM EDT> <Warning> <EJB> <010054> <EJB Deployment: Teller has a class com.hywy.samples.ejb20.session.stateless.TellerHome
which is in the classpath. This class should only be located in the ejb-jar file.>
[java] <Jun 2, 2002 2:02:48 PM EDT> <Warning> <EJB> <010054> <EJB Deployment: Teller has a class com.hywy.samples.ejb20.session.stateless.Teller whi
ch is in the classpath. This class should only be located in the ejb-jar file.>
[java] ejbc successful.

ear_app:
[ear] Building ear: C:\bea\weblogic700b\samples\server\config\examples\applications\teller_session.ear

compile_webapp:
[javac] Compiling 2 source files to C:\bea\weblogic700b\samples\server\config\examples\applications\examplesWebApp\WEB-INF\classes

compile_client:
[javac] Compiling 3 source files to C:\bea\weblogic700b\samples\server\config\examples\clientclasses

all:

BUILD SUCCESSFUL

Total time: 8 seconds

C:\run\projects\bank\enhanced\com\hywy\samples\ejb20\session\stateless>
 

Before moving on,

On my system, all my projects are placed in a user directory named "run" which is created off the C: drive. My PE:J product is installed off my C: drive. My BEA Weblogic Application Server is installed off the C: drive. You may have make appropriate modifications based on your installation environment.

Copy the \.pej\ folder from C:\run\projects\bank\bank_ObjectEditor\ to the C:\bea\weblogic700b\samples\server\config\examples\ folder. You will also have to copy the system.properties file from the C:\PEJ\.pej\ folder to the C:\bea\weblogic700b\samples\server\config\examples\.pej\ folder.

Run the Sample Application.

Before running the client, make sure the Application Server is up and running. I had to modify the Weblogic startup script to add the pej.jar and the bank.jar files to the Application Server's CLASSPATH. The modified Examples Server batch file is available here. You may have to modify it based on your environment.

Command Prompt 
C:\bea\weblogic700b\samples\server\config\examples\clientclasses>
C:\bea\weblogic700b\samples\server\config\examples\clientclasses>
%JAVA_HOME%/bin/java -classpath .;C:/PEJ/lib/j2ee.jar;C:\bea\weblogic700b\server\lib\weblogic.jar;C:\PEJ\lib\pej.jar com.hywy.samples.ejb20.session.stateless.Client "t3://localhost:7001/TellerHome"

Beginning stateless.Client...

Creating a Teller
Create Checking Account for Gopalan Suresh Raj
Create Checking Account for Athul Suresh Raj
Create Savings Account for Gopalan Suresh Raj
Create Savings Account for Athul Suresh Raj
The size of checkingAccountList is :4
_______________________________________
List of Checking Accounts
_______________________________________
Checking Account Number :9345903153152
Checking Account Number :9483342106624
Checking Account Number :9620781060096
Checking Account Number :9758220013568
_______________________________________
The size of savingsAccountList is :4
_______________________________________
List of Savings Accounts
_______________________________________
Savings Account Number :9345886375936
Savings Account Number :9483325329408
Savings Account Number :9620764282880
Savings Account Number :9758203236352
_______________________________________
Delete Checking Account Number :9345903153152
The size of checkingAccountList is now :3
Delete Savings Account Number :9345886375936
The size of savingsAccountList is now :3
Transfer Money - 100 from Checking Account :9483342106624 to Savings Account :9483325329408
The Money Transfer was a SUCCESS
Removing the teller

End stateless.Client...


C:\bea\weblogic700b\samples\server\config\examples\clientclasses>
 

Download

You can download the entire enhanced folder from here.

click here to go to
My JDO HomePage...

click here to go to
My Advanced Java Tutorial Page...

About the Author...
Gopalan Suresh Raj is a Software Architect, Developer and an active Author. He has co-authored a number of books including "Professional JMS", "Enterprise Java Computing-Applications and Architecture" and "The Awesome Power of JavaBeans". His expertise spans enterprise component architectures and distributed object computing. Visit him at his Web Cornucopia© site (https://gsraj.tripod.com/) or mail him at gopalan@gmx.net.

Go to the Component Engineering Cornucopia page

This site was developed and is maintained by Gopalan Suresh Raj

This page has been visited times since February 26,2002.

Last Updated : Feb 26, 2002

If you have any questions, comments, or problems regarding this site, please write to me I would love to hear from you.


Copyright (c) 1997-2002, Gopalan Suresh Raj - All rights reserved. Terms of use.

All products and companies mentioned at this site are trademarks of their respective owners.