In order to deploy resources like data sources or JMS destinations along with your applications you need to use a special format for your applications called Enhanced EAR. A WebSphere Enhanced EAR file is a regular Java EE EAR file but with additional configuration information for resources required by Java EE applications.
When an Enhanced EAR is deployed to WebSphere Application Server, the resources
specified in the Enhanced EAR are automatically configured using a pre-define scope as shown in this table:
Resource
|
Scope
|
JDBC Providers & Data sources
|
Application
|
JMS resources
|
Application
|
Resource adapters
|
Application
|
Class loaders
|
Application
|
Substitution variables
|
Application
|
Shared libraries
|
Server
|
JAAS authentication alias
|
Cell
|
Virtual hosts
|
Cell
|
If you want to create an Enhanced EAR then it’s highly suggested to use a development tool like Rational Application Developer (RAD) or IBM Assembly and Deploy Tools for Websphere.
You can evaluate Websphere Rational Application Developer (RAD) from the IBM site: http://www.ibm.com/developerworks/downloads/r/rad/ . If you want to develop applications using free tools, check out Chapter 7 which is about installing “IBM Websphere developer tool”.
Creating an Enhanced EAR using RAD
Once that you created an Enterprise Application Project, in order to access the Enhanced EAR deployment options, right-click the EAR project, and select Java EE > Open WebSphere Application Server Deployment.
This will open the deployment editor containing all the enhancements you can apply on your Enterprise application (in this sample, the EAR is just made up of an EJB archive)
To configure JDBC providers, expand at first the Authentication section, so that we create an authentication alias for your Connection, (remember just as we did before using the Web console).
The Alias is just a reference name for your Authentication Entry, whose User id and Password are obviously your database credentials. Next, expand the Data Sources section. As you can see, there’s already a pre-configured JDBC provider for the Derby database. (You can remove this Entry by clicking on the Remove button).
To configure an Oracle JDBC provider, complete the following steps:
- Click Add next to upper JDBC Provider list.
- In the window that opens, select the following options (as shown in the picture):
– Oracle as the Database type
– Oracle JDBC thin driver as the JDBC provider type
In the next window, enter a name for the JDBC provider and check that the Class path information and Native Path both map to the location where the JDBC driver is:
Now your JDBC Provider will be enlisted in the Websphere Deployment screen, as shown by the following picture:
Ok, now it’s time to define your data source so move to the “Data Sources” section and click on Add. In the next screen, you will need to select the JDBC driver which will be used by the Data Source:
Next, enter all the Connection details as shown by the following picture:
By clicking on Finish, you should be able to see your data source enlisted in the Data Sources section along with the connection properties:
Ok, now your EAR is ready to be exported into WAS along with the data source information that is contained in a file named resources.xml. If you are curious to know what an Enhanced EAR looks like, have a look into the META-INF folder of the EAR archive:
SAMPLEEJBEAR.EAR\META-INF
│ MANIFEST.MF
│
└───ibmconfig
└───cells
└───defaultCell
│ security.xml
│ virtualhosts.xml
│
├───applications
│ └───defaultApp
│ └───deployments
│ └───defaultApp
│ deployment.xml
│ resources.xml
│ variables.xml
│
└───nodes
Now deploy your application (See Chapter 8 for more information about it application deployment). Within your Enterprise Applications screen, select your application and click on the “Application scoped resources” option (contained in the References section):
As you can see, the OracleDataSource we have configured with RAD now ships with your application and is ready for serving requests of your application.