[Coldbox 4.3.0] Cannot variable dsn, the inject datasource

68 views
Skip to first unread message

Jiamin

unread,
Sep 3, 2017, 10:51:29 PM9/3/17
to ColdBox Platform
Hi, I am trying to create a simple project to retrieve all the data in a db table using dao.
The structure is +models
                             admin.cfc
                             adminDAO.cfc
                             adminService.cfc
In the adminDAO.cfc, "property name="dsn" inject="coldbox:datasource:test";"
One of the function is getAll(), there is a query to select all from the admin table
In the coldbox.cfc, datasources={
                             test={
                                 name="test",
                                 dbtype="mySQL"
                              }
                };
However, when I run the app, it shows
(I wonder what is wrong ?) Thank you very much
variable [DSN] doesn't exist
    at lucee.runtime.type.scope.UndefinedImpl.getCollection(UndefinedImpl.java:404):404
    at models.admindao_cfc$cf.udfCall(/models/adminDAO.cfc:18):18
    at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111
    at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328
    at lucee.runtime.type.UDFImpl.call(UDFImpl.java:229):229
    at lucee.runtime.ComponentImpl._call(ComponentImpl.java:642):642
    at lucee.runtime.ComponentImpl._call(ComponentImpl.java:524):524
    at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1761):1761
    at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:743):743
    at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1599):1599
    at models.adminservice_cfc$cf.udfCall(/models/adminService.cfc:21):21
    at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111
    at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328
    at lucee.runtime.type.UDFImpl.call(UDFImpl.java:229):229
    at lucee.runtime.ComponentImpl._call(ComponentImpl.java:642):642
    at lucee.runtime.ComponentImpl._call(ComponentImpl.java:524):524
    at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1761):1761
    at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:743):743
    at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1599):1599
    at handlers.basic_cfc$cf.udfCall(/handlers/basic.cfc:8):8
    at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111
    at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328
    at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:216):216
    at lucee.runtime.type.scope.UndefinedImpl.callWithNamedValues(UndefinedImpl.java:775):775
    at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:774):774
    at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1609):1609
    at coldbox.system.eventhandler_cfc$cf.udfCall(/coldbox/system/EventHandler.cfc:85):85
    at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111
    at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328
    at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:216):216
    at lucee.runtime.ComponentImpl._call(ComponentImpl.java:643):643
    at lucee.runtime.ComponentImpl._call(ComponentImpl.java:524):524
    at lucee.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1778):1778
    at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:774):774
    at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1609):1609
    at coldbox.system.web.controller_cfc$cf.udfCall3(/coldbox/system/web/Controller.cfc:795):795
    at coldbox.system.web.controller_cfc$cf.udfCall(/coldbox/system/web/Controller.cfc):-1
    at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111
    at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328
    at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:216):216
    at lucee.runtime.type.scope.UndefinedImpl.callWithNamedValues(UndefinedImpl.java:775):775
    at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:774):774
    at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1609):1609
    at coldbox.system.web.controller_cfc$cf.udfCall2(/coldbox/system/web/Controller.cfc:633):633
    at coldbox.system.web.controller_cfc$cf.udfCall(/coldbox/system/web/Controller.cfc):-1
    at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111
    at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328
    at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:216):216
    at lucee.runtime.type.scope.UndefinedImpl.callWithNamedValues(UndefinedImpl.java:775):775
    at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:774):774
    at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1609):1609
    at coldbox.system.web.controller_cfc$cf.udfCall2(/coldbox/system/web/Controller.cfc:425):425
    at coldbox.system.web.controller_cfc$cf.udfCall(/coldbox/system/web/Controller.cfc):-1
    at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111
    at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328
    at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:216):216
    at lucee.runtime.ComponentImpl._call(ComponentImpl.java:643):643
    at lucee.runtime.ComponentImpl._call(ComponentImpl.java:524):524
    at lucee.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1778):1778
    at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:774):774
    at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1609):1609
    at coldbox.system.bootstrap_cfc$cf.udfCall1(/coldbox/system/Bootstrap.cfc:200):200
    at coldbox.system.bootstrap_cfc$cf.udfCall(/coldbox/system/Bootstrap.cfc):-1
    at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111
    at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328
    at lucee.runtime.type.UDFImpl.call(UDFImpl.java:229):229
    at lucee.runtime.type.scope.UndefinedImpl.call(UndefinedImpl.java:766):766
    at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:743):743
    at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1599):1599
    at coldbox.system.bootstrap_cfc$cf.udfCall1(/coldbox/system/Bootstrap.cfc:360):360
    at coldbox.system.bootstrap_cfc$cf.udfCall(/coldbox/system/Bootstrap.cfc):-1
    at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111
    at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328
    at lucee.runtime.type.UDFImpl.call(UDFImpl.java:229):229
    at lucee.runtime.ComponentImpl._call(ComponentImpl.java:642):642
    at lucee.runtime.ComponentImpl._call(ComponentImpl.java:524):524
    at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1761):1761
    at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:743):743
    at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1599):1599
    at application_cfc$cf.udfCall(/Application.cfc:44):44
    at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:111):111
    at lucee.runtime.type.UDFImpl._call(UDFImpl.java:328):328
    at lucee.runtime.type.UDFImpl.call(UDFImpl.java:229):229
    at lucee.runtime.ComponentImpl._call(ComponentImpl.java:642):642
    at lucee.runtime.ComponentImpl._call(ComponentImpl.java:524):524
    at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1761):1761
    at lucee.runtime.listener.ModernAppListener.call(ModernAppListener.java:414):414
    at lucee.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:133):133
    at lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:37):37
    at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2271):2271
    at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2234):2234
    at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:456):456
    at lucee.loader.servlet.CFMLServlet.service(CFMLServlet.java:47):47
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790):790
    at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85):85
    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129):129
    at org.cfmlprojects.regexpathinfofilter.RegexPathInfoFilter.doFilter(RegexPathInfoFilter.java:47):47
    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61):61
    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131):131
    at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84):84
    at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62):62
    at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36):36
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43):43
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43):43
    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:274):274
    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchToPath(ServletInitialHandler.java:209):209
    at io.undertow.servlet.spec.RequestDispatcherImpl.forwardImpl(RequestDispatcherImpl.java:221):221
    at io.undertow.servlet.spec.RequestDispatcherImpl.forwardImplSetup(RequestDispatcherImpl.java:147):147
    at io.undertow.servlet.spec.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:111):111
    at org.cfmlprojects.regexpathinfofilter.RegexPathInfoFilter.doFilter(RegexPathInfoFilter.java:45):45
    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61):61
    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131):131
    at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84):84
    at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62):62
    at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36):36
    at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131):131
    at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57):57
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43):43
    at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46):46
    at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64):64
    at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60):60
    at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77):77
    at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43):43
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43):43
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43):43
    at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292):292
    at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81):81
    at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138):138
    at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135):135
    at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48):48
    at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43):43
    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272):272
    at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81):81
    at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104):104
    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:211):211
    at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:809):809
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142):1142
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617):617
    at java.lang.Thread.run(Thread.java:745):745

Ancient Programmer

unread,
Sep 5, 2017, 11:17:42 AM9/5/17
to ColdBox Platform
It looks correct to me. Try to reinit the framework, fwreinit=1

br...@bradwood.com

unread,
Sep 5, 2017, 1:31:28 PM9/5/17
to col...@googlegroups.com
variable [DSN] doesn't exist
 
That error means the injection isn't taking place OR you're trying to use the injected variable too soon.  Do a reinit first since ColdBox/WireBox caches CFC metadata and then ensure you're not using it in the init() method.  If you need to use it when the CFC is created, use the onDIComplete() method.

Thanks!

~Brad

ColdBox/CommandBox Developer Advocate
Ortus Solutions, Corp

E-mail: br...@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com 
 
 
--------- Original Message ---------
--
--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org
For Bug Reports, visit https://ortussolutions.atlassian.net/browse/COLDBOX
---
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coldbox+u...@googlegroups.com.
To post to this group, send email to col...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/coldbox/5f685100-d3fd-40c5-9188-872b29562d09%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

echo

unread,
Sep 5, 2017, 11:16:27 PM9/5/17
to ColdBox Platform
Thanks for your reply. I managed to make it work by adding username and password to the datasource in the coldbox.cfc. Initially, I thought since I already register it to the server admin, I do not need to do that. 
However, other error occurs:
at first, it shows error msg like [host] key does not exist, [type] key does not exist.(I have dbType attribute)
I tried to add those keys to the datasource in the coldbox.cfc as well. 
then, the error msg becomes
Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
I thought datasource won't need such setting like host or type. Is there something wrong?
Thanks!

echo

unread,
Sep 5, 2017, 11:25:17 PM9/5/17
to ColdBox Platform
Also, I add the onDIComplete and dump and dsn. The datasource struct shows


On Wednesday, 6 September 2017 01:31:28 UTC+8, Brad Wood wrote:
Reply all
Reply to author
Forward
0 new messages