Integration of WebLogic6.0 and JBuilder5
Development and commissioning of EJB
First, installation and configuration
Install JBuilder5 Enterprise first, then install JBuilder5 Person, License Key, make sure JBuilder5 Enterprise, can run.
After the JBuilder5, BAS4.5, and Weblolgic6.0 are installed, it can begin to be configured.
(1) Modification of system environment variables:
Transform the system environment variable TMP, TEMP is changed to a directory without spaces;
In JB5 menu project -> default project property-> Paths transform all space-free directories without spaces; (Why is this setting? Because of the integrated WebLogic and JB5 in the development process JB5 Calling WebLogic's bag to make EJB, and WebLogic is not well identified by spaceless, it is wrong, ie, is the directory of WebLogic to come into contact, the directory name is best not Chinese name, with space.)
When you use JB5 editing, you will find the problem that the cursor is not aligned with the actual location, in fact, you only need to set the reserved Word in Tools -> Editor Opntion -> Color, you can set the reserved Word without the use of boldes and italics.
(2) JBUILDER5 configuration:
A, Tools -> configure Libraries Determines a WebLogic6.0 package, where the Class should be added as follows and paths:
C: /bea/wlserver6.0/lib/ cr_wls60f.jar (is a WebLogic 6.0 CRACK package)
C: /bea/wlserver6.0/lib/weblogic_sp.jar
C: /bea/wlserver6.0/lib/weblogic.jar
B, Tools Menu -> Enterprise Setup -> CORBA
Added a WebLogic item, add WebLogic's primary directory under Path for ORB Tools, add WebLogic6.0 library under library for projects, and the specific method is: Point "..", then select WebLogic6.0 package; Fill in IDLj.exe in Compiler Command; fill in a directory path in Command Option for Output Directory, but to note that it cannot be Chinese, with spaces.
C, Tools Menu -> Enterprise Setup -> Application Server -> BAS4.5.
Fill in the catalog installed in the App Server. And select the enable integrate check box.
Tools Menu -> Enterprise Setup -> Application Server -> WebLogic 6.0 Fill in the directory and home directory installed by WebLogic installations.
(Note: Do not select the USE External Compiler check box)
D, configure Default Project Properties
Project -> Default Project Properties -> PATH -> Required Libraries Select WebLogic6.0;
Project -> Default Project Properties -> Build -> IDL Select Weblogic in Idl Compiler; Project -> Default Project Properties -> Run -> Application Select Main Class to WebLogic.Server (when you are set correctly This class can be found after WebLogic6.0 pack.)
Remove the COMPLILE BEFORE RUNNING and COMPLILE BEFORE DEBUGGING, otherwise, even if you run an EJB client, you will re-create an EJB package.
Project -> Default Project Properties -> Servers Point ".." This is the option server, of course, is also w readyiC6.0. Select WebLogic 6.0 after the Edit ... button:
2 Add a WebLogic6.0 package to Require Libraries, delete other deletions; simultaneously remove the path of all classes in the Class;
2 Modify VM Parameters: such as:
-ms64m -mx64m -Dweblogic.Domain = petstore -Dweblogic.Name = petstoreServer -Dbea.home = d:. / bea -Dcloudscape.system.home = / samples / eval / cloudscape / data -Djava.security.policy == d : /bea/wlserver6.0/ludb/weblogic.policy
Note: The parameter is the startup parameter that launches the WebLogic service. You can refer to the startup configuration in ../config/mydomain/startweblogic.cmd, most of the errors during the debugging process come to the unreasonable configuration here, including Domain and Server The case is written, will cause an error.
2 If you need to debug JSP or Servlet, select Application Server IS Web Server.
Second, create Enterprise Bean in JBuilder
Each enterprise bean you create must belong to a JBuilder EJB group. An EJB group is a logical grouping of one or more beans that will be deployed in a single JAR file. It contains the information that is used to produce the deployment descriptor (s) For That Jar File. You Can Edit The Content of an EJB Group Using The Deployment Descriptor Editor.
l Creating an EJB GROUP
Two ways:
File | New | Enterprise | EMPTY EJB GROUP ...
File | New | Enterprise | EJB Group from Descriptors ...
NOTICE: EJB Group Type Select EJBPRGX (Describe file with XML for version control)
l create bean
Two ways:
2 Enterprise Javabean Wizard
2 The EJB Entity Bean Modelerfile | New | Enterprise | Enterprise JavaBean ...
l Add attributes and methods in EJB
Select EJB class file, select Bean Designer | Property | Add Property
l Exposing Business Methods Through The Remote Interface
Add methods in remote interfaces:
Select the EJB class file, select Bean Designer | Mothods Tab, select the method you want to expose in the remote interface (Checked or Uncheck).
Third, debug EJB
1. Create Container Server
Run | Configurations ... - "New ... | RUN
l Configuration Name: ServerName;
l Set EJB | VM Parameters: (and Project Properties ... àrunàejb | vm parameters ...);
l Application | Main class: WebLogic.Server
2, create a CILENT for Test
l Create a Client Framework
NewàEnterprise | EJB Test Client ... Select the EJB name and package, Class name, OK button you want to debug.
l Add reference to EJB methods
Add a reference to the EJB method to the end of the TRY block of the CLIENTCLASS. EG:
Package adtec.wei.changtest;
Import adtec.wei.chang. *;
Import javax.naming. *;
Import java.util.properties;
Import javax.rmi.portableremoteObject;
Public class changejbtestclient {
Private changejbhome changejbhomeObject = NULL;
/ ** Construct the EJB TEST Client * /
Public changejbtethclient () {
Try {
// Get Naming Context
Context CTX = GetInitialContext ();
// Look Up JNDI Name
Object Ref = ctx.lookup ("ChangeJbhome");
// Cast to Home Interface
ChangejbhomeObject = (changejbhome) PortableRemoteObject.narrow (ref, changejbhome.class);
Int age = changejbhomeObject.create (). Getage ();
System.out.println ("My Age IS: AGE);
}
Catch (Exception E) {
E.PrintStackTrace ();
}
}
Private context getinitialcontext () throws exception {
String URL = "T3: //100.100.100.69: 7001";
String user = NULL;
String password = NULL;
Properties Properties = NULL;
Try {
Properties = new profment (); Properties.put (Context.initial_Context_Factory, "WebLogic.jndi.wlinitialContextFactory";
Properties.Put (Context.Provider_URL, URL);
IF (user! = null) {
Properties.Put (Context.security_principal, user);
Properties.put (Context.Security_credentials, Password == Null? "": password);
}
Return New InitialContext (Properties);
}
Catch (Exception E) {
System.out.Println ("Unable to Connect To Weblogic Server AT" URL);
System.out.Println ("Please makess");
Throw e;
}
}
// Utility Methods
/ / -------------------------------------------------------------------------------------------- --------------------
Public changejbhome gethome () {
Return ChangeJBhomeObject;
}
/ ** main method * /
Public static void main (String [] args) {
ChangejbTestClient Client = new changejbtestclient ();
// int Age = client.getHome (). Create (). getage ();
// use the gethome () Method of The Client Object to Call Home Interface
// Methods That Will Return A Remote Interface Reference. Then
// Use That Remote Interface Reference to Access The EJB.
}
}
l Create a Client Operation Environment
Run | Configurations ... - "New ... | RUN
Application | main class: wei.chang.song.changejbtestclient
Where: Main Class runs class for our customers.
3, run debugging
l Select the Run Project button on the shortcut toolbar, click the drop-down menu, select Run Container Server, start the EJB container service; if there is a problem, please check the VM parameters, confirm the error.
l Run the client in the same way, the client will return the correct expected value.
4. Remote call EJB
Publish the EJB package file to Application Server, make sure the Server has started. When the client is called, the URL in the GetInitialContext function is changed, such as the Application Server runs on the machine that is 100.100.100.69, and URL = T3: //100.100.100.69: 7001.