This chapter includes the following sections:
This section describes how to create a new WebLogic resource adapter. The next section, Modifying an Existing Resource Adapter, describes how to take an existing resource adapter and prepare it for deployment on WebLogic Server.
To create a new WebLogic resource adapter, you must create the classes for the particular resource adapter (
Connection, and so on), write the resource adapter's deployment descriptors, and then package everything into an archive file to be deployed to WebLogic Server.
The following are the main steps for creating a resource adapter:
Write the Java code for the various classes required by resource adapter (
Connection, and so on) in accordance with JSR 322: Java EE Connector Architecture 1.6. These classes will be specified in the
ra.xml file. For example:
<managedconnectionfactory-class> com.sun.connector.blackbox.LocalTxManagedConnectionFactory </managedconnectionfactory-class> <connectionfactory-interface> javax.sql.DataSource </connectionfactory-interface> <connectionfactory-impl-class> com.sun.connector.blackbox.JdbcDataSource </connectionfactory-impl-class> <connection-interface> java.sql.Connection </connection-interface> <connection-impl-class> com.sun.connector.blackbox.JdbcConnection </connection-impl-class>
For 1.6 adapters, you can embed metadata annotations in the resource adapter class files to specify deployment information, eliminating the need to create the
ra.xml file manually. For more information, see Configuring the ra.xml File.
The WebLogic Server implementation of Connector Architecture 1.6 includes support for Contexts and Dependency Injection. This support has implications on the set of annotations that may be used in resource adapter component beans, which are beans that define special components managed by the Connector container and that have a special life cycle. For more information, see
For more information about programming resource adapters, see Chapter 4, "Programming Tasks."
Compile the Java code for the interfaces and implementation into class files, using a standard compiler.
Create the resource adapter's deployment descriptors. A WebLogic resource adapter uses two deployment descriptor files:
ra.xml describes the resource adapter-related attributes type and its deployment properties using the standard XML schema specified by the Java EE Connector Architecture specification.
Java EE Connector Architecture 1.6 no longer requires the
ra.xml file to be created manually. Instead, deployment information can be specified in metadata annotations. See Configuring the ra.xml File.
weblogic-ra.xml adds additional WebLogic Server-specific deployment information, including connection and connection pool properties, security identities, Work Manager properties, and logging.
Package the Java classes into a Java archive (JAR) file with a
Create a staging directory anywhere on your hard drive. Place the JAR file in the staging directory and the deployment descriptors in a subdirectory called
Then create the resource adapter archive by executing a
jar command similar to the following in the staging directory:
jar cvf myRAR.rar *
Optionally, you can include the Bean Validation configuration file,
META-INF/validation.xml, inside the JAR file. WebLogic Server uses the Bean Validation configuration file to validate the resource adapter module.
Deploy the resource adapter archive (RAR) file on WebLogic Server in a test environment and test it.
During testing, you may need to edit the resource adapter deployment descriptors. You can do this using the WebLogic Server Administration Console or manually using an XML editor or a text editor. For more information about editing deployment descriptors, see Configuring the weblogic-ra.xml File, and "Configure resource adapter properties" in the Oracle WebLogic Server Administration Console Online Help. See also Appendix A, "weblogic-ra.xml Schema," for detailed information on the elements in the deployment descriptor.
Deploy the RAR resource adapter archive file on WebLogic Server or include it in an enterprise archive (EAR) file to be deployed as part of an enterprise application.
For information about these steps, see Chapter 10, "Packaging and Deploying Resource Adapters." See also Deploying Applications to Oracle WebLogic Server for detailed information about deploying components and applications in general.
In some cases, you may already have a resource adapter available for deployment to WebLogic Server. This section describes how to take an existing resource adapter that is packaged in a RAR file and modify it for deployment to WebLogic Server. This involves adding the
weblogic-ra.xml deployment descriptor and repackaging the resource adapter. The following procedure supposes you have an existing resource adapter packaged in a RAR file named
Create a temporary directory anywhere on your hard drive to stage the resource adapter:
Extract the contents of the resource adapter archive:
cd c:/stagedir jar xf blackbox-notx.rar
The staging directory should now contain the following:
A JAR file containing Java classes that implement the resource adapter
A META-INF directory containing the Manifest.mf and ra.xml files
Execute these commands to see these files:
c:/stagedir> ls blackbox-notx.rar META-INF c:/stagedir> ls META-INF Manifest.mf ra.xml
weblogic-ra.xml file. This file is the WebLogic-specific deployment descriptor for resource adapters. In this file, you specify parameters for connection factories, connection pools, and security settings.
weblogic-ra.xml file into the temporary directory's
META-INF subdirectory. The
META-INF directory is located in the temporary directory where you extracted the RAR file or in the directory containing a resource adapter in exploded directory format. Use the following command:
cp weblogic-ra.xml c:/stagedir/META-INF c:/stagedir> ls META-INF Manifest.mf ra.xml weblogic-ra.xml
Create the resource adapter archive:
jar cvf blackbox-notx.rar -C c:/stagedir
Deploy the resource adapter to WebLogic Server. For more information about packaging and deploying the resource adapter, see Chapter 10, "Packaging and Deploying Resource Adapters," and Deploying Applications to Oracle WebLogic Server.
All resource adapters must be specified in an
ra.xml deployment descriptor file. For 1.0 or 1.5 resource adapters, you must create this file manually. If you are creating a 1.6 resource adapter, you can optionally specify metadata annotations in the resource adapter classes, eliminating the need to create the
ra.xml file manually. The following sections explain how to configure the
For more information about creating a
ra.xml file, you can also refer to JSR 322: Java EE Connector Architecture 1.6.
If your resource adapter does not already contain a
ra.xml file, and you are creating a 1.0 or 1.5 resource adapter, you must manually create or edit an existing one to set the necessary deployment properties for the resource adapter. You can use a text editor or XML editor to edit the properties.
The Java EE Connector Architecture 1.6 no longer requires you to manually create a
ra.xml file. Instead, metadata annotations can be included in resource adapter classes to provide the same functions that are specified in the
If you choose to specify all deployment information in a
ra.xml file, the Java EE Connector Architecture 1.6 includes the
metadata-complete element, which you include in the
ra.xml file and set to
true. Setting the
metadata-complete element to
true causes all metadata annotations included in the resource adapter classes to be ignored. If the
metadata-complete element is not specified, or is set to
false, WebLogic Server merges the information specified in the annotations with the information specified in the
ra.xml file at run time, and uses this merged information to deploy and manage the resource adapter.
For more information about deployment descriptors and annotations, see Chapter 18, "Metadata Annotations," of JSR 322: Java EE Connector Architecture 1.6. See also "Metadata Annotations" in The Java EE 6 Tutorial.
The Java EE Connector Architecture 1.6 introduces changes to the
ra.xml file schema, primarily to support ease-of-development features such as metadata annotations. For details about schema definition changes, see Section 20.7, "Resource Adapter XML Schema Definition," in JSR 322: Java EE Connector Architecture 1.6.
The schema for the
ra-xml file for 1.0 and 1.5 resource adapters is
http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd. For 1.6 adapters, the schema is
In addition to supporting features of the standard resource adapter configuration
ra.xml file, WebLogic Server defines an additional deployment descriptor file, the
weblogic-ra.xml file. This file contains parameters that are specific to configuring and deploying resource adapters in WebLogic Server. This functionality is consistent with the equivalent
weblogic-*.xml extensions for EJBs and Web applications in WebLogic Server, which also add WebLogic-specific deployment descriptors to the deployable archive. The basic RAR or deployment directory can be deployed to WebLogic Server without a
weblogic-ra.xml file. If a resource adapter is deployed in WebLogic Server without a weblogic-ra.xml file, a template
weblogic-ra.xml file populated with default element values is automatically added to the resource adapter archive. However, this automatically generated
weblogic-ra.xml file is not persisted to the RAR; the RAR remains unchanged.
The following summarizes the most significant features you can configure in the
weblogic-ra.xml deployment descriptor file.
Descriptive text about the connection factory.
JNDI name bound to a connection factory. (Resource adapters developed based on JSR 322: Java EE Connector Architecture 1.6 are bound in the JNDI as objects independently of their
Reference to a separately deployed connection factory that contains resource adapter components that can be shared with the current resource adapter.
Connection pool parameters that set the following behavior:
Initial number of
ManagedConnections that WebLogic Server attempts to allocate at deployment time.
Maximum number of
ManagedConnections that WebLogic Server allows to be allocated at any one time.
ManagedConnections that WebLogic Server attempts to allocate when filling a request for a new connection.
Whether WebLogic Server attempts to reclaim unused
ManagedConnections to save system resources.
The time WebLogic Server waits between attempts to reclaim unused
Logging properties to configure WebLogic Server logging for the
Transaction support levels (XA, local, or no transaction support).
Principal names to use as security identities.
For detailed information about configuring the
weblogic-ra.xml deployment descriptor file, see the reference information in Appendix A, "weblogic-ra.xml Schema." See also the configuration information in the following sections:
To define or make changes to the XML descriptors used in the WebLogic Server resource adapter archive, you must define or edit the XML elements in the
ra.xml deployment descriptor files. You can edit the deployment descriptor files with any plain text editor. However, to avoid introducing errors, use a tool designed for XML editing.You can also edit most elements of the files using the WebLogic Administration Console.
To edit XML elements manually:
If you use an ASCII text editor, make sure that it does not reformat the XML or insert additional characters that could invalidate the file.
Use the correct case for file and directory names, even if your operating system ignores the case.
To use the default value for an optional element, you can either omit the entire element definition or specify a blank value. For example:
When editing or creating XML deployment files, it is critical to include the correct schema header for each deployment file. The header refers to the location and version of the schema for the deployment descriptor.
Although this header references an external URL at
java.sun.com, WebLogic Server contains its own copy of the schema, so your host server need not have access to the Internet. However, you must still include this
<?xml version...> element in your
ra.xml file, and have it reference the external URL because the version of the schema contained in this element is used to identify the version of this deployment descriptor.
Table 3-1 shows the entire schema headers for the
|XML File||Schema Header|
<?xml version="1.0" encoding="UTF-8"?> <connector xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/connector_1_6.xsd" version="1.6">
<?xml version = "1.3"> <weblogic-connector xmlns="http://xmlns.oracle.com/weblogic/weblogic-connector">
XML files with incorrect header information may yield error messages similar to the following, when used with a utility that parses the XML (such as
SAXException: This document may not have the identifier 'identifier_name'
The contents and arrangement of elements in your deployment descriptor files must conform to the schema for each file you use. The following links provide the public schema locations for deployment descriptor files used with WebLogic Server:
connector_1_6.xsd contains the schema for the standard
ra.xml deployment file, required for all resource adapters. This schema is maintained as part of JSR 322: Java EE Connector Architecture 1.6 and is located at
weblogic-ra.xsd contains the schema used for creating
weblogic-ra.xml, which defines resource adapter properties used for deployment to WebLogic Server. This schema is located at
Your browser might not display the contents of files having the
.xsd extension. In that case, to view the schema contents in your browser, save the links as text files and view them with a text editor.
You can use the Administration Console to view, modify, and (when necessary) persist deployment descriptor elements. Some descriptor element changes take place dynamically at run time without requiring the resource adapter to be redeployed. Other descriptor elements require redeployment after changes are made. To use the Administration Console to configure a resource adapter, open Deployments and click the name of the deployed resource adapter. Use the Configuration tab to change the configuration of the resource adapter and the other tabs to control, test, or monitor the resource adapter.
For information about using the Administration Console, see "Configure resource adapter properties" in the Oracle WebLogic Server Administration Console Online Help.
Dynamic reconfigurable configuration properties are described in Section 188.8.131.52 of JSR 322: Java EE Connector Architecture 1.6. For 1.6 resource adapters, WebLogic Server supports dynamic reconfigurable configuration properties for the following adapter component beans:
Administered object beans
At run time, after you update the dynamically configurable properties on any of these adapter component beans, you must update the adapter to put changes into effect. Updating the adapter is a relatively lightweight operation during which WebLogic Server modifies the run-time bean instances without interfering with active connection pools or admin objects that do not have configuration updates. You do not need to update the adapter immediately. However, changes to properties on adapter component beans do not go into effect unless the beans are dynamically updated or the resource adapter is restarted.
The resource adapter should be designed carefully with regard to support for dynamic changes to its properties during run time. Depending on the services provided by the resource adapter, it might be critically important that some properties should never be reconfigured when the adapter is running; for example, the listen address and port number of a resource adapter used for the EIS connection (any reconfiguration of those properties should require the adapter to be shut down and restarted). WebLogic Server does not impose any requirements on an adapter component bean with regard to whether specific properties may or may not be designated as dynamically reconfigurable. It is entirely for the adapter developer to decide which adapter component beans support dynamic update and which do not.
For 1.6 adapters, WebLogic Server supports dynamic update on properties of
ManagedConnectionFactory, and admin object beans. Using the Administration Console, you can modify the following configuration parameters on those beans dynamically, without requiring the resource adapter to be redeployed:
Edit the adapter JNDI name
Create and delete outbound connection pools
Edit the connection pool JNDI name
Create and delete admin objects
Edit admin object JNDI names
Using the Administration Console, you can modify the following
weblogic-ra.xml pool parameters dynamically, without requiring the resource adapter to be redeployed:
A resource adapter archive (RAR) deployed on WebLogic Server must include a
weblogic-ra.xml deployment descriptor file in addition to the
ra.xml deployment descriptor file specified in JSR 322: Java EE Connector Architecture 1.6.
If a resource adapter is deployed in WebLogic Server without a
weblogic-ra.xml file, a template
weblogic-ra.xml file populated with default element values is automatically added to the resource adapter archive. However, this automatically generated
weblogic-ra.xml file is not persisted to the RAR; the RAR remains unchanged. WebLogic Server instead generates internal data structures that correspond to default information in the
For a 1.0 resource adapter that is a single connection factory definition, the JNDI name will be
ModuleName. For example, if the RAR is named
MySpecialRA.rar, the JNDI name of the connection factory will be
For a 1.5 resource adapter with a
ResourceAdapter bean class specified, the JNDI name of the bean would be
MySpecialRA. Each connection factory would also have a corresponding instance created with a JNDI name of
ModuleName_2, and so on.
The Link-Ref mechanism was introduced in the 8.1 release of WebLogic Server to enable the deployment of a single base adapter whose code could be shared by multiple logical adapters with various configuration properties. For 1.5 resource adapters in the current release, the Link-Ref mechanism is deprecated and is replaced by the new Java EE libraries feature. However, the Link-Ref mechanism is still supported in this release for 1.0 resource adapters. For more information on Java EE libraries, see "Creating Shared Java EE Libraries and Optional Packages" in Developing Applications for Oracle WebLogic Server. To use the Link-Ref mechanism, use the
ra-link-ref element in your resource adapter's
The deprecated and optional
ra-link-ref element allows you to associate multiple deployed resource adapters with a single deployed resource adapter. In other words, it allows you to link (reuse) resources already configured in a base resource adapter to another resource adapter, modifying only a subset of attributes. The
ra-link-ref element enables you to avoid - where possible - duplicating resources (such as classes, JARs, image files, and so on). Any values defined in the base resource adapter deployment are inherited by the linked resource adapter, unless otherwise specified in the
If you use the optional
ra-link-ref element, you must provide either all or none of the values in the
pool-params element. The
pool-params element values are not partially inherited by the linked resource adapter from the base resource adapter.
Do one of the following:
max-capacity element the value of
0 (zero). This allows the linked resource adapter to inherit its
pool-params element values from the base resource adapter.
max-capacity element any value other than
0 (zero). The linked resource adapter will inherit no values from the base resource adapter. If you choose this option, you must specify all of the
pool-params element values for the linked resource adapter.
For further instructions on editing the
weblogic-ra.xml file, see Appendix A, "weblogic-ra.xml Schema."
In its support of JSR 303: Bean Validation, WebLogic Server extends Java EE 6 by providing a module-level bean validation configuration file. WebLogic Server supports the optional use this file to validate a resource adapter module.
The bean validation configuration file can be specified for a resource adapter module regardless of whether the resource adapter is deployed independently (as a standalone RAR) or as part of an enterprise application (EAR). If no bean validation configuration file is specified for an adapter module, WebLogic Server uses a default bean validation configuration to validate the resource adapter module.
The bean validation configuration file is named
validation.xml and is included among the deployment descriptors in the
META-INF subdirectory of the RAR.
For more information about bean validation, see Bean Validation.
Section 11.7 of JSR 322: Java EE Connector Architecture 1.6 defines two standard hints to control the quality-of-service (QoS) characteristics afforded to it by the
Work Name Hint — Names a
Work instance and is used as part of the thread name assigned to a long-running Work instance.
Work instance Hint — Performs the same function as the WebLogic Server extension annotation @LongRunning, which allows you to schedule a
Work instance in a separate thread and that also facilitates the control and monitoring capabilities of long-running Work instances.
WebLogic Server allows you to configure a limit on the number of long-running
Work instances that can be submitted by a resource adapter to be executed concurrently. The default limit is 10. You can change the limit to higher value, but you need to exercise care not to overburden system resources.
This limit can be specified either by using the
max-concurrent-long-running-requests element in the
weblogic-ra.xml file or by setting
ConnectorWorkManagerRuntimeMBean.ActiveLongRunningRequests attribute, which is exposed in the Administration Console. The
ConnectorWorkManagerRuntimeMBean includes getter and setter methods on the
CompletedLongRunningRequests attributes that allow you to configure and monitor information about long-running
For more information, see Configuring and Managing Long-Running Work.
WebLogic Server supports the following tools, which can be used to help with resource adapter development and deployment:
Performs validation checks metadata annotations. When used with the
weblogic.appmerge generates a merged
ra.xml that combines deployment information specified in annotations with the contents of any pre-existing
After you run the
weblogic.appmerge tool, make sure the
metadata-complete element in the merged
ra.xml is set to
true. This prevents the deployer from processing annotations again, which improves overall deployment performance and reduces deployment time.
For more information, see "Using weblogic.appmerge to Merge Libraries" in Developing Applications for Oracle WebLogic Server.
Performs extensive validation checks on annotations, bean classes,
weblogic-ra.xml, and the resource adapter deployment plan (
weblogic.appmerge validates annotations only).
appc tool also:
Provides extensive reports that include both warnings and errors.
Is particularly useful for validating a resource adapter and ensuring that its configuration is correct without having to deploy it.
For more information, see "appc Reference" in Developing Enterprise JavaBeans, Version 2.1, for Oracle WebLogic Server.
WebLogic Server provides the ability to monitor the health status of standalone and embedded resource adapters. By default if a standalone or embedded resource adapter has a deployment error, the entire deployment of the adapter fails with a health status of HEALTH_FAILED. However, if the resource adapter includes multiple outbound connection pools and its deploy-as-a-whole flag is set to
false, the adapter deployment can succeed even if one or more outbound connection pool failures occur. You can use the health monitoring feature to detect connection pool failures and repair them without needing to redeploy the adapter.
The following sections explain how resource adapter health status monitoring is available in WebLogic Server:
To support health monitoring in both standalone and embedded resource adapters, WebLogic Server provides the following MBean attributes, whose values can be obtained using the WebLogic Server Administration Console, WLST, or JMX:
ConnectorComponentRuntimeMBean.HealthState — Returns the overall health state of either a standalone or embedded resource adapter. If an outbound connection pool has a deployment failure, the health state of the resource adapter is HEALTH_CRITICAL.
ApplicationRuntimeMBean.OverallHealthState — Returns the aggregated health state of the application, including that of the embedded components that report health. If an embedded resource adapter contains a failed outbound connection pool, the health state of that connection pool is reflected in the overall health of the application.
ConnectorConnectionPoolRuntimeMBean.HealthState — Returns health state of the individual outbound connection pool in a resource adapter.
To deploy a resource adapter that is configured with multiple outbound connection pools so that a failed connection pool does not cause the whole adapter deployment to fail, you must set the
deploy-as-a-whole element in the
weblogic-ra.xml file to
false. (By default, this element is set to
true.) For information about setting this deployment option, see Deploying a Resource Adapter Configured with Multiple Outbound Connection Pools .