RE: [coldbox:18240] Using cfthread and wirebox

50 views
Skip to first unread message

br...@bradwood.com

unread,
May 1, 2013, 5:23:07 PM5/1/13
to col...@googlegroups.com
At first glance, is this a mapping issue?  Do you have a mapping for "com" or is it in the web root?  It's possible the thread is running out of the web context and doesn't know where the web root is.  I'm curious if an app mapping or server mapping would help ColdFusion find the components.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

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


-------- Original Message --------
Subject: [coldbox:18240] Using cfthread and wirebox
From: Brian Love <bl...@webucator.com>
Date: Wed, May 01, 2013 4:15 pm
To: col...@googlegroups.com

I have a scheduled task service component that is using threading to send out emails.  I am attempting to create a new instance of an object using wirebox, which works fine outside of the thread, but doesn't work inside the thread.  Any ideas?  This might be more of a question about threading that wirebox, but I thought this would be a good place to ask.  :)

component extends="com.acuity.services.tasks.LastDayOfMonthScheduledTask" accessors="true" singleton {

  property
type="com.acuity.config.datasources.AcuityDatasource" name="acuityDatasource" inject="id:com.acuity.config.datasources.AcuityDatasource";
  property type="com.acuity.utils.AmazonSESUtil" name="amazonSESUtil" inject="id:com.acuity.utils.AmazonSESUtil";
  property type="com.acuity.emails.EmailFactory" name="emailFactory" inject="id:com.acuity.emails.EmailFactory";

 
public
void function run() IsExecuting output="false" {
  //execute batches in threads
    for (var i=1; i<=batches; i++) {
        thread action="run" name="#getName()##i#" i=i limit=limit {
            try {
               //this line below will not work when inside the thread execution context
               var
email = application.wirebox.getInstance("com.acuity.emails.emails.tasks.NewsletterEmail");
               
               getLoggerService().debug("#getName()# new thread spawned: #getName()#-#i#");
 
               
// email sending logic is here
           }
           catch (any exception) {
               getLoggerService().error(message="Error sending monthly newsletter.", exception=exception);
           }
        }
  }
}

When the call to getInstance is executed in the above code, an exception occurs stating that the instance cannot be found.  I have tried to replace the getInstance() with a standard createObject() function, and I am getting the same error.  Is this due to a limitation of threads in ColdFusion?

The logging is below that indicates the exception.

"Error","cfthread-2","05/01/13","17:05:00","WORDSKILL","Error sending monthly newsletter. EXCEPTION: Requested instance not found: 'com.acuity.emails.emails.tasks.NewsletterEmail' EXCEPTION DETAIL: The instance could not be located in any declared scan location(s) (com.acuity) or full path location  STACKTRACE: coldfusion.runtime.CustomException: Requested instance not found: 'com.acuity.emails.emails.tasks.NewsletterEmail' at coldfusion.tagext.lang.ThrowTag.doStartTag(ThrowTag.java:142) at coldfusion.runtime.CfJspPage._emptyTcfTag(CfJspPage.java:2722) at cfUtil2ecfc225637256$funcTHROWIT.runFunction(/www/local.word-skill.com/www/org/coldbox/wirebox/system/core/util/Util.cfc:164) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:472) at coldfusion.filter.SilentFilter.invoke(SilentFilter.java:47) 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:517) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:496) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:355) at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2301) at cfInjector2ecfc1259791438$funcGETINSTANCE.runFunction(/www/local.word-skill.com/www/org/coldbox/wirebox/system/ioc/Injector.cfc:236) 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:491) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:337) at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2360) at cfNewsletterTask2ecfc1759022024$func_CFFUNCCFTHREAD_CFNEWSLETTERTASK2ECFC17590220241.runFunction(/www/local.word-skill.com/www/com/acuity/services/tasks/tasks/NewsletterTask.cfc:69) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:472) 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.UDFMethod.invokeCFThread(UDFMethod.java:201) at coldfusion.thread.Task.invokeFunction(Task.java:274) at coldfusion.thread.Task.run(Task.java:140) at coldfusion.scheduling.ThreadPool.run(ThreadPool.java:201) at coldfusion.scheduling.WorkerThread.run(WorkerThread.java:71) "
--
--
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.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply all
Reply to author
Forward
0 new messages