Runnable Task - java.lang.NoClassDefFoundError


#1

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!


Running a thread inside a thread in Lucee 4
#2

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…


#3

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


#4

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


#5

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


#6

It’s very helped me.