Access container and server services from enterprise components

This page discusses - Access container and server services from enterprise components


Chapter 2. Design, build and test web components Chapter 2. Design, build and test web components Test and debug enterprise components Describe the effects of a server failure on the application Interact with connection pools to obtain and release connections Part II. Appendixes WSAD 5.0 Practicing for IBM Test 000-287 Preface Identify misbehaving application components Implement mechanisms which support loose coupling between clients and components Manipulate transactional behavior of EJBs using deployment descriptors Use JTA to control transaction demarcation Design, develop and test JSPs Configure JMS connection factories and destinations Implement Java clients calling Web Services Chapter 3. Develop clients that access the enterprise components IBM Test 000-287. Enterprise Application Development with IBM WebSphere Studio, V5.0 Study Guide Implement mechanisms for efficient inter-component calls Chapter 7. Validate, tune and troubleshoot an application within an IBM WebSphere Application Server environment Manage end-user state and understand performance tradeoffs of using HTTP sessions Explain implications of resource management on application design and implementation Part I. Exam Objectives Access container and server services from enterprise components Chapter 1. Design, build and test reusable enterprise components Validate operational parameters of application server to support the enterprise application Design and develop entity EJBs Design and develop message-driven EJBs Chapter 5. EJB transactions Chapter 4. Demonstrate understanding of database connectivity and messaging within IBM WebShpere Application Server Design and develop custom tags Configure resource and security-role references Chapter 6. Assemble enterprise applications and deploy them in IBM WebSphere Application Server Deploy enterprise applications into servers WSAD 5.0 Practicing for IBM Test 000-287 Mind Map Appendix A. Additional materials

Access container and server services from enterprise components

Setting up a server to test Data source

  1. In the Servers view, double-click the TitanServer server. The server editor opens.

  2. Select the Data source tab at the bottom of the editor.

  3. To test data sources at the node level, expand Node Settings. To test data sources at the server level, expand Server Settings.

    Expand Server Settings.

  4. A JDBC provider for DB2 and for Cloudscape will already be created for you (in the Server Settings section only). Before using the predefined JDBC provider, verify that the Class path field specified in the JDBC provider is the correct class path that contains the database driver. Select the JDBC provider from the JDBC provider list and click Edit to edit the JDBC class path.

  5. Define a data source and resource properties. Beside Data sources defined in the JDBC provider selected above list, click Add.

  6. Select the type of JDBC provider, for example Cloudscape JDBC Provider.

    JDBC Provider

    Select Version 5.0 data source and click Next.

  7. On the Modify Data source page, specify the details of the data source that you want to create. For more information about any of the fields on this wizard, select the field and then press F1.

    Name - TitanDS.

    JNDI name - jdbc/TitanDS.

    Select the Use this data source in container managed persistence (CMP) check box.

    Modify Data source

    Click Next.

  8. In the Resource Properties list table, select databaseName.

    In the Value field, type the following: c:/titandb.

    Modify Data source
  9. Click Finish. You associated a pooled database connection to a JNDI name that can be used by the application.

    Data source

Adding Datasource references to enterprise bean

You can add different types of references to an enterprise bean, including resource references.

To add resource references to an enterprise bean:

  1. In the J2EE Hierarchy view, right-click the desired EJB module and select Open With > Deployment Descriptor Editor from the pop-up menu.

  2. On the References page of the editor select the enterprise bean that you want to add a reference to (the referencing bean) - Ship, and click the Add button. The Add Reference wizard opens.

  3. Select the type of reference that you want to create (Resource reference), and click Next.

  4. Complete these fields:

    • Name - Specifies the name of the reference (jdbc/TitanDS).

    • Type - The expected type of the resource manager connection factory (javax.sql.DataSource).

    • Authentication - Specifies the authentication method (container or application) for the resource manager (Container).

    • Sharing Scope - Specifies whether connections can be shareable or unshareable. This option is available for J2EE 1.3-compliant application client modules (Shareable).

    • Description - Text that describes the reference (Titan application Data Source).

  5. Click Finish.


The reference is added to the bean that you selected and is displayed on the References page of the EJB deployment descriptor editor.

Add WebSphere Binding information (the JNDI (Java Naming and Directory Interface) name that the bean code uses to get a reference to a data source) - jdbc/TitanDS

WebSphere Binding information

The Data source reference is added to the ejb-jar.xml deployment descriptor:

<entity id="Ship">
	<resource-ref id="ResourceRef_1122305703058">
		<description>Titan application Data Source</description>

Defining JNDI bindings (CMP connection factory)

You can define JNDI bindings, or CMP connection factory bindings, for EJB 2.0 beans.

The CMP factory connection binding is a setting specific to WebSphere Application Server. See the WebSphere Application Server documentation for more detailed information about component-managed authentication and container-managed authentication.

To define CMP connection factory bindings:

  1. Switch to the J2EE perspective.

  2. In the J2EE Hierarchy view, right-click the desired EJB 2.0 module, and select Open With > Deployment Descriptor Editor from the pop-up menu.

  3. On the Overview page of the editor, in the WebSphere Bindings section, go to the CMP Connection Factory Binding section.

  4. Type a JNDI name - jdbc/TitanDS

  5. Select one of the following container authentication types:

    • Per_Connection_Factory - Select this option for component-managed authentication.

    • Container - Select this option for container-managed authentication.

JNDI name


Share on Google+Share on Google+

Access container and server services from enterprise components

Posted on: April 18, 2011 If you enjoyed this post then why not add us on Google+? Add us to your Circles



Discuss: Access container and server services from enterprise components  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image