KB Article #181227

Groovy Date Object Does Not Work in API Gateway 7.7 September 2020 Release

Problem

Groovy's Date objects no longer works in 7.7 September 2020 Release, though it worked previously. For example, the following script will fail:


import com.vordel.trace.Trace;

def invoke(msg) {
    Trace.debug(new Date().format("ddMMyyyy"));
    return true;
}


Causing an error similar to this:


ERROR   01/Oct/2020:00:00:00.000 [0000:000000000000000000000000] Filter that caused failure: Scripting Language
Policy 'Test' {
    Filter 'Scripting Language' Status:  ABORTED
}
nested fault: No signature of method: java.util.Date.format() is applicable for argument types: (String) values: [ddMMyy
yy]
Possible solutions: from(java.time.Instant), toYear(), getAt(java.lang.String), parse(java.lang.String), print(java.io.P
rintWriter), print(java.lang.Object)
java.lang.NoSuchMethodException: No signature of method: java.util.Date.format() is applicable for argument types: (Stri
ng) values: [ddMMyyyy]
Possible solutions: from(java.time.Instant), toYear(), getAt(java.lang.String), parse(java.lang.String), print(java.io.P
rintWriter), print(java.lang.Object)
        at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.invokeImpl(GroovyScriptEngineImpl.java:360)
        at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.invokeFunction(GroovyScriptEngineImpl.java:194)
        at com.vordel.circuit.script.ScriptProcessor.invoke(ScriptProcessor.java:48)
        at com.vordel.circuit.InvocationEngine.invokeFilter(InvocationEngine.java:149)
        at com.vordel.circuit.InvocationEngine.invokeCircuit(InvocationEngine.java:41)
        at com.vordel.circuit.InvocationEngine.recordCircuitInvocation(InvocationEngine.java:279)
        at com.vordel.circuit.InvocationEngine.processMessage(InvocationEngine.java:241)
        at com.vordel.circuit.SyntheticCircuitChainProcessor.invoke(SyntheticCircuitChainProcessor.java:65)
        at com.vordel.dwe.http.HTTPPlugin.processRequest(HTTPPlugin.java:417)
        at com.vordel.dwe.http.HTTPPlugin.invokeDispose(HTTPPlugin.java:443)
        at com.vordel.dwe.http.HTTPPlugin.invoke(HTTPPlugin.java:135)


Resolution

The methods for java.util.Date are now in the groovy-dateutil module, which isn’t included by default. Accordingly, you can fix this problem by copying the groovy-dateutil JAR from the Groovy Maven repository into /apigateway/ext/lib and restarting the affected instances.

Issue will be fixed in November 2020 release.