JNDI in Fusion Metadata Registry

From FMR Knowledge Base
Jump to navigation Jump to search

Overview

Fusion Metadata Registry 11.0 supports JNDI connections for storing structural metadata.

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 package (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 1 resources "8063-jnd1" which is a MySQL resource.
The registry is running on localhost: 8063.

<?xml version="1.0" encoding="UTF-8"?>
<Context>
  <Resource
    name="8063-jnd1"
    auth="Container"
    type="javax.sql.DataSource"
    maxIdle="30"
    driverClassName="com.mysql.cj.jdbc.Driver"
    url="jdbc:mysql://localhost:3306/8063-jnd1?useLegacyDatetimeCode=false&serverTimezone=Europe/London&allowLoadLocalInfile=true"
    username="root"
    password="password"
 />
</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 Settings

The values should be:

  • JNDI Name - this must be the name exactly as specified in the resource. E.g. for Apache Tomcat and the examples above of the context.xml file, this could be either jdbc/test1 or test2
  • Context - this is where the Registry will look for the resources. If using Apache Tomcat this value must be specified as java:/comp/env

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.


Error: Import Error Bulk Load Failed

If this occurs then please check the logs of Fusion Registry.

If you are using MySQL and the log file states the following (note this will not all be output on a single line)

BadSqlGrammarException: StatementCallback; bad SQL grammar [LOAD DATA LOCAL INFILE
...
The used command is not allowed with this MySQL version

This issue is caused because your database needs to be configured to permit the bulk loading of data via INFILE. This needs to be performed on the server (database) and within your client. To setup your database to permit this, please see resources on the Internet. To permit this in your Tomcat JNDI connection you may find that you need to edit the URL in the context.xml file so allowLoadLocalInfile is explicitly set to true. For example:

 driverClassName="com.mysql.cj.jdbc.Driver"
 url="jdbc:mysql://localhost:3306/fr-soap-ui?useLegacyDatetimeCode=false&serverTimezone=Europe/London&allowLoadLocalInfile=true"
 username="root"