Runnable Task - java.lang.NoClassDefFoundError

Hi,
i want to create a task, which running in the background, till someone
stops it.

I found a “demo” at a rabbitmq consumer:

The demo works, but when i try to write my own Task, i cant start it.

(java.lang.NoClassDefFoundError)

I hope someone can help me…

Error:

https://lh3.googleusercontent.com/-tVvUgfSkzkk/WKbS13tgO-I/AAAAAAAAC5I/FUl8NOOSbHE10IbUBM3ziPx-JBkoTaazwCLcB/s1600/Error.jpg

Start.cfm

<cfscript>

application.stoptasks = false;
//Create Task
myTask = createDynamicProxy(new MyTask(), [ "java.lang.Runnable" ]);
// Create a new start for consuming
    thread = createObject( "java", "java.lang.Thread" 
).init(myTask).start();
WriteOutput("Started...");
</cfscript>.

MyTask.cfc

component accessors="true"{

  property name = "id";

  function init(){
    variables.id = left( createUUID(), 3);
    variables.app = application;
    return this;
  }

  function run(){
    while(!variables.app.stopTasks){
      WriteOutput("Test Output");
      Sleep(1000);
    }
  }

}

I dont know why this happens…

Thank you!

I found the issue…
Simply add javaSettings in your application.cfc.

this.javaSettings = { loadPaths = ["/task/lib"] }; 

This works, but i dont know why i have to define the javaSettings
Path…The lib-folder is empty and it makes not sense…

2 Likes

Why on earth does this stupid fix work? Did you raise an issue on JIRA?

@lmajano Have you ever run into the behavior described in this thread?

@bdw429s @David_Raschper @kliakos
Works for me, too. But it should not be necessary, shouldn’t it?

It’s very helped me.