Using <cfthread> around runEvent(event) throws error

Hi everyone,

Need a bit of help with CF threads. I’m trying to run an intensive bit of code with cfthread on a coldbox view, so that the main thread loads up the rest of the page quickly and doesn’t get stuck up. My code looks something like this -

#runEvent(event)#

Note that the heavy-duty operation is invoked via runEvent.

I get the following error -

Application Execution ExceptionError Type: Expression : [N/A]

Error Messages: Unable to complete CFML to Java translation.
Error information unsupported statement: class coldfusion.compiler.ASTfunctionDefinition

Any pointers would be appreciated? Can we not use a thread around runevent?

Many thanks!

what happens when you put the cfthread around the actual code?

Try this:

cfthread action=“run” name=“xx” event=“#arguments.event#”{

runEvent( attributes.event )

}

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

Luis,

I used thread around the viewlet, like u advised. It gives me the same error.

thread action=“run” name=“t1” event=“myModule:myHandler.heavyDutyFunc”{
runEvent(attributes.event);
}

Error - " Unable to complete CFML to Java translation. Error information unsupported statement: class coldfusion.compiler.ASTfunctionDefinition "

Aaron,

If I use thread around the actual code in the handler, the piece of code doesn’t get rendered at all -

function heavyDutyFunc(){
// If function is called using runEvent, render out content as widget
if( arguments.widget ){
thread action=“run” name=“t1”
{
return renderView(“vwHeavyDutyOper”);
}
}
}

Pls note that its the rendering of view ‘vwHeavyDutyOper’ (as viewlet on another view) that takes a lot of time because of all the javascript and graphical rendering of results etc. Any help would be greatly appreciated.

Aaron,

Probably I’m missing something. I want to load a viewlet in my view which I do as follows -

  1. I first define a structure (which I want to pass to runEvents() method -
    eventStruct = {event=‘module:handler.function’,prepostExempt=true,eventArguments={widget=true,entityID=rc.entityID()}

  2. Then I invoke the runEvent() method in my view - using a thread -
    thread action=“run” name=“t1” event=eventStruct{

runEvent(attributes.event);
}

Please advise if this correct? Many thanks for your help.

Maybe this is something else. Are you in cf9, 10 or Railo?

Also, can you post the full stack trace

yes that works.

Aaron,

It didn’t work for me. Gave me the same error - "Unable to complete CFML to Java translation. Error information unsupported statement: class coldfusion.compiler.ASTfunctionDefinition "

Luis,

I’m using CF10. Threads have worked fine for me before, when I used them from my models or handlers. Here’s the full stacktrace when I try to use them with the runEvent() method -

Hello everyone

Any suggestions/ideas would be appreciated! :slight_smile:

I will try this today.

Can someone please check if they get the same error on invoking runEvent() using a thread? Many thanks!

Any chance it’s related to this ticket:

https://bugbase.adobe.com/index.cfm?event=bug&id=3516704

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

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

If that is your problem at least there is a work-around.

Brad,

Doesn’t look like it. I’m creating the structure before using it, as is shown in the workaround for the bug. I still get the same error.

eventStruct = {event=‘module:handler.myFunc’,prepostExempt=true,eventArguments={widget=true,entityID=3}};
thread action=“run” name=“t1” event=eventStruct{
runEvent(attributes.event);
}

I still get the error -
" Unable to complete CFML to Java translation. Error information unsupported statement: class coldfusion.compiler.ASTfunctionDefinition "

just out of curiosity are you using that code as an example, as I am sure the thread name has to be unique.

Yes, Andrew, that’s just an example. I generally use createUuid() while naming the threads. Otherwise, it does give ‘Threadname has to be unique’ error (or something similar), but not the error I’m getting right now. I’ve used threads successfully in the past, generally in my models and handlers. This is the first time I tried invoking it from a view (and wrapped around the runEvent() method) - and I get this weird ‘Unable to complete CFML to Java translation.’ error.

Yeah wasn’t sure as I was trying to find out whether that was the case, one thing that I was thinking about and only because it is not clear what line has the error, but have you thought about that it could be something within that handler or method. Have you tried a very basic no thrills method to compare?

This should be:

runEvent( argumentCollection=attributes.event );

Luis F. Majano
CEO
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com
Social: twitter.com/lmajano facebook.com/lmajano

Luis,

I tried that. Doesn’t work either and gives the same old error.

So, the following works fine when invoked in one of my views -
<cfset eventStruct = {event=‘module:handler.myFunc’,prepostExempt=true,eventArguments={widget=true,entityID=rc.entityID()}}>
#runEvent(argumentCollection=eventStruct)#

While this doesn’t -
<cfset eventStruct = {event=‘module:handler.myFunc’,prepostExempt=true,eventArguments={widget=true,entityID=rc.entityID}}>

#runEvent(argumentCollection=attributes.event)#

Andrew,

I just tried with a very basic handler for testing -

function myFunc(event,rc,prc){
return renderView(“testFile”);
}

where testFile.cfm contains just the following html -

Testing

I still get the same error.

Hi Parul Bali,

Please would you confirm which version of CF you are using?

I have seen something similar on CF 9.0.1

Thanks