Fixed
Details
Assignee
Michael OffnerMichael OffnerReporter
Dan LancelotDan LancelotPriority
NewLabels
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
Details
Details
Assignee
Michael Offner
Michael OffnerReporter
Dan Lancelot
Dan LancelotPriority
Labels
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
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 theclass
andconnectionString
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) andconnectionString
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 toorg.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 withcom.mysql.cj.jdbc.Driver
, this reference is now incorrect and causesjava.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.