Building EJBs
With JBuilder 4 And Weblogic Server 5.1

Author: Jeff Smith
Last Revised: 11/3/2000

Overview:
JBuilder4 Enterprise has wizards which simplify creating EJBs with Weblogic. The wizard creates the bean, home, and remote interface classes for you as well as the deployment descriptor files (ejb-jar.xml and weblogic-ejb-jar.xml). It also automatically creates your final deployable jar file which you can deploy from within weblogic's console program. Once deployed, JBuilder also has a wizard for creating a client class to test your EJB. Just compile the client class and you can run it inside the integrated debugger.

Programs Required:
JBuilder 4 (with either jdk 1.22 or 1.3)
Weblogic Console (with weblogic running)

Installation Note:
After you install JBuilder4, you have to go to the Tools Menu, Enterprise and tell JBuilder where to find IAS (e.g. c:\inprise\appserver) and weblogic (e.g. c:\weblogic). You then will have to close and restart JBuilder to enable its enterprise (EJB) features.

Step By Step Process:
1) JBuilder Project Menu, default project properties, enterprise tab. Set JBuilder to use weblogic server instead of Inprise's IAS (Inprise Application Server). This will become the default for future EJB projects.
2) JBuilder Project Menu, default project properties, build tab, weblogic tab. Check the "Use external compiler to compile stub files" option. Enter the path to your (javac) compiler. You can use either jdk 1.22 or 1.3. For example, you could set it to c:/JBuilder4/jdk1.3/bin/javac.exe.
3) JBuilder File Menu, New, Enterprise tab, Empty EJB Group (wizard). Choose a project directory and name. On step 2 of the wizard, add WebLogic 5.1 to the list of required libraries.
4) JBuilder File Menu, New, Enterprise tab, Enterprise Java Bean (wizard). Choose your bean type (stateless session, stateful session, bean managed persistence entity bean, or container managed persistence entity bean). Choose a custom JNDI name or use the default.
5) Modify your bean class to implement any business logic you want. Modify the home and remote interfaces as appropriate.
6) Compile your project. JBuilder has automatically created a deployable jar file for you (with the ejb-jar.xml and weblogic-ejb-jar.xml files in it). It placed it in your project directory (unless you set a different output directory in the project options)
7) Run Weblogic console, attach to your server (ie myserver). Drill down the tree on the left to "Distributable objects". Drill down again to "EJB". Drill down again to "Deployment units". Click the "Commands" tab in the window to the right and click the "New deployment" button. Enter your JNDI name for the "deployment unit name", and enter the path to your deployable jar file for the "bean file location". Your bean should now be deployed.
8) To create a client program to test your EJB, go back to JBuilder and open your EJB project (if it isn't already open).
9) JBuilder File Menu, New, EJB Test Client. Choose your EJB and EJB group (the default values should be correct). The wizard will create a client class for you, with all the code to test your EJB. Modify the following lines of code "user = null; password = null" to use your username and password. You may have to change the host too. Do not compile your program yet.
10) Project menu, project properties, "Run" tab. Set the main class to your client class (it should be in the treeview for your ejb group) and uncheck the "compile before running" and "compile before debugging tabs". This will prevent JBuilder from recompiling and deploying the jar file each time you want to run your client.
11) Run your client program. You should see the default initialization and run messages.
12) Modify your client class to access and test features in your EJB.

 

 

   
Website copyright © 2002, SoftTech Design, Inc. All rights reserved worldwide.