The below datadog-related code is throwing an exception on Lucee.
It runs okay on CF2018 (we’ve been using it on production for years).
<cfcomponent name="datadog" displayname="Datadog Utility"><cfprocessingdirective pageEncoding="utf-8">
<cffunction name="Init" output="false" returntype="any">
<cfset this.javaOtelAttributeKey = createObject("java", "io.opentelemetry.api.common.AttributeKey")>
<cfset this.javaOtelSpan = createObject("java", "io.opentelemetry.api.trace.Span")>
<cfset this.javaStringClass = createObject("java", "java.lang.String").getClass()>
<cfreturn this>
</cffunction>
<cffunction name="getCurrentSpan">
<cfreturn this.javaOtelSpan.getClass().getMethod("current", javaCast("null", "")).invoke(javaCast("null", ""), javaCast("null", ""))>
</cffunction>
<cffunction name="setAttributeString">
<cfargument name="key" type="string" required="true">
<cfargument name="value" type="string" required="true">
<cfset LOCAL.span = this.getCurrentSpan()>
<cfset LOCAL.attributeKey = this.javaOtelAttributeKey.getClass().getMethod("stringKey", [this.javaStringClass]).invoke(javaCast("null", ""), [ARGUMENTS.key])>
<cfset LOCAL.span.setAttribute( LOCAL.attributeKey, javaCast("string", ARGUMENTS.value) )>
</cffunction>
</cfcomponent>
From what I recall, we’re using reflection to work around ambiguous function calls / it doesn’t work without using getMethod and invoke, on CF2018 at least.
Anyway, the Lucee bug (?) is, the setAttribute call is throwing the below:
lucee.runtime.exp.NativeException: unable to load class path [datadog
/opentelemetry/shim/trace/OtelSpan.class] at lucee.transformer.dynamic.
meta.dynamic.ClazzDynamic._getFunctionMembers(ClazzDynamic.java:514)
at lucee.transformer.dynamic.meta.dynamic.ClazzDynamic.
getFunctionMembers(ClazzDynamic.java:487) at lucee.transformer.dynamic.
meta.dynamic.ClazzDynamic.(ClazzDynamic.java:131) at lucee.
transformer.dynamic.meta.dynamic.ClazzDynamic.getInstance
(ClazzDynamic.java:88) at lucee.transformer.dynamic.DynamicInvoker.
toClazzDynamic(DynamicInvoker.java:165) at lucee.runtime.reflection.pairs.
MethodInstance.invoke(MethodInstance.java:94) at lucee.runtime.util.
VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:
824) at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:
2075) at cfcs.utility.datadog_cfc$cf.udfCall(/cfcs/utility/datadog.cfc:27)
Any ideas?
Note, we have these JVM args set for both CF2018 and Lucee, setenv.sh:
-javaagent:/cfcustom/jars/dd-java-agent-1.49.0.jar -Ddd.trace.otel.enabled=true
Also, in ApplicationProxy.cfc we have:
<cfset this.javaSettings = { loadPaths = ["/cfcustom/jars/"] }>
These are in /cfcustom/jars, same jars for both CF2018 and Lucee:
- dd-java-agent-1.49.0.jar
- opentelemetry-api-1.50.0.jar
- opentelemetry-context-1.50.0.jar
OS: Linux amd64 5.10.236-228.935.amzn2.x86_64
Java Version: 21.0.7 Eclipse Adoptium
Tomcat Version: Apache Tomcat/11.0.7
Lucee Version: 6.2.2.27-SNAPSHOT-light (docker)
EDIT: This can also be reproduced simply using the below, cfdump throws the same exception:
<cfdump var="#createObject("java", "io.opentelemetry.api.trace.Span").current()#" abort>
Though with that said, I can’t reproduce it using a minimal test . Maybe the issue is specific to certain means of importing jars?