I did not rename Application.cfm to Application.cfc. Sorry I didnāt make that clear. Iām trying to convert my Application.cfm code to Application.cfc and it has been very frustrating to say the least:
Hereās my Application.cfc which does NOT work. Iām getting datasource [MyDSN] doesnāt exist error in Lucee even though itās CLEARLY set below:
component {
this.name="MyApp";
this.applicationTimeout = CreateTimeSpan(0,0,60,0);
this.sessionTimeout = CreateTimeSpan(0,0,60,0);
this.sessionManagement=true;
this.clientManagement = false;
this.datasources["MyDSN"] = {
class: 'com.mysql.jdbc.Driver'
, bundleName: 'com.mysql.jdbc'
, bundleVersion: '5.1.40'
, connectionString: 'jdbc:mysql://localhost:3306/theDB?useUnicode=true&characterEncoding=UTF-8&useLegacyDatetimeCode=true'
, username: 'theUsername'
, password: "thePassword"
// optional settings
, blob:true // default: false
, clob:true // default: false
, connectionLimit:100 // default:-1
};
// Initialize POP component
this.componentpaths["/pop"]= "/opt/lucee/tomcat/webapps/ROOT/WEB-INF/lucee/components/custom/extension/pop4";
}
component {
//Authentication Section
<cfcomponent>
<cfset This.name = "AdminGUI" />
<cfset This.Sessionmanagement="True">
<cfset This.loginstorage="session">\
<cfset datasource="MyDatasource">
<cffunction name="OnRequestStart">
<CFPARAM NAME="session.Loggedin" DEFAULT="FALSE">
<CFIF #session.Loggedin# IS "FALSE">
<cfinclude template="logon.cfm">
<cfabort>
</CFIF>
</cffunction>
</cfcomponent>
}
If I remove the section below Iām not getting the error datasource [MyDSN] doesnāt exist but then my authentication doesnāt work and Iām getting variable [DATASOURCE] dosnāt exist error:
component {
//Authentication Section
<cfcomponent>
<cfset This.name = "AdminGUI" />
<cfset This.Sessionmanagement="True">
<cfset This.loginstorage="session">\
<cfset datasource="MyDatasource">
<cffunction name="OnRequestStart">
<CFPARAM NAME="session.Loggedin" DEFAULT="FALSE">
<CFIF #session.Loggedin# IS "FALSE">
<cfinclude template="logon.cfm">
<cfabort>
</CFIF>
</cffunction>
</cfcomponent>
}
If I try to separate the cfset datasource=āMyDatasourceā> in its own section Iām starting to get weird errors that the name is missing from the cfcomponent even though I clearly define it.
All I want to do is the following:
Define a datasource to my database, defined a component mapping, set my authentication and set a global variable called datasource. It shouldnāt be this hard but itās kicking my butt.