This message is part question and part sharing to help anyone else who
may encounter this.
I've spent more than a day fighting with a Stack Overflow error in a
new ColdBox - ColdFusion 9 Application. I am using the Auto-wire
dependency injection system native to ColdBox. I finally identified
the area of concern and have resolved issue; however, I am still not
exactly sure why this happened, and, have a little concern it could
pop up.
This is the code that directly caused the Stack Overflow Error.
<!---
var languages = [];
var lanuage = '';
var i = 0 ;
var n = arguments.qry.recordCount;
for (i=1; i<= n; i++) {
arrayAppend(languages, dependency.BeanFactory.getModel('Language'));
Following, please find the full stack trace. The last CFC shifts between the InterceptorState and BeanFactory.
To clarify, I am using ColdBox’s DI solution exclusively. ColdSpring is not involved.
coldfusion.runtime.EventHandlerException: Event handler exception.
at coldfusion.runtime.AppEventInvoker.onRequestStart(AppEventInvoker.java:266)
at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:331)
at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48)
at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40)
at coldfusion.filter.PathFilter.invoke(PathFilter.java:87)
at coldfusion.filter.LicenseFilter.invoke(LicenseFilter.java:27)
at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70)
at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)
at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46)
at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)
at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
at coldfusion.filter.CachingFilter.invoke(CachingFilter.java:53)
at coldfusion.CfmServlet.service(CfmServlet.java:200)
at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89)
at jrun.servlet.FilterChain.doFilter(FilterChain.java:86)
at com.intergral.fusionreactor.filter.FusionReactorFilter.b(FusionReactorFilter.java:376)
at com.intergral.fusionreactor.filter.FusionReactorFilter.c(FusionReactorFilter.java:254)
at com.intergral.fusionreactor.filter.FusionReactorFilter.doFilter(FusionReactorFilter.java:164)
at jrun.servlet.FilterChain.doFilter(FilterChain.java:94)
at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42)
at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46)
at jrun.servlet.FilterChain.doFilter(FilterChain.java:94)
at jrun.servlet.FilterChain.service(FilterChain.java:101)
at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106)
at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:286)
at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543)
at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203)
at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320)
at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)
at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266)
at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
Caused by: java.lang.StackOverflowError
at coldfusion.tagext.lang.InvokeTag.doEndTag(InvokeTag.java:475)
at cfInterceptorState2ecfc906489402$funcINVOKER.runFunction(C:\inetpub\wwwroot\coldbox\system\beans\InterceptorState.cfc:127)
at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:472)
at coldfusion.filter.SilentFilter.invoke(SilentFilter.java:47)
at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:405)
at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:368)
at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:55)
at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:321)
at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:220)
at coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:2582)
at cfInterceptorState2ecfc906489402$funcPROCESS.runFunction(C:\inetpub\wwwroot\coldbox\system\beans\InterceptorState.cfc:80)
at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:472)
at coldfusion.filter.SilentFilter.invoke(SilentFilter.java:47)
at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:405)
at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:368)
at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:55)
at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:321)
at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:220)
at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:490)
at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:336)
at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2360)
at cfInterceptorService2ecfc327319666$funcPROCESSSTATE.runFunction(C:\inetpub\wwwroot\coldbox\system\services\InterceptorService.cfc:98)
at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:472)
at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:405)
at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:368)
at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:55)
at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:321)
at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:220)
at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:490)
at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:336)
at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2360)
at cfColdbox2ecfc255186317$funcPROCESSCOLDBOXREQUEST.runFunction(C:\inetpub\wwwroot\coldbox\system\Coldbox.cfc:195)
at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:472)
at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:405)
at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:368)
at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:55)
at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:321)
at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:220)
at coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:2582)
at cfApplication2ecfc2122324858$funcONREQUESTSTART.runFunction(C:\inetpub\wwwroot\htdocs\cmscb\Application.cfc:55)
at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:472)
at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:405)
at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:368)
at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:55)
at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:321)
at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:220)
at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:490)
at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:336)
at coldfusion.runtime.AppEventInvoker.invoke(AppEventInvoker.java:88)
at coldfusion.runtime.AppEventInvoker.onRequestStart(AppEventInvoker.java:258)
... 32 more
There is a Request.cfc Interceptor which reads a setting from the ColdBox Config and constructs any objects required to fullful a basic request (currently: Site, User). This issue is triggered by User.
The user is first Constructed to be a ‘New User’ and then, if the proper conditions exist, the Request.cfc Interceptor will ask the User to self-populate. When I first had this issue. Here is the Populate() method within User.
/** Populate the User from the database. @property Define the criteria to use. Accepts ‘login’ and any valid User property. Example : ‘user_id’ or ‘email’. */ public boolean function populate (string property=‘User_ID’) { arguments.User = this; if (UserDAO.populate(argumentCollection=arguments)) variables.populated = true; else variables.populated = false; return variables.populated; }
And, here is a condensed version of UserDAO’s populate method:
SELECT XXXX
The populateUserLanguage() method is where I finally found a resolution. By rewriting the method as I previously posted, the error goes away. I also rewrote this behavior and placed the burden of creating/populating these language objects in a few other places and always received the same stack overflow error.
I now have more information about this error. Seems, the bean is the
cause.
If the INIT method of the Language object has arguments defined, the
stack error occurs. If I remove the arguments from the constructor, it
works as expected.
I also defaulted every argument and still got the error. Here is the
BAD code... any thoughts?
/** Constructor. Languages should allways be populated during
construction or just after.
The default language is 'ENGLISH' */
public function init () {
// Construct the language using arguments.
setLID(arguments.lid);
setLanguage(arguments.language);
setLanguage_Short(arguments.Language_Short);
setLanguage_Medium(arguments.Language_Medium);
setAkamai_Directory(arguments.Akamai_Directory);
setISO_Code(arguments.ISO_Code);
setIs_System_Language(arguments.is_system_language);
return this;
}
/** Facade Method for getIs_System_Langauge. Used to keep API
consistent. */
public boolean function isSystemLanguage() {
return getIs_System_Language();
}
}