WebSphere Application Server & Liberty

WebSphere Application Server & Liberty

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only

WebSphere Application Server - Application bindings

By Steve Robinson posted Fri February 01, 2013 05:45 PM

  
After trying to read through the IBM Information Centre to list the available IBM specific binding files which can used in JEE application deployment, I decided to create this document to outline information for Eclipse-based developers. The reason for this is; If you are using an Eclipse based project as opposed to an IBM Rational Application Developer based project, you might miss some of the deployment descriptor binding files available. RAD contains these extra extended deployment descriptor elements/stanzas/files in its IDE, however Eclipse doesn't know about IBM specific binding files. Most of the information is from IBM's site and as I find more information I will update it and try to create some code examples. You can use this document as a semi-detailed reference, to get those Google search keywords ready.


Before an application that is installed on an application server can start, all enterprise bean (EJB) references and resource references defined in the application must be bound to the actual artifacts (enterprise beans or resources) defined in the application server.
When defining bindings, you specify Java Naming and Directory Interface (JNDI) names for the referenceable and referenced artifacts in an application. The jndiName values specified for artifacts must be qualified lookup names. An example referenceable artifact is an EJB defined in an application. An example referenced artifact is an EJB or a resource reference used by the application.Binding definitions are stored in the ibm-xxx-bnd.xml or ibm-xxx-bnd.xmi files of an application. Version 7.0 binding definitions support files with the suffix of XML for EJB 3.0 and Web 2.5 modules. Modules earlier than Java EE 5 continue to use binding definition files with the suffix of XMI as in previous versions of WebSphere Application Server. The xxx can be ejb-jar, web, application or application-client. For transitioning users: For EJB 3.0 modules, you do not need to specify JNDI binding names for each of the home or business interfaces on your enterprise beans. If you do not explicitly assign bindings, the EJB container assigns default bindings. Further, binding definitions are stored in ibm-ejb-jar-bnd.xml.trns This topic provides the following information about bindings:

  • Times when bindings can be defined
  • Required bindings
  • Other bindings that might be needed

Times when bindings can be defined

You can define bindings at the following times:

During application development

An application developer can create binding definitions in ibm-xxx-bnd.xml files for EJB 3.0 and Web 2.5 modules and in ibm-xxx-bnd.xmi files for pre-Java EE 5 modules. The application developer can create the files using a tool such as an IBM® Rational® developer tool or, for EJB 3.0 or Web 2.5 modules, using an XML editor or text editor. The developer then gives an enterprise application (.ear file) complete with bindings to an application assembler or deployer. When assembling the application, the assembler does not modify the bindings. Similarly, when installing the application onto a server supported by WebSphere Application Server, the deployer does not modify or override the bindings or generate default bindings unless changes to the bindings are necessary for successful deployment of the application.

During application assembly

An application assembler can define bindings in annotations or deployment descriptors of an application. Java EE 5 modules contain annotations in the source code. To declare an annotation, an application assembler precedes a keyword with an @ character ("at" sign). Bindings for pre-Java EE 5 modules are specified in the WebSphere Bindings section of a deployment descriptor editor. Modifying the deployment descriptors might change the binding definitions in the ibm-xxx-bnd.xmi files created when developing an application. After defining the bindings, the assembler gives the application to a deployer. When installing the application onto a server supported by WebSphere Application Server, the deployer does not modify or override the bindings or generate default bindings unless changes to the bindings are necessary to deploy the application.

During application installation

An application deployer or server administrator can modify the bindings when installing the application onto a server supported by WebSphere Application Server using the administrative console. New binding definitions can be specified on the installation wizard pages. Also, a deployer or administrator can select to generate default bindings during application installation. Selecting Generate default bindings during application installation instructs the product to fill in incomplete bindings in the application with default values. Existing bindings are not changed.Restriction: You cannot define or override bindings during application installation for application clients. You must define bindings for application client modules during assembly and store the bindings in the ibm-application-client-bnd.xmi file.

During configuration of an installed application

After an application is installed onto a server supported by WebSphere Application Server, an application deployer or server administrator can modify the bindings by changing values in administrative console pages such as those accessed from the settings page for the enterprise application.

Required bindings

Before an application can be successfully deployed, bindings must be defined for references to the following artifacts:

EJB JNDI names

For each EJB 2.1 or earlier enterprise bean (EJB), you must specify a JNDI name. The name is used to bind an entry in the global JNDI name space for the EJB home object. An example JNDI name for a Product EJB in a Store application might be store/ejb/Product. The binding definition is stored in the META-INF/ibm-ejb-jar-bnd.xmi file. If a deployer chooses to generate default bindings when installing the application, the installation wizard assigns EJB JNDI names having the form prefix/EJB_name to incomplete bindings. The default prefix is ejb, but can be overridden. The EJB_name is as specified in the deployment descriptor tag. During and after application installation, EJB JNDI names can be specified on the Provide JNDI names for beans page. After installation, click Applications > Application Types > WebSphere enterprise applications > application_name > EJB JNDI names in the administrative console.You do not need to specify JNDI binding names for each of the EJB 3.0 home or business interfaces on your enterprise beans because the EJB container assigns default bindings.

Data sources for entity beans

Entity beans such as container-managed persistence (CMP) beans store persistent data in data stores. With CMP beans, an EJB container manages the persistent state of the beans. You specify which data store a bean uses by binding an EJB module or an individual enterprise bean to a data source. Binding an EJB module to a data source causes all entity beans in that module to use the same data source for persistence. An example JNDI name for a Store data source in a Store application might be store/jdbc/store. For modules earlier than Java EE 5, the binding definition is stored in IBM binding files such as ibm-ejb-jar-bnd.xmi. A deployer can also specify whether authentication is handled at the container or application level. WebSphere Application Server Version 7.0 supports CMP beans in EJB 2.x or 1.x modules. Version 7.0 does not support CMP beans in EJB 3.0 modules. If a deployer chooses to generate default bindings when installing the application, the install wizard generates the following for incomplete bindings:

  • For EJB 2.x .jar files, connection factory bindings based on the JNDI name and authorization information specified
  • For EJB 1.1 .jar files, data source bindings based on the JNDI name, data source user name and password specified
  • The generated bindings provide default connection factory settings for each EJB 2.x .jar file and default data source settings for each EJB 1.1 .jar file in the application being installed. No bean-level connection factory bindings or data source bindings are generated unless they are specified in the custom strategy rule supplied during default binding generation.

During and after application installation, you can map data sources to 2.x entity beans on the 2.x CMP bean data sources page and on the 2.x entity bean data sources page. After installation, click Applications > Application Types > WebSphere enterprise applications > application_name in the administrative console, then select 2.x CMP bean data sources or 2.x entity bean data sources. You can map data sources to 1.x entity beans on the Map data sources for all 1.x CMP beans page and on the Provide default data source mapping for modules containing 1.x entity beans page. After installation, access console pages similar to those for 2.x CMP beans, except click links for 1.x CMP beans.

Backend ID for EJB modules

If an EJB .jar file that defines CMP beans contains mappings for multiple backend databases, specify the appropriate backend ID that determines which persister classes are loaded at run time. Specify the backend ID during application installation. You cannot select a backend ID after the application is installed onto a server. To enable backend IDs for individual EJB modules:

  • During application installation, select Deploy enterprise beans on the Select installation options page. Selecting Deploy enterprise beans enables you to access the Provide options to perform the EJB Deploy page.
  • On the Provide options to perform the EJB Deploy page, set the database type to "" (null).

During application installation, if you select Deploy enterprise beans on the Select installation options page and specify a database type for the EJB deployment tool on the Provide options to perform the EJB Deploy page, previously defined backend IDs for all of the EJB modules are overwritten by the chosen database type. The default database type is DB2UDB_V81. The EJB deployment tool does not run during installation of EJB 3.0 modules. For information on backend databases, refer to EJB deployment tool. For information on EJB Deploy options, refer to The ejbdeploy command.

EJB references

An enterprise bean (EJB) reference is a logical name used to locate the home interface of an enterprise bean. EJB references are specified during deployment. At run time, EJB references are bound to the physical location (global JNDI name) of the enterprise beans in the target operational environment. EJB references are made available in the java:comp/env/ejb Java naming subcontext. The product assigns default JNDI values for or automatically resolves incomplete EJB 3.0 reference targets. For each EJB 2.1 or earlier EJB reference, you must specify a JNDI name. An example JNDI name for a Supplier EJB reference in a Store application might be store/ejb/Supplier. The binding definition is stored in IBM binding files such as ibm-ejb-jar-bnd.xmi. When the referenced EJB is also deployed in the same application server, you can specify a server-scoped JNDI name. But if the referenced EJB is deployed on a different application server or if ejb-ref is defined in an application client module, then you should specify the global cell-scoped JNDI name. If a deployer chooses to generate default bindings when installing the application, the install wizard binds EJB references as follows: If an is found, it is honored. If the ejb-name of an EJB defined in the application matches the ejb-ref name, then that EJB is chosen. Otherwise, if a unique EJB is found with a matching home (or local home) interface as the referenced bean, the reference is resolved automatically. During and after application installation, you can specify EJB reference JNDI names on the Map EJB references to beans page. After installation, click Applications >Application Types > WebSphere enterprise applications > application_name > EJB references in the administrative console. Best practice: To enable EJB reference targets to resolve automatically if the references are from EJB 2.1 or earlier modules or from Web 2.3 or earlier modules, select Generate default bindings on the Preparing for application installation page or select Allow EJB reference targets to resolve automatically on the Select installation options, Map EJB references to beans, or EJB references console pages.bprac

Resource references

A resource reference is a logical name used to locate an external resource for an application. Resource references are specified during deployment. At run time, the references are bound to the physical location (global JNDI name) of the resource in the target operational environment. Resource references are made available as follows:

Table 1. Resource reference subcontexts. JNDI java:comp/env names are used for resource reference subcontexts.
Resource reference type Subcontext declared in
Java DataBase Connectivity (JDBC) data source java:comp/env/jdbc
JMS connection factory java:comp/env/jms
JavaMail connection factory java:comp/env/mail
Uniform Resource Locator (URL) connection factory java:comp/env/url

For each resource reference, you must specify a JNDI name. If a deployer chooses to generate default bindings when installing the application, the install wizard generates resource reference bindings derived from the tag, assuming that the java:comp/env name is the same as the resource global JNDI name. During application installation, you can specify resource reference JNDI names on the Map resource references to references page. Specify JNDI names for the resources that represent the logical names defined in resource references. You can optionally specify login configuration name and authentication properties for the resource. After specifying authentication properties, click OK to save the values and return to the mapping step. Each resource reference defined in an application must be bound to a resource defined in your WebSphere Application Server configuration. After installation, click Applications > Application Types > WebSphere enterprise applications > application_name > Resource references in the administrative console to access the Resource references page.

Virtual host bindings for Web modules

You must bind each Web module to a specific virtual host. The binding informs a Web server plug-in that all requests that match the virtual host must be handled by the Web application. An example virtual host to be bound to a Store Web application might be store_host. The binding definition is stored in IBM binding files such as WEB-INF/ibm-web-bnd.xmi. If a deployer chooses to generate default bindings when installing the application, the install wizard sets the virtual host to default_host for each .war file. During and after application installation, you can map a virtual host to a Web module defined in your application. On the Map virtual hosts for Web modules page, specify a virtual host. The port number specified in the virtual host definition is used in the URL that is used to access artifacts such as servlets and JavaServer Pages (JSP) files in the Web module. For example, an external URL for a Web artifact such as a JSP file is http://host_name:virtual_host_port/context_root/jsp_path. After installation, click Applications > Application Types > WebSphere enterprise applications > application_name > Virtual hosts in the administrative console.

Message-driven beans

For each message-driven bean, you must specify a queue or topic to which the bean will listen. A message-driven bean is invoked by a Java Messaging Service (JMS) listener when a message arrives on the input queue that the listener is monitoring. A deployer specifies a listener port or JNDI name of an activation specification as defined in a connector module (.rar file) under WebSphere Bindings on the Beans page of an assembly tool EJB deployment descriptor editor. An example JNDI name for a listener port to be used by a Store application might be StoreMdbListener. The binding definition is stored in IBM bindings files such as ibm-ejb-jar-bnd.xmi. If a deployer chooses to generate default bindings when installing the application, the install wizard assigns JNDI names to incomplete bindings.

  • For EJB 2.0 or later message-driven beans deployed as JCA 1.5-compliant resources, the install wizard assigns JNDI names corresponding to activationSpec instances in the form eis/MDB_ejb-name.
  • For EJB 2.0 or later message-driven beans deployed against listener ports, the listener ports are derived from the message-driven bean tag with the string Port appended.

During application installation using the administrative console, you can specify a listener port name or an activation specification JNDI name for every message-driven bean on the Bind listeners for message-driven beans page. A listener port name must be provided when using the JMS providers: Version 5 default messaging, WebSphere MQ, or generic. An activation specification must be provided when the application's resources are configured using the default messaging provider or any generic J2C resource adapter that supports inbound messaging. If neither is specified, then a validation error is displayed after you click Finish on the Summary page. Also, if the module containing the message-driven bean is deployed on a 5.x deployment target and a listener port is not specified, then a validation error is displayed after you click Next. After application installation, you can specify JNDI names and configure message-driven beans on console pages under Resources > JMS > JMS providers or under Resources > Resource adapters. Restriction: You can only bind message driven-beans that are defined in an EJB 3.0 module to an activation specification. Message destination references A message destination reference is a logical name used to locate an enterprise bean in an EJB module that acts as a message destination. Message destination references exist only in J2EE 1.4 and later artifacts such as--

  • J2EE 1.4 application clients
  • EJB 2.1 projects
  • 2.4 Web applications

If multiple message destination references are associated with a single message destination link, then a single JNDI name for an enterprise bean that maps to the message destination link, and in turn to all of the linked message destination references, is collected during deployment. At run time, the message destination references are bound to the administered message destinations in the target operational environment. If a message destination reference and a message-driven bean are linked by the same message destination, both the reference and the bean should have the same destination JNDI name. When both have the same name, only the destination JNDI name for the message-driven bean is collected and applied to the corresponding message destination reference. If a deployer chooses to generate default bindings when installing the application, the install wizard assigns JNDI names to incomplete message destination references as follows: If a message destination reference has a , then the JNDI name is set to ejs/message-destination-linkName. Otherwise, the JNDI name is set to eis/message-destination-refName.

Other bindings that might be needed

Depending on the references in and artifacts used by your application, you might need to define bindings for references and artifacts not listed in this topic.

IBM extension and binding files

Type Binding File Name
EJB ibm-ejb-jar-bnd.xmi
ibm-ejb-jar-ext.xmi
Web ibm-web-bnd.xmi
ibm-web-ext.xmi
WebServices ibm-webservices-bnd.xmi
ibm-webservices-ext.xmi,
WebServices Client ibm-webservicesclient-bnd.xmi
ibm-webservicesclient-ext.xmi
Portlet ibm-portlet-ext.xmi


Supported configurations:
For IBM extension and binding files, the .xmi or .xml file name extension is different depending on whether you are using a pre-Java EE 5 application or module or a Java EE 5 or later application or module. An IBM extension or binding file is named ibm-*-ext.xmi or ibm-*-bnd.xmi where * is the type of extension or binding file such as app, application, ejb-jar, or web.
The following conditions apply: For an application or module that uses a Java EE version prior to version 5, the file extension must be .xmi For an application or module that uses Java EE 5 or later, the file extension must be .xml However, a Java EE 5 or later module can exist within an application that includes pre-Java EE 5 files and uses the .xmi file name extension. The ibm-webservices-ext.xmi, ibm-webservices-bnd.xmi, ibm- webservicesclient-bnd.xmi, ibm-webservicesclient-ext.xmi, and ibm-portlet-ext.xmi files continue to use the .xmi file extensions.

Example: Configuring data source provider and data source settings

You can configure data source provider and data source settings. The purpose of this article is to help you to configure data source provider and data source settings.

  • Required fields:
    • Data Source Provider Properties page: name
    • Data Source Properties page: name, jndiName
  • Special cases:
    • The user name and password fields have no equivalent XMI tags. You must specify these fields in the custom properties.
    • The password is encrypted when you use the Application Client Resource Configuration Tool (ACRCT). If you do not use the ACRCT the field cannot be encrypted.

Example:

description="jdbcProvider:description" implementationClassName="jdbcProvider:ImplementationClass"> jdbcProvider:classPath name="jdbcFactory:name" jndiName="jdbcFactory:jndiName" description="jdbcFactory:description" databaseName="jdbcFactory:databasename"> value="jdbcFactory:customValue"/>value="jdbcFactory:user"/> value="{xor}NTs9PBk+PCswLSZlMT4yOg=="/>value="jdbcProvider:customeValue"/>


References:
publib.boulder.ibm.com/infocenter/wasinf...

I will be writing some articles that give practical insights into some of IBM's new Eclipse tools and exposing some of the nuggets that only RAD users were previously privy to. Now things are changing, it is a good time to ensure that everyone can use Eclipse with WAS in an efficient manner.

My blogs articles will cover topics such as packaging, bindings & deployment/application descriptors. I will also add a blog very soon on the different types of MQ access (Bindings client etc) which are avaiable in WAS as these still confused people. The same goes with why we have a Connection Factory and an MQConnection factory which seem to do the same thing.

0 comments
27 views

Permalink