[ColdBox 3.6.1] ORM - datasource [null] doesn't exist error

Good afternoon,

I was following the Model Integration Guide on the wiki under the ORM section. I setup my ColdBox app to basically mirror the examples on the page. However, when I go to hit the index for the handler I created to try this I get “datasource [null] doesn’t exist” as an error. The only place that I have to define the datasource is in my Application.cfc, correct? I’ve checked and double-checked everything to make sure that I haven’t missed anything. My Application.cfc contains the same code as the wiki example (except the datasource name) in the OnRequestStart method. I know it’s a valid datasource as the rest of my app uses it without problem. I’m running out of places to look. Any help would be appreciated.

Thanks,
Scott

Hi Scott,

Which CF engine you are using Railo or Adobe ? Also make sure you have correct orm-settings in Application.cfc

Thanks

Can we get the stack trace of the error please?

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Sana,

I’m on Railo 4.0.4 and I have the same settings that are on the wiki page with the exception that my datasource is named “career” instead of “contact”

Brad, I’ll get the stack trace as soon as I get back in the office tomorrow morning.

Thanks,
Scott

sorry, wasn’t thinking, I have access to it now…

ID: ??
LINE: 4
Template: /var/www/scott/handlers/skills.cfc
ID: ??
LINE: 756
Template: /var/www/coldbox/system/web/Controller.cfc
ID: ??
LINE: 640
Template: /var/www/coldbox/system/web/Controller.cfc
ID: ??
LINE: 236
Template: /var/www/coldbox/system/Coldbox.cfc
ID: ??
LINE: 44
Template: /var/www/scott/Application.cfc
datasource [null] doesn't exist
	at railo.runtime.config.ConfigImpl.getDataSource(ConfigImpl.java:2597):2597
	at railo.runtime.orm.hibernate.HibernateORMEngine.createSession(HibernateORMEngine.java:129):129
	at railo.runtime.PageContextImpl.getORMSession(PageContextImpl.java:3191):3191
	at railo.runtime.orm.ORMUtil.getSession(ORMUtil.java:30):30
	at railo.runtime.orm.ORMUtil.getSession(ORMUtil.java:26):26
	at railo.runtime.functions.orm.EntityNew.call(EntityNew.java:24):24
	at railo.runtime.functions.orm.EntityNew.call(EntityNew.java:20):20
	at scott.handlers.skills_cfc$cf.udfCall(/var/www/scott/handlers/skills.cfc:4):4
	at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:103):103
	at railo.runtime.type.UDFImpl._call(UDFImpl.java:371):371
	at railo.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:275):275
	at railo.runtime.ComponentImpl._call(ComponentImpl.java:608):608
	at railo.runtime.ComponentImpl._call(ComponentImpl.java:490):490
	at railo.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1796):1796
	at railo.runtime.tag.Invoke.doComponent(Invoke.java:209):209
	at railo.runtime.tag.Invoke.doEndTag(Invoke.java:182):182
	at coldbox.system.web.controller_cfc$cf._6(/var/www/coldbox/system/web/Controller.cfc:756):756
	at coldbox.system.web.controller_cfc$cf.udfCall(/var/www/coldbox/system/web/Controller.cfc):-1
	at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:103):103
	at railo.runtime.type.UDFImpl._call(UDFImpl.java:371):371
	at railo.runtime.type.UDFImpl.call(UDFImpl.java:284):284
	at railo.runtime.type.scope.UndefinedImpl.call(UndefinedImpl.java:775):775
	at railo.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:723):723
	at railo.runtime.PageContextImpl.getFunction(PageContextImpl.java:1506):1506
	at coldbox.system.web.controller_cfc$cf._5(/var/www/coldbox/system/web/Controller.cfc:640):640
	at coldbox.system.web.controller_cfc$cf.udfCall(/var/www/coldbox/system/web/Controller.cfc):-1
	at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:103):103
	at railo.runtime.type.UDFImpl._call(UDFImpl.java:371):371
	at railo.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:275):275
	at railo.runtime.ComponentImpl._call(ComponentImpl.java:608):608
	at railo.runtime.ComponentImpl._call(ComponentImpl.java:490):490
	at railo.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1800):1800
	at railo.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:749):749
	at railo.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1521):1521
	at coldbox.system.coldbox_cfc$cf._1(/var/www/coldbox/system/Coldbox.cfc:236):236
	at coldbox.system.coldbox_cfc$cf.udfCall(/var/www/coldbox/system/Coldbox.cfc):-1
	at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:103):103
	at railo.runtime.type.UDFImpl._call(UDFImpl.java:371):371
	at railo.runtime.type.UDFImpl.call(UDFImpl.java:284):284
	at railo.runtime.type.scope.UndefinedImpl.call(UndefinedImpl.java:775):775
	at railo.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:723):723
	at railo.runtime.PageContextImpl.getFunction(PageContextImpl.java:1506):1506
	at scott.application_cfc$cf.udfCall(/var/www/scott/Application.cfc:44):44
	at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:103):103
	at railo.runtime.type.UDFImpl._call(UDFImpl.java:371):371
	at railo.runtime.type.UDFImpl.call(UDFImpl.java:284):284
	at railo.runtime.ComponentImpl._call(ComponentImpl.java:607):607
	at railo.runtime.ComponentImpl._call(ComponentImpl.java:490):490
	at railo.runtime.ComponentImpl.call(ComponentImpl.java:1781):1781
	at railo.runtime.listener.ModernAppListener.call(ModernAppListener.java:346):346
	at railo.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:107):107
	at railo.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:18):18
	at railo.runtime.PageContextImpl.execute(PageContextImpl.java:2255):2255
	at railo.runtime.PageContextImpl.execute(PageContextImpl.java:2222):2222
	at railo.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:315):315
	at railo.loader.servlet.CFMLServlet.service(CFMLServlet.java:29):29
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:728):728
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305):305
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210):210
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222):222
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123):123
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472):472
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171):171
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99):99
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118):118
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407):407
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004):1004
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589):589
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310):310
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source):-1
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source):-1
	at java.lang.Thread.run(Unknown Source):-1

Let’s see you application.cfc. It looks like maybe the this.datasource line is malformed or something. Also you created the datasource in your Ralio admin correct.

Curt

The datasource is ok because I use it in other pages with no problem…Applications.cfc is as follows (or at least the onRequestStart method:

<cfif findNoCase(‘index.cfm’, listLast(arguments.targetPage, ‘/’))>

<cfset reloadChecks()>

<cfset processColdBoxRequest()>

// Enable ORM this.ormEnabled = true; // ORM Datasource this.datasource = "career"; // ORM configuration settings this.ormSettings = { // Location of your entities, default is your convention model folder cfclocation = ["model"], // Choose if you want ORM to create the database for you or not? dbcreate = "none", // Log SQL logSQL = true, // Don't flush at end of requests, let Active Entity manage it for you flushAtRequestEnd = false, // Don't manage session, let Active Entity manage it for you autoManageSession = false, // Active ORM events eventHandling = true, // Use the ColdBox WireBox Handler for events eventHandler = "coldbox.system.orm.hibernate.WBEventHandler" }; ORMReload();

Why do you have the ORM settings in onRequeststart()?

Well, I guess because I hadn’t seen anywhere where not to put it there (or I missed it, a distinct possibility) I did have it outside the method, but it was balking on the ORMReload().

Where should the ORM settings be located in Application.cfc? Can someone point me to an example or docs?

Thx.

Hi ,

Here is adobe ColdFusion orm setting information
http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSED380324-6CBE-47cb-9E5E-26B66ACA9E81.html#WS2CED8D4C-8F3B-4f88-AEAA-D3F94F04964D

All of this kind of stuff

this.datasource = “datasourcename”;

// ORM SETTINGS
this.ormEnabled = true;
this.ormSettings = {
cfclocation=[“model”,“modules”],
dbcreate = “update”,
secondarycacheenabled = true,
cacheprovider = “ehCache”,
logSQL = true,
flushAtRequestEnd = false,
autoManageSession = false,
//savemapping = true,
eventHandling = true,
eventHandler = “model.EventHandler”,
skipCFCWithError = false
};

Need to be in the application.cfc “sudo” constructor. IE just under the start of the component outside of any function.

I usually add something like this in development in my onRequestStart.

// ORM Reload: REMOVE IN PRODUCTION IF NEEDED
if( structKeyExists(url,“ormReload”) ){ ormReload(); }

Curt

You should put it in the pseudoconstructor of Application.cfc (usually toward the top, outside of any functions). The ColdBox examples sites have examples of this: https://github.com/ColdBox/coldbox-samples/blob/master/applications/ormexample/Application.cfc

Re: the ORMReload(), I typically leave that in onRequestStart(), and wrap it in a check for a url variable so that I can reload on demand, as with fwreinit

Ya, pseudoconstructor – its early ok…. :slight_smile: And I just typed sudo :slight_smile:

Lol, sorry for duplicating your answer. I saw the notification pop up literally as I was hitting send :slight_smile:

Thanks Curt (et al) I just came in to tell everyone that I moved everything out of onRequestStart but left ORMReload() behind. It seems to work now. Had I really thought out, it is pretty obvious. I’ll chalk it up to a “long day”

Thanks,
Scott

Thanks Joel, see my response to Curt. I realized this all to late. Your response sparked me to think about it more.

Scott

Thanks all, it seems to be working now. I appreciate the help. Sana, thanks for the link to the Adobe docs.

Awesome, glad it’s working for you!

Ok, one more question…I swear.

I copied the example from http://wiki.coldbox.org/wiki/Models.cfm (under ORM) exactly because I was having some issues with mine. It works to list and save, however when I try delete I get “Application Execution Exception Error Type: java.lang.NumberFormatException : 0 Error Messages: For input string: “Contact”” and when I edit, it just creates a new record instead of updating the existing one. Any ideas? I know this is something relatively stupid, I’m just not seeing it.

Thanks again,
Scott