ESAPI error after update

OS: Win10
Java Version: 11.0.15 (Eclipse Adoptium) 64bit
Tomcat Version: 9.0.62
Lucee Version:

Just updated (via the admin) a local dev Tomcat install to and immediately got an error with this simple line of code:

dump( EncodeForHtml( "test" ) )

java.lang.reflect.InvocationTargetException Encoder class (org.owasp.esapi.reference.DefaultEncoder) CTOR threw exception.

Stack trace

lucee.runtime.exp.NativeException: java.lang.reflect.InvocationTargetException Encoder class (org.owasp.esapi.reference.DefaultEncoder) CTOR threw exception.
 	at org.owasp.esapi.util.ObjFactory.make(
 	at org.owasp.esapi.ESAPI.encoder(
 	at org.lucee.extension.esapi.functions.ESAPIEncode.encode(
 	at org.lucee.extension.esapi.functions.ESAPIEncode.encode(
 	at org.lucee.extension.esapi.functions.EncodeForHTML.invoke(
 	at lucee.runtime.functions.FunctionHandlerPool.invoke(
 	at index_cfm$
Caused by: org.owasp.esapi.errors.ConfigurationException: java.lang.reflect.InvocationTargetException Encoder class (org.owasp.esapi.reference.DefaultEncoder) CTOR threw exception.
 	... 43 more
 Caused by: java.lang.reflect.InvocationTargetException
 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(
 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(
 	at java.base/java.lang.reflect.Method.invoke(
 	at org.owasp.esapi.util.ObjFactory.make(
 	... 42 more
 Caused by: org.owasp.esapi.errors.ConfigurationException: java.lang.ClassNotFoundException: org.lucee.extension.esapi.log.LogFactoryImpl not found by org.lucee.esapi [62] LogFactory class (org.lucee.extension.esapi.log.LogFactoryImpl) must be in class path.
 	at org.owasp.esapi.util.ObjFactory.make(
 	at org.owasp.esapi.ESAPI.logFactory(
 	at org.owasp.esapi.ESAPI.getLogger(
 	at org.owasp.esapi.reference.DefaultEncoder.<init>(
 	at org.owasp.esapi.reference.DefaultEncoder.getInstance(
 	... 47 more
 Caused by: java.lang.ClassNotFoundException: org.lucee.extension.esapi.log.LogFactoryImpl not found by org.lucee.esapi [62]
 	at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(
 	at org.apache.felix.framework.BundleWiringImpl.access$300(
 	at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(
 	at java.base/java.lang.ClassLoader.loadClass(
 	at java.base/java.lang.Class.forName0(Native Method)
 	at java.base/java.lang.Class.forName(
 	at org.owasp.esapi.util.ObjFactory.make(
 	... 51 more

This trace seems to be identical to the one reported by Dave Stanley a few days ago in the comments of this ticket:

But unlike him downgrading the ESAPI extension from version to the previous version fixed it for me.

However, spinning up a command box server running and ESAPI the code runs just fine! So this must be some kind of edge case. Anyone else seen it?

1 Like

Tried updating the lucee loader jar to the latest but that hasn’t helped. Only downgrading the ESAPI extension works for now.

We encounter the same issue. No matter what string we provide, encodeForHTML() causes the same error as mentioned above. We’ll try downgrading ESAPI now.

What’s interesting is I received the COTR error a few times recently, but on 5.3.8 and updating to the 5.3.0 snapshot was actually the fix. I don’t really know what the error means though and when I posted it in the #Lucee channel on CFML Slack a couple times, no one really had heard of it so I assumed it was just me.

I have tested “Julian_Halliwell”'s solution. It fixed the problem for me as well.

After the ESAPI downgrade from to however, I have upgraded ESAPI to again. Now it works like a charm…

Sidenote: After every down-/upgrade I have restartet Lucee.

1 Like

Interesting. I tried that but the error returned when I restarted Lucee.

I’m not sure what constellation of upgrade/downgrade is causing this, but i will further investigate.
Problem is the file /lucee/temp/properties/ that contains this line:


We had to set this line so, the ESAPI library is not using log4j directly anymore, instead it is using our own factory that point to the Lucee core log framework (what is log4j2).

Problem for sure is, when you downgrade to an older version and you have this setting, you get this bug, because the older implementation simply does not have this class.

we did fix this by changing the location of that properties file to
/Lucee/temp/esapi224/, so every version has it’s own properties file and they no longer conflict.

As a workariund, simply delete the file /lucee/temp/properties/

Thanks, Micha, but I that didn’t work for me. I also tried deleting the entire contents of the temp/ directory but the error was still thrown. With each change I restarted Tomcat/Lucee before testing again.

Once again, downgrading to ESAPI did fix it.

That would make sense if I had upgraded to ESAPI and then (for some reason) downgraded again to

But I didn’t. I’ve been testing with only the latest ESAPI extension installed. Surely that does have the org.lucee.extension.esapi.log.LogFactoryImpl class and the reference in the new esapi224/ file should work?

Maybe this isn’t relevant but the following entry in my bundles listing looks suspicious:

This is after upgrading ESAPI to and double-checking that the previous version bundles have gone from by bundles directory. In which case why is that older version still present and active? Where can it be coming from? Have searched my entire Tomcat/Lucee install folder but can’t locate it.

That’s interesting.
For comparison: I have only one version active.

1 Like

I should have triple-checked my tomcat\lucee-server\bundles folder. Found the offending file which was named org-lucee-esapi-2-1-0-1.jar with hyphens instead of dots. Deleted. Restarted. All working again :slightly_smiling_face:

@micstriit So is this just a clean-up problem when the extension is upgraded?

…and why wouldn’t OSGi ensure the new jar is used even if the old one is still there?