This topic shows you step-by-step how to deploy session bean from Weblogic 5.1.0 to IBM WebSphere 3.5 samples and run a client for it. The sample resides in %WL_HOME%\examples\ejb\basic\statelessSession.
Copy all *.java files from %WL_HOME%\examples\ejb\basic\statelessSession to %TG_HOME%\myprojects\session\examples\ejb\basic\statelessSession.
Start Together.
Create a New Project and set its location to %TG_HOME%\myprojects\cmp. Enter 'cmp' as the project name. As you won't need standard libraries, remove them from the project: press Advanced button, select Search Classpath and make sure that checkboxes 'Include standard libraries' and 'Include Classpath' are cleared. On the EJB tab select IBM WebSphere AE 3.5 server. Press OK.
Navigate to statelessSession node in the Explorer, choose Open Diagram on its speedmenu and open statelessSession package.
Select TraderBean in the diagram in the diagram, choose Properties from its speedmenu and open Object Inspector..
Select 'Session EJB' page and in the Properties tab set JNDI name to "TraderHome".
Close Object Inspector.
Edit constructor 'ejbCreate()':
|
Find |
Replace |
|
try { |
tradeLimit = 300; |
You are now ready to deploy this bean to WebSphere 3.5
Correcting the Client
Select Client class on the diagram.
Edit JNDI_NAME parameter:
|
Find |
Replace |
|
private static final String JNDI_NAME = "statelessSession.TraderHome"; |
private static final String JNDI_NAME = "TraderHome"; |
Edit main() method:
|
Find |
Replace |
|
String url = "t3://localhost:7001"; |
String url = "iiop://localhost:900"; |
Edit getInitialContext method:
|
Find |
Replace |
|
h.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory") |
h.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.ejs.ns.jndi.CNInitialContextFactory") |
The client is now ready.
Precondition
Start WebSphere server:
Select Control panel | Services from Start | Settings menu.
Select "IBM WS AdminServer" and press Start button.
Note: "IBM HTTP Administration" and "IBM HTTP Server" should be already started.
Deploying the bean
Run Together 's Main Menu | Tools | EJB Deployment Expert
Select "IBM WebSphere AE 3.5" as the target server and make sure that all available checkboxes, except "Process servlets", "Generate WLM jar for Bean","Generate start and compile file for client" and "Generate simple JSP client" are set. Press Next.
Set paths to WebSphere home directory and to IBM JDK 1.2.2 root directory (e.g. "c:\WebSphere\AppServer" and "c:\WebSphere\AppServer\jdk"). Press Next.
Set the following parameters on the next page:
|
Parameter name |
Setting |
Comment |
|
Admin Node Name |
Name of the Node to deploy |
Name of the computer |
|
Dependent ClassPath |
Fully qualified path to WebSphere |
Check if it refers to existing jars |
|
Application Server Name |
Your Application Server |
"Default Server" by default |
|
EJB Container name |
Your Container name |
"Default Container" by default |
|
Target WebSphere server directory |
WebSphere home directory |
e.g. c:\WebSphere\AppServer |
|
Launch server in debug mode |
OFF |
|
Press Next and Finish.
If you have checked Hot Deploy check box, the last message in the
Message Pane should be:
//WAS35: Finished with 0 Errors, 0 Warnings.
It means the deployment process successfully completed. Now let us create a client for this bean.
Add the following libraries to your project:
%WAS_HOME%\jdk\jre\lib\ext\rmiorb.jar
%WAS_HOME%\jdk\jre\lib\ext\iioprt.jar
Deployed jar file (e.g. %WAS_HOME%\deployableEJBs\DeployabletogetherEJB.jar)
Home directory of WebSphere Server %WAS_HOME%This is done in the following way
From the Main Menu | File | Project Properties dialog select
Search/Classpath page on the Resource pane. At this moment there
shouldn't be anything added to the classpath.
Press Add Zip/JAR button and add %WAS_HOME%\jdk\jre\lib\ext\rmiorb.jar,
%WAS_HOME%\jdk\jre\lib\ext\iioprt.jar
Press OK to save project properties.
Select Main Menu | Options | Project
Go to the Tools tab and add Deployed jar file to the ClassPath.
Note: In the nearest builds these libs will be added automatically.
Select Main Menu | Options | Project and set JDK Home to %WAS_Home%\jdk on the Tools Tab. Press "OK"
Select 'Client' class on the diagram and choose Rebuild Node on the speedmenu.
Builder pane displays a message that the tool is completed.
Select Main Menu | Tools | Run/Debug | Run. Make
sure that 'Class with main' is set to examples.ejb.basic.containerManaged.Client.
Press OK.
The following messages appear in the Runner pane:
Beginning statelessSession.Client...
Creating a trader
Buying 100 shares of BEAS.
Buying 200 shares of MSFT.
Buying 300 shares of AMZN.
Buying 400 shares of HWP.
Selling 100 shares of BEAS.
Selling 200 shares of MSFT.
Selling 300 shares of AMZN.
Selling 400 shares of HWP.
Removing the trader
End statelessSession.Client...