Running and Testing Enterprise JavaBeans

To test your EJBs you might need to run a client program that can create or find EJB instances and call their remote interface methods. JDeveloper provides a sample client utility that will help you create clients quickly. You can run and test EJBs using either the embedded OC4J Server or a remote server, and the sample client utility can be used to create a client for either type.

Note that changes you make to the standalone OC4J configuration area are not picked up by the embedded server. You need to modify the corresponding files in the embedded server's oc4j-config directory for these changes to affect the embedded server.

Testing EJBs Using the Embedded OC4J Server

The embedded OC4J server runs within JDeveloper. You can run and test EJBs quickly and easily using this server, and then deploy your EJBs with no changes to them. You do not need to create a deployment profile to use this server, nor do you have to initialize it.

To run a sample client on the embedded OC4J server:

  1. In the System Navigator, right click on an EJB and choose Run.
    Notice in the Message pane that OC4J has been launched.
  2. Right click on an EJB and choose Create S ample Java Client from the context menu.
    Note that this option is only available if your EJB exposes remote interfaces.
  3. The default choice is to create a client for the embedded OC4J server, so you can click OK.
    The client is created and opens in the code editor.
  4. If your client is for a CMP EJB, code is generated to invoke the findAll() method, iterating through the retrieved instances and printing the property values to System.out. Otherwise edit your sample client to call the desired home and remote methods.
  5. In the System Navigator, right-click the sample client and choose Run.
    The Message pane shows you the running output.

Testing EJBs Using a Remote Server

To test EJBs on a remote server you need to deploy the EJB and then create a sample client. (If you deploy first, then the framework can pick up the deployed applications, which will populate the client's pick list).

Note that you cannot mix CMP 1.1 and CMP 2.0 beans in the same module.

To run a sample client on a remote server:

  1. Launch your application server.
  2. In the System Navigator, right-click your project node and choose New.
  3. In the New dialog box, click the Deployment Profiles category and choose J2EE EJB Module.
    The new deployment profile is displayed in the System Navigator.
  4. Right click the deployment profile and choose Deploy to New Connection.
  5. In the dialog box, specify the application server you want to use. (The OC4J server that ships with JDeveloper is selected by default.) Click OK.
  6. In the System Navigator, right click on the deployment profile and chose Deploy to <named connection>.
  7. In the System Navigator, right click on an EJB and choose Create Sample Java Client.
  8. In the dialog box, choose to connect to a Remote App Server. The combo boxes should list any deployed J2EE applications, choose one.
  9. Click OK.
    The client is created and displayed in the System Navigator.
  10. Right-click the client and choose Run .
    The Message pane shows you the running output.

Related topics

About EJB Files Generated by JDeveloper
Binding User Interfaces to Entity Beans

 

 

 

Copyright © 1997, 2004, Oracle. All rights reserved.