Specifying type='mysql' within Application.cfc datasource definition raises exception due to hard coded reference to org.gjt.mm.mysql.Driver

Description

Issue:

As per existing documentation (e.g. https://docs.lucee.org/guides/cookbooks/datasource-define-datasource.html) it should be possible to create a datasource within Application.cfc, specifying type, port & host parameters as opposed to manually specifying the class and connectionString parameters, as per the following:

public String getFoo() this.datasources["nodatabase"] = { database='' ,password='****************' ,username='********' ,host='192.168.48.1' ,port='5005' ,type='mysql' };

This functionality worked as per expectations under Lucee 5.2.

Under Lucee 5.3, this code results in the following exception being raised when the datasource is first accessed:

lucee.commons.lang.ClassException: cannot load class through its string name, because no definition for the class with the specified name [org.gjt.mm.mysql.Driver] could be found caused by (java.lang.ClassNotFoundException:org.gjt.mm.mysql.Driver not found by lucee.core [46];java.lang.ClassNotFoundException:org.gjt.mm.mysql.Driver;)

Declaring the datasource within Application.cfc using class (pointing to the driver which is shipped with 5.3) and connectionString works as expected, as per the following:

this.datasources["nodatabase"] = { database='' ,password='****************' ,username='********' ,class= 'com.mysql.cj.jdbc.Driver' ,connectionString= 'jdbc:mysql://192.168.48.1:5005' };

Cause:

I believe the cause for this issue is a per the below:

Within function lucee.runtime.db.DBUtil. getDataSourceDefintionForType() https://github.com/lucee/Lucee/blob/5.3/core/src/main/java/lucee/runtime/db/DBUtil.java#L43 a reference is made to https://github.com/lucee/Lucee/blob/5.3/core/src/main/java/lucee/runtime/db/DBUtil.java#L30 which has a hard coded reference to org.gjt.mm.mysql.Driver:

private static DataSourceDefintion MYSQL = new DataSourceDefintion("org.gjt.mm.mysql.Driver", "jdbc:mysql://{host}:{port}/{database}", 3306);

As org.gjt.mm.mysql.Driver no longer ships with Lucee 5.3 - and has been replaced with com.mysql.cj.jdbc.Driver, this reference is now incorrect and causes java.lang.ClassNotFoundException:org.gjt.mm.mysql.Driver to be raised.

I believe this reference potentially needs to be updated to point to the correct class.

Please note there are other hard coded references within the Lucee codebase (another 3 in total), some of which may also need updating, though I believe this is the one which is causing the described issue.

Environment

Lucee 5.3 (tested with Lucee 5.3.1.102 - but still present in latest 5.3 source)
Tested on docker loaded through commandbox

Activity

Show:

Dan Lancelot 8 October 2020 at 08:52

Hi ,

Sorry, didn’t see your last message.

I haven’t re-tested since my last comment (we moved to setting the connection string / driver directly as per the second snippet, as that syntax worked consistently).

However, based on the testing we performed at the time, I’m happy for this ticket to be closed.

Pothys - MitrahSoft 7 October 2020 at 14:21

Did you see my above comment?. The issue resolved means, shall I close this ticket?

Pothys - MitrahSoft 26 March 2020 at 15:01

, As per your last comment, the issue has been resolved for you?

Dan Lancelot 12 July 2019 at 15:15
Edited

I have re-tested against 5.3.3.60-RC, and I can confirm that this issue appears to be resolved.

Issue is still occurring against current 5.3.2.77 release - which matches expectations as this fix appears to have been committed to 5.3.3 branch and not 5.3.2.

Is is possible to advise how far off release status 5.3.3.60 is?

I couldn't locate another issue which was a duplicate of this at the time when I raised the issue... I assumed it had been fixed as a result of this issue (commit was made by you 1 day after I had raised the issue... although now I look it seems it was assigned to you the day after the commit had been made!)... so possibly a duplicate slightly smiling face

In any case, it appears to be resolved in latest RC.

Thanks.

Michael Offner 12 July 2019 at 13:24

i assume that this is an duplicate and the issue is already solved.
does an update solve the issue for you?

Fixed

Details

Assignee

Reporter

Priority

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Affects versions

Created 8 May 2019 at 15:07
Updated 9 October 2020 at 13:34
Resolved 9 October 2020 at 13:34

Flag notifications