Difference between revisions of "JNDI In Fusion Registry"

From Fusion Registry Wiki
Jump to navigation Jump to search
(Elements of the Resource)
(Example File)
Line 47: Line 47:
 
     auth="Container"
 
     auth="Container"
 
     type="javax.sql.DataSource"
 
     type="javax.sql.DataSource"
     maxActive="100"
+
     maxTotal="16"
 
     maxIdle="30"
 
     maxIdle="30"
    maxWait="10000"
 
 
     driverClassName="com.mysql.cj.jdbc.Driver"
 
     driverClassName="com.mysql.cj.jdbc.Driver"
 
     url="jdbc:mysql://localhost:3306/fr-soap-ui?useLegacyDatetimeCode=false&serverTimezone=Europe/London"
 
     url="jdbc:mysql://localhost:3306/fr-soap-ui?useLegacyDatetimeCode=false&serverTimezone=Europe/London"
Line 60: Line 59:
 
     auth="Container"
 
     auth="Container"
 
     type="javax.sql.DataSource"
 
     type="javax.sql.DataSource"
     maxActive="100"
+
     maxTotal="16"
 
     maxIdle="30"
 
     maxIdle="30"
    maxWait="10000"
 
 
     driverClassName="com.mysql.cj.jdbc.Driver"
 
     driverClassName="com.mysql.cj.jdbc.Driver"
 
     url="jdbc:mysql://localhost:3306/fusion_registry_temp2?useLegacyDatetimeCode=false&serverTimezone=Europe/London"
 
     url="jdbc:mysql://localhost:3306/fusion_registry_temp2?useLegacyDatetimeCode=false&serverTimezone=Europe/London"

Revision as of 09:40, 25 February 2022

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 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 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"
    maxTotal="16"
    maxIdle="30"
    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"
    maxTotal="16"
    maxIdle="30"
    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 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.