You can use the EJB Deployment Expert to compile your EJBs and deploy them on BEA WebLogic Server (WebLogic):
BEA WebLogic Application Server 4.5.1, and 5.1
BEA WebLogic Enterprise 5.0
This section describes how to set up your Together project and your environment so that you can use Together to compile both EJB clients and deploy your EJBs to the server. At the end, there is a short tutorial using a simple sample project.
If your EJB project contains one or more EJB clients that you want to compile and run from Together, you need to specify several paths and archives in the Search/Classpaths page of the Project Properties dialog before compiling the client(s). For Weblogic server, the order of the specifications is important, so follow the instructions below when setting up your EJB project to deploy to BEA Weblogic server.
If your project does not contain any EJB clients, you can skip the next sections.
If you want to compile/run EJB clients in the same project as EJBs, you need the following specified in the Search/Classpath tab of the Project Properties dialog In addition to other standard and other libraries needed for your EJBs and/or clients :
%WL_HOME%\lib\weblogicaux.jar *
%WL_HOME%\classes
%J2EE_HOME%\lib\j2ee.jar
Where: %WL_HOME% is the home directory of Weblogic Server (e.g. e:\weblogic), and %J2EE_HOME% is the home directory of Java2 Enterprise Edition (e.g. c:\j2sdkee1.2)
|
* IMPORTANT: weblogicaux.jar should always be first in the list, ahead of even standard libraries. |
To edit Search/Classpath:
On the Main menu choose File | Project Properties to display the Project Properties dialog.
Click the Advanced button to display the Resources group box.
Click the Search/Classpath tab.
Click the Add Path button to add paths (e.g. %WL_HOME%\classes), or the Add Zip/JAR button to add an archive (e.g. %J2EE_HOME%\lib\j2ee.jar).
Note: Together 4.0 users may need to remove and then re-add resources in order to get the file weblogicaux.jar first in the Search/Classpath list. The order will be editable in future releases.
You should add the path %J2EE_HOME%\nativelib in the PATH environment variable on Windows systems. (This path finds ioser12.dll).
This section shows you step-by-step how to compile an EJB, deploy it to the server, compile an EJB client in the same project, and run it against the the deployed EJB.
The example is based on BEA Weblogic Server version 5.1. It uses a simple example project Hello World which is located in $TOGETHER_HOME$/samples/java/ejb/WeblogicServer. To try the steps you need the following:
A Together product with Java language support and EJB support (or Together Whiteboard and a full-feature evaluation license).
An installation of Java2 Enterprise Edition (SDK 1.2 or higher).
An installation of Java2 SDK 1.2 or higher (installed with Together).
An installation of BEA WebLogic Server version 5.1 (local or accessible remote host).
IMPORTANT: When deploying EJBs, make sure your WebLogic server does not already have a deployed EJB with the same name as the one you are deploying (see Verifying deployment below). If it does, you must either restart Weblogic server after each deployment, or give your EJB a different name.
Open the HelloWorld.tpr project from $TOGETHER_HOME$/samples/java/ejb/WeblogicServer/HelloWorld/ (File | Open Project).
Open the hello diagram. You should see the HelloBean class. Open the Message pane so you can monitor process messages.
Check that you have the correct port number and password for Weblogic server available.
Launch the EJB Deployment Expert (Tools menu). Weblogic Application Server 5.1 is the default target server.
Make sure that all available check boxes are checked (including Hot Deploy).
Even though it's the default, open the drop-down list and select Weblogic Application Server 5.1 in the list to display server startup options.
In the server startup options, check Start Weblogic Server 5.1.0 (normal mode) and uncheck Start Weblogic Server 5.1.0 (debug mode).
Press Next button.
Specify the paths to:
Java2 Enterprise Edition: ()
Java2 SDK1.2 (or higher): (e.g. c:\jdk1.2.2),
Weblogic server(e.g. e:\weblogic)
directories for storing the generated jar file and temporary files.
Press Next button.
Specify the server host name (e.g. localhost), system password, and port number. Press Finish button.
Together does a number of things now:
Starts Weblogic Server
Invokes the Java SDK compiler to compile the Hello bean.
Generates the necessary deployment files for Weblogic, including deployment descriptor
Invokes the SDK's JAR utility to package everything into a .JAR file.
Communicates with the server to register the deployed EJB.
Assuming you checked Hot Deploy in the EJB Deployment Expert, the last message lines in the Message pane should be:
//WLS51: Connecting to
localhost, port 7001...Successfully connected.//
//WLS51: Done deploying
HelloWorld with c:\temp\DEPLOYABLE_HelloWorld.jar//.
//WLS51: Finished with 0
errors, 0 Warnings.//
Host name and port number values will match those you specified in the expert.
To be sure the generated JAR file was successfully deployed to the WebLogic server, you can run the Weblogic Console. In the console window, check for:
EJB Home interface: 'hello.HelloHome' deployed bound to the JNDI name: 'hello.HelloHome'.
This verifies that the bean is deployed.
If you have problems starting or running WebLogic server, consult the WebLogic documentation and/or technical support.
If you have problems connecting to a remote WebLogic server, consult the server's administrator or your network administrator.
To test the deployed EJB you need an EJB client to access it. The HelloWorld example contains a client class that you can compile and run to test your deployed sample EJB.
In the Project Properties dialog, check that the Search/Classpath specifications are as described in Search/Classpath specifications above. (File | Project Properties - Advanced)
Open the HelloWorld.client.weblogic package in the Explorer and open the weblogic class diagram containing the HelloClient class.
Right-click on the client class and select Tools | Compile from the speedmenu.
When compilation is complete the Message pane displays a message that the tool is completed.
Select the HelloClient class, right-click on it and choose Tools | Run from the speedmenu.
Your deployed EJB runs and outputs the string "Hello World". Together picks up this output and displays it as a message line in the message pane. The output also appears in the server console.
This section contains an exercise you can follow to learn how to debug bean and client from within the Together environment.
Close the running Weblogic Server.
For debugging your bean you must restart the server in a debug mode. To do this:
On the Main Menu, choose Tools | EJB Deployment Expert to launch the deployment expert again.
Drop down the list of servers and select WebLogic Application Server 5.1.
Uncheck Start WebLogic Server 5.1.0 (normal mode) and check Start WebLogic Server 5.1.0 (debug mode). Press Next.
Set the root directory of WebLogic Server 5.1.0 and press Next.
Set Remote process port address and remember it. Press Finish to start server in debug mode.
Read instructions in 'EJB Deployment' message window and follow them.
On the main menu choose Tools | Debugger | Attach to remote process.
In the subsequent dialog set the following values, then click OK:
Host: localhost (or the name of your server host)
Transport: dt_socket
Address: <address>
<address> - the value from the 2nd point above.
Deploy 'HelloBean' to WebLogic Server as previously described.
Select the hello() method of the 'HelloBean' class in the diagram. In the Editor, set a breakpoint on the first string in it (F5 or speedmenu | Toggle breakpoint).
Compile the HelloClient class as previously described (speedmenu - Compile).
In the Editor, set a breakpoint on the first string after the try statement in the s method.
On the Main menu choose Tools | Debugger | Debug project. The process will stop on the break point in the 'HelloClient' class.
Now you can use speed buttons to manage your process (Restart/Resume program, Reset program,step over, step in, etc.). They are situated in the Debugger page of the process. Or you can use hot keys (Step over - 'F8', Step in - 'F7') When you pass line calling the hello() method, the debugger will stop on the breakpoint in the 'HelloBean' class.
When you have traced all the hello() method, click the measure Program speed button on the remote process page to continue running WebLogic. As a result you'll be stopped in the 'HelloClient' class after the point at which the hello() method of the bean was invoked.
Continue step by step debugging, or click the Resume Program button to finish the debugging process.
In the previous sections, you have deployed a bean described in a Class diagram. This technique is fine for prototyping, but in real scenarios you want to specify such things as container transaction attributes on classes and methods, security roles, and method permissions. The EJB Assembly diagram enables you to do this, and so you can run the deployment expert against this type of diagram as well. For more information on this type of diagram and how to work with it, see User's Guide: EJB Assembly diagrams.
In this section you can do an exercise that uses an EJB Assembler diagram for deploying your Enterprise JavaBeans.
Close the running WebLogic Server.
In the example HelloWorld project, open the AssemblyDiagram diagram. You will see a shortcut to the hello.HelloBean class, and two ContainerTransaction elements, one with transaction attribute displaying as Supported and one as NotSupported. These elements are linked to the bean class and the hello() method respectively.
Start the EJB Deployment Expert again (Tools | EJB Deployment Expert) and deploy your EJB. For more information about deployment process refer to section Deploying the Bean of this guide.