java.lang.ClassNotFoundException: org.apache.logging.log4j.LogManager.getLogger:

Java 11.0.14 with Camunda 7.16.0

We are using wildfly-23.0.2.Final and path of the camunda modules are in this folder. \wildfly-23.0.2.Final\modules\org\camunda

Created workflow with start node->script Task-end node.
In script node I have added below code.

var log=org.apache.logging.log4j.LogManager.getLogger(“motive.utilities.javascript.JavaScriptLogger”);
log.debug(“Test Log”);

When I run BPFlow getting below error.

2022-06-21 10:59:38,464 ERROR [stderr] (pool-9-thread-4) Warning: Nashorn engine is planned to be removed from a future JDK release
2022-06-21 10:59:38,492 ERROR [org.camunda.bpm.engine.context] (pool-9-thread-4) ENGINE-16004 Exception while closing command context: java.lang.ClassNotFoundException: org.apache.logging.log4j.LogManager.getLogger: java.lang.RuntimeException: java.lang.ClassNotFoundException: org.apache.logging.log4j.LogManager.getLogger
at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:531)
at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:456)
at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:413)
at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:409)
at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:162)
at java.scripting/javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:233)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.scripting.SourceExecutableScript.evaluateScript(SourceExecutableScript.java:125)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.scripting.SourceExecutableScript.evaluate(SourceExecutableScript.java:65)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.scripting.ExecutableScript.execute(ExecutableScript.java:63)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.scripting.env.ScriptingEnvironment.execute(ScriptingEnvironment.java:99)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.scripting.env.ScriptingEnvironment.execute(ScriptingEnvironment.java:87)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.delegate.ScriptInvocation.invoke(ScriptInvocation.java:47)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.delegate.DelegateInvocation.proceed(DelegateInvocation.java:58)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocationInContext(DefaultDelegateInterceptor.java:92)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocation(DefaultDelegateInterceptor.java:63)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.bpmn.behavior.ScriptTaskActivityBehavior$1.call(ScriptTaskActivityBehavior.java:55)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.bpmn.behavior.ScriptTaskActivityBehavior$1.call(ScriptTaskActivityBehavior.java:51)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior.executeWithErrorPropagation(AbstractBpmnActivityBehavior.java:90)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.bpmn.behavior.ScriptTaskActivityBehavior.performExecution(ScriptTaskActivityBehavior.java:51)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.bpmn.behavior.TaskActivityBehavior.execute(TaskActivityBehavior.java:69)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityExecute$2.callback(PvmAtomicOperationActivityExecute.java:61)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityExecute$2.callback(PvmAtomicOperationActivityExecute.java:50)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl.continueIfExecutionDoesNotAffectNextOperation(PvmExecutionImpl.java:2039)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityExecute.execute(PvmAtomicOperationActivityExecute.java:42)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityExecute.execute(PvmAtomicOperationActivityExecute.java:31)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.interceptor.AtomicOperationInvocation.execute(AtomicOperationInvocation.java:99)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.invokeNext(CommandInvocationContext.java:131)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performNext(CommandInvocationContext.java:111)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:86)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:634)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:608)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl$6.callback(PvmExecutionImpl.java:1978)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl$6.callback(PvmExecutionImpl.java:1975)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl.continueExecutionIfNotCanceled(PvmExecutionImpl.java:2045)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl.dispatchDelayedEventsAndPerformOperation(PvmExecutionImpl.java:1994)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl.dispatchDelayedEventsAndPerformOperation(PvmExecutionImpl.java:1975)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationTransitionNotifyListenerStart.eventNotificationsCompleted(PvmAtomicOperationTransitionNotifyListenerStart.java:60)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationTransitionNotifyListenerStart.eventNotificationsCompleted(PvmAtomicOperationTransitionNotifyListenerStart.java:30)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.core.operation.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:66)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.interceptor.AtomicOperationInvocation.execute(AtomicOperationInvocation.java:99)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.invokeNext(CommandInvocationContext.java:131)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performNext(CommandInvocationContext.java:111)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:86)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:76)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:643)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:618)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.core.operation.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:62)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.interceptor.AtomicOperationInvocation.execute(AtomicOperationInvocation.java:99)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.invokeNext(CommandInvocationContext.java:131)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performNext(CommandInvocationContext.java:111)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:86)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:76)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:643)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:618)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.core.operation.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:62)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.interceptor.AtomicOperationInvocation.execute(AtomicOperationInvocation.java:99)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.invokeNext(CommandInvocationContext.java:131)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performNext(CommandInvocationContext.java:111)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:86)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:634)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:608)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationTransitionCreateScope.scopeCreated(PvmAtomicOperationTransitionCreateScope.java:38)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationCreateScope.execute(PvmAtomicOperationCreateScope.java:54)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationCreateScope.execute(PvmAtomicOperationCreateScope.java:28)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.interceptor.AtomicOperationInvocation.execute(AtomicOperationInvocation.java:99)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.invokeNext(CommandInvocationContext.java:131)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performNext(CommandInvocationContext.java:118)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:86)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:76)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.jobexecutor.AsyncContinuationJobHandler.execute(AsyncContinuationJobHandler.java:81)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.jobexecutor.AsyncContinuationJobHandler.execute(AsyncContinuationJobHandler.java:40)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.persistence.entity.JobEntity.execute(JobEntity.java:134)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.cmd.ExecuteJobsCmd.execute(ExecuteJobsCmd.java:110)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.cmd.ExecuteJobsCmd.execute(ExecuteJobsCmd.java:43)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:28)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:110)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.interceptor.JtaTransactionInterceptor.execute(JtaTransactionInterceptor.java:67)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:70)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.interceptor.CommandCounterInterceptor.execute(CommandCounterInterceptor.java:35)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobHelper.executeJob(ExecuteJobHelper.java:57)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobsRunnable.executeJob(ExecuteJobsRunnable.java:110)
at org.camunda.bpm.camunda-engine@7.16.0//org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobsRunnable.run(ExecuteJobsRunnable.java:71)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.SimpleDirectExecutor.execute(SimpleDirectExecutor.java:29)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.QueueExecutor.runTask(QueueExecutor.java:789)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.QueueExecutor.access$100(QueueExecutor.java:44)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.QueueExecutor$Worker.run(QueueExecutor.java:809)
at java.base/java.lang.Thread.run(Thread.java:834)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.JBossThread.run(JBossThread.java:513)
Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.LogManager.getLogger
at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.NativeJavaPackage.classNotFound(NativeJavaPackage.java:163)
at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$5$^eval_/0x00000179dd2129e0.:program(:1)
at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:655)
at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:513)
at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:527)
… 88 more

Could you please us how to fix this. We have all the required camunda jars in our classpath.

I tested this with Camunda 7.18.0-alpha2, Wildfly 26.0.1, Java 8.
It works for me.
The log statement appears in server.log:
21.06. 14:23:00,509 DEBUG [motive.utilities.javascript.JavaScriptLogger#invokeHandle] Test Log

My script task is:

<bpmn:scriptTask id="Activity_111syw4" name="Test Script Logger" scriptFormat="javascript">
  <bpmn:incoming>SequenceFlow_10ou0ag</bpmn:incoming>
  <bpmn:outgoing>Flow_14iivlx</bpmn:outgoing>
  <bpmn:script>
var log=org.apache.logging.log4j.LogManager.getLogger("motive.utilities.javascript.JavaScriptLogger");
log.debug("Test Log");
  </bpmn:script>
</bpmn:scriptTask>

Can you upload your bpmn file here ?

Weird is the error message you get:
java.lang.ClassNotFoundException: org.apache.logging.log4j.LogManager.getLogger
The class name is simply org.apache.logging.log4j.LogManager, getLogger is the method name.

Thx @langfr .
This is working fine for Java 8. Issue is with Java 11.