Step-By-Step How to deploy CMP bean from Weblogic 5.1.0 samples to IBM WebSphere 3.5

This topic shows you step-by-step how to deploy a CMP bean from WebLogic 5.1.0 to IBM WebSphere 3.5 and run a client for it. The sample resides in %WL_HOME%\examples\ejb\basic\containerManaged.

Create a project and make necessary changes to CMP bean


'findBigAccounts' : 'select * from accountbeantbl where balance > ?',

'findAccount': 'select * from accountbeantbl where balance = ?',

'findNullAccounts': 'select * from accountbeantbl where accountType is null '.

public AccountPK(String param) { accountId = param; }

public int hashCode() { return accountId.hashCode(); }

Now you are ready to deploy this bean to WebSphere 3.5

Editing the Client


Find

Replace

String url = "t3://localhost:7001";

String url = "iiop://localhost:900";

Find

Replace

h.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");

h.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.ejs.ns.jndi.CNInitialContextFactory");

Find

Replace

Object home = (AccountHome) ctx.lookup("containerManaged.AccountHome");'

Object home = (AccountHome) ctx.lookup("AccountHome")

Find

Replace

Enumeration enum = (Enumeration) PortableRemoteObject.narrow(home.findNullAccounts(), hi.class);

 

Enumeration enum = home.findNullAccounts();

 

Account nullAccount= (Account) enum.nextElement();

Account nullAccount= (Account) PortableRemoteObject.narrow(enum.nextElement(), Account.class);

The client is now ready.

Deploying the Bean

Precondition

Start WebSphere server:

Note: "IBM HTTP Administration" and "IBM HTTP Server" should be already started.

Deploying the bean

1. Run Together 's Main Menu | Tools | EJB Deployment Expert

2. 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.

3. 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.

4. 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

for example c:\WebSphere\AppServer

Create Table for CMP EJBs

ON

 

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.

Compiling and running the client


%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

Note: In the nearest builds these libs will be added automatically.

Beginning containerManaged.Client...

Starting Part A of the example...
Creating account 10020 with a balance of 3000.0 account type Savings...
Account 10020 successfully created

Part A: Depositing $2000
Current balance is $5000.0
Attempting to withdraw an amount greater than current balance. Expecting an exception...

Received expected Processing Error:
examples.ejb.basic.containerManaged.ProcessingErrorException: Request to withdraw $5001.0; is more than balance
$5000.0 in account 10020
Removing account...

End Part A of the example...

Starting Part B of the example...

Creating account ID: 0 with a balance of 0.0 account type null...
Account ID: 0 successfully created
Creating account ID: 1 with a balance of 1000.0 account type Savings...
Account ID: 1 successfully created
Creating account ID: 2 with a balance of 2000.0 account type Savings...
Account ID: 2 successfully created
Creating account ID: 3 with a balance of 3000.0 account type Savings...
Account ID: 3 successfully created
Creating account ID: 4 with a balance of 4000.0 account type Savings...
Account ID: 4 successfully created
Creating account ID: 5 with a balance of 5000.0 account type null...
Account ID: 5 successfully created
Creating account ID: 6 with a balance of 6000.0 account type Savings...
Account ID: 6 successfully created
Creating account ID: 7 with a balance of 7000.0 account type Savings...
Account ID: 7 successfully created
Creating account ID: 8 with a balance of 8000.0 account type Savings...
Account ID: 8 successfully created
Creating account ID: 9 with a balance of 9000.0 account type Savings...
Account ID: 9 successfully created
Creating account ID: 10 with a balance of 10000.0 account type null...
Account ID: 10 successfully created
Creating account ID: 11 with a balance of 11000.0 account type Savings...
Account ID: 11 successfully created
Creating account ID: 12 with a balance of 12000.0 account type Savings...
Account ID: 12 successfully created
Creating account ID: 13 with a balance of 13000.0 account type Savings...
Account ID: 13 successfully created
Creating account ID: 14 with a balance of 14000.0 account type Savings...
Account ID: 14 successfully created
Creating account ID: 15 with a balance of 15000.0 account type null...
Account ID: 15 successfully created
Creating account ID: 16 with a balance of 16000.0 account type Savings...
Account ID: 16 successfully created
Creating account ID: 17 with a balance of 17000.0 account type Savings...
Account ID: 17 successfully created
Creating account ID: 18 with a balance of 18000.0 account type Savings...
Account ID: 18 successfully created
Creating account ID: 19 with a balance of 19000.0 account type Savings...
Account ID: 19 successfully created
Account: :examples.ejb.basic.containerManaged.AccountPK@4247acf has a balance of 0.0
Account: :examples.ejb.basic.containerManaged.AccountPK@4247ad0 has a balance of 1000.0
Account: :examples.ejb.basic.containerManaged.AccountPK@4247ad1 has a balance of 2000.0
Account: :examples.ejb.basic.containerManaged.AccountPK@4247ad2 has a balance of 3000.0
Account: :examples.ejb.basic.containerManaged.AccountPK@4247ad3 has a balance of 4000.0
Account: :examples.ejb.basic.containerManaged.AccountPK@4247ad4 has a balance of 5000.0
Account: :examples.ejb.basic.containerManaged.AccountPK@4247ad5 has a balance of 6000.0
Account: :examples.ejb.basic.containerManaged.AccountPK@4247ad6 has a balance of 7000.0
Account: :examples.ejb.basic.containerManaged.AccountPK@4247ad7 has a balance of 8000.0
Account: :examples.ejb.basic.containerManaged.AccountPK@4247ad8 has a balance of 9000.0
Account: :examples.ejb.basic.containerManaged.AccountPK@806adf60 has a balance of 10000.0
Account: :examples.ejb.basic.containerManaged.AccountPK@806adf61 has a balance of 11000.0
Account: :examples.ejb.basic.containerManaged.AccountPK@806adf62 has a balance of 12000.0
Account: :examples.ejb.basic.containerManaged.AccountPK@806adf63 has a balance of 13000.0
Account: :examples.ejb.basic.containerManaged.AccountPK@806adf64 has a balance of 14000.0
Account: :examples.ejb.basic.containerManaged.AccountPK@806adf65 has a balance of 15000.0
Account: :examples.ejb.basic.containerManaged.AccountPK@806adf66 has a balance of 16000.0
Account: :examples.ejb.basic.containerManaged.AccountPK@806adf67 has a balance of 17000.0
Account: :examples.ejb.basic.containerManaged.AccountPK@806adf68 has a balance of 18000.0
Account: :examples.ejb.basic.containerManaged.AccountPK@806adf69 has a balance of 19000.0

Querying for accounts with a balance greater than 5000.0...
Account examples.ejb.basic.containerManaged.AccountPK@4247ad5; balance is $6000.0
Account examples.ejb.basic.containerManaged.AccountPK@4247ad6; balance is $7000.0
Account examples.ejb.basic.containerManaged.AccountPK@4247ad7; balance is $8000.0
Account examples.ejb.basic.containerManaged.AccountPK@4247ad8; balance is $9000.0
Account examples.ejb.basic.containerManaged.AccountPK@806adf60; balance is $10000.0
Account examples.ejb.basic.containerManaged.AccountPK@806adf61; balance is $11000.0
Account examples.ejb.basic.containerManaged.AccountPK@806adf62; balance is $12000.0
Account examples.ejb.basic.containerManaged.AccountPK@806adf63; balance is $13000.0
Account examples.ejb.basic.containerManaged.AccountPK@806adf64; balance is $14000.0
Account examples.ejb.basic.containerManaged.AccountPK@806adf65; balance is $15000.0
Account examples.ejb.basic.containerManaged.AccountPK@806adf66; balance is $16000.0
Account examples.ejb.basic.containerManaged.AccountPK@806adf67; balance is $17000.0
Account examples.ejb.basic.containerManaged.AccountPK@806adf68; balance is $18000.0
Account examples.ejb.basic.containerManaged.AccountPK@806adf69; balance is $19000.0

Querying for an account with zero balance...
Account examples.ejb.basic.containerManaged.AccountPK@4247acf; balance is zero

Querying for accounts with a null account type
Account examples.ejb.basic.containerManaged.AccountPK@4247ad4; account type is null
Account examples.ejb.basic.containerManaged.AccountPK@806adf60; account type is null
Account examples.ejb.basic.containerManaged.AccountPK@806adf65; account type is null
Account examples.ejb.basic.containerManaged.AccountPK@4247acf; account type is null
Removing beans...
End Part B of the example...

End containerManaged.Client..