What is the recommended way to install a JDBC driver in EAP 6/7
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 6
- 7
Issue
- Should drivers be packaged/bundled with the application?
- Are there advantages to installing JDBC driver using a module?
- Is it recommended to install a JDBC driver as a simple jar deployment or is it better to use a module-based deployment?
Resolution
Driver JAR files should NOT be packaged in the application.
- EAP datasources are dependent on and cannot be successfully loaded without the driver.
- Core EAP functionality (e.g. datasources configured in the
standalone*.xmlordomain.xml) should not depend on deployment of applications which may, themselves, depend on datasources to have already been successfully configured/loaded. - Note that bundling a driver in the application when that driver is already deployed in EAP will often lead to class loading conflicts
- Classes loaded by the application class loader are not interchangeable/compatible with those loaded by a JAR or module class loader
A JDBC driver may be installed either as a simple JAR deployment or as part of a module depending on specific use cases/requirements.
Simple JAR Deployment
- This is the simplest approach for installing a driver and is recommended for most single-JAR driver implementations.
- JAR based deployments cannot be used if the JDBC driver implementation consists of/requires multiple JAR files.
- JAR based deployments can be created and managed using the web-based administration console.
- In domain configurations, JAR based deployments are automatically published/distributed to all hosts.
Driver Module
- Supports drivers that consist of multiple distinct JAR files or which require custom dependencies.
- Supports lazy/optional loading of the driver only if/at the point it is used by a datasource or by an application.
- May facilitate more structured/clear management of multiple versions of a single driver type (e.g. when using a module per driver version).
- This is a matter of preference and relates primarily to naming/readability
- NOTE: Modules cannot be created or managed using the web-based administration console.
- Modules may be created using CLI (in standalone configurations only) or via manual file system operations (in standalone and domain configurations).
- In domain configurations, the module must be explicitly installed on every host for any profile with datasources or applications which require the driver.
SBR
Components
Category
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.