JNDI In Fusion Registry

From Fusion Registry Wiki
Revision as of 02:03, 8 November 2021 by Plazarou (talk | contribs) (In GUI)
Jump to navigation Jump to search

Overview

Fusion Registry 10.8.0 supports JNDI connections for storing structural metadata and for Data Stores

Elements of the Resource

The following items must exist within the resource:

  • name - used to refer to the resource from the UI
  • driver class name - this must be a valid Java packae (see below)
  • url - the connection string used to connect to the database
  • Username and password - to authenticate with the database (optional)

Example driver Class Names

The following are driver class names you should use to connect to various databases:

MySQL com.mysql.cj.jdbc.Driver
Oracle oracle.jdbc.driver.OracleDriver
SQL Server com.microsoft.sqlserver.jdbc.SQLServerDriver

Optional Resource Elements

For non JNDI connections the following settings are set by default:

  • TimeBetweenEvictionRunsMillis = 7200000
  • MinEvictableIdleTimeMillis = 3600000
  • MaxTotal = 10
  • MinIdle = 5
  • DefaultAutoCommit = false
  • MaxWaitMillis = -1

It may be sensible to ensure your resource also sets the values as the above

Applying to a Tomcat Instance

Create or edit the file config.xml and place this in the directory conf.

Restart your Apache Tomcat instance. To use a resource defined in config.xml, refer to the resource name in the Registry User Interface.

Example File

The following shows an example of a valid context.xml file. This example declares 2 resources "jdbc/test1" and "test2" both of which are MySQL resources.

<?xml version="1.0" encoding="UTF-8"?>
<Context>
  <Resource
    name="jdbc/test1"
    auth="Container"
    type="javax.sql.DataSource"
    maxActive="100"
    maxIdle="30"
    maxWait="10000"
    driverClassName="com.mysql.cj.jdbc.Driver"
    url="jdbc:mysql://localhost:3306/fr-soap-ui?useLegacyDatetimeCode=false&serverTimezone=Europe/London"
    username="root"
    password="myPassword"
  />

  <Resource
    name="test2"
    auth="Container"
    type="javax.sql.DataSource"
    maxActive="100"
    maxIdle="30"
    maxWait="10000"
    driverClassName="com.mysql.cj.jdbc.Driver"
    url="jdbc:mysql://localhost:3306/fusion_registry_temp2?useLegacyDatetimeCode=false&serverTimezone=Europe/London"
    username="root"
    password="myPassword"
  />
</Context>

Setting in the Registry User Interface

To specify JNDI as the database name, either on the install pages or on the settings page: Settings -> Server Settings -> Database

In the dropdown select "JNDI connection"

In the fields enter the JNDI name and the context

JNDI-Setting.png

Troubleshooting

Error: Unable to determine Java Driver class from JNDI information.

This manifests itself with the error message:

Unable to determine Java Driver class from JNDI information.
Cannot create JDBC driver of class 'oracle.jdbc.driver.OracleDriver' for connect URL 'jdbc\:oracle\:thin\:@localhost\:1521/orapdb1'
No suitable driver

Possible Fix 1: Your Tomcat has not been supplied with the appropriate Oracle driver. Copy the jar file (ojdbc8.jar) to the 'lib' directory of Tomcat.

Possible Fix 2: Your "url" is incorrect and this is causing the issue. Look at your context.xml file and ensure that your "url" is specified correctly in your resource.