# Creating a New EJB Control

Enterprise Java Bean (EJB) controls make it easy for you to use an existing, deployed EJB from within an application. This topic describes how to create a new EJB control and configure it to access a local EJB or a remote EJB.

## Creating a New EJB Control

1. If you are not in Design View, click the Design View tab.
2. From the Insert menu, choose Insert-->Portal->EJB Control. The Control - Insert EJB dialog opens.
3. In the Variable name for this control field, type the name for your EJB control.
4. Select the Create a new EJB control to use with this service radio button.
5. In the New JCX name field, type the name of the new file.
6. Decide whether you want to make this a control factory and select or clear the Make this a control factory that can create multiple instances at runtime check box. For more information about control factories, see Control Factories: Managing Collections of Controls.
7. In the Step 3 pane, next to the jndi-name field, click Browse. The Database Browser dialog appears.
8. Select the appropriate EJB from the list and click Select. The name appears in the jndi-name field, and the interfaces used by this EJB appear in the home interface and bean interface fields.
9. Click Create.

   > Note: Before an EJB control will function, the EJB it represents must be deployed in WebLogic Server. To deploy an EJB, please refer to the WebLogic Server documentation, or refer to your system administrator.

## Accessing Remote EJBs

A local EJB is an EJB that is deployed on the same instance of WebLogic Server that is running your application. A remote EJB is one that is deployed on a different server.

You can access remote EJBs using the EJB control, provided the server hosting the EJB control and the server to which the target EJB is deployed are in the same domain. You access remote EJBs by using special JNDI syntax in the jndi-name attribute. For example:

> jndi://username:password@host:7001/my.resource.jndi.object

Note: Accessing a remote EJB in a different domain via the EJB control requires advanced transaction configuration. Please consult the "Configuring Domains for Inter-Domain Transactions" section of the Managing Transactions topic in the WebLogic Server documentation on edocs.bea.com.

Related Topics

Portal Control Declaration

Using WebLogic Built-In Controls

Using an EJB Control