It's all about the answers!

Ask a question

java.lang.NoClassDefFoundError: org.apache.log4j.Logger - RECOMPILING extensions EWM7.0.2

Álvaro Alonso (35127) | asked Nov 18 '22, 8:43 a.m.


I have migrated EWM from v6.0.6.1 to v7.0.2

Trying to migrate the ccm/sites i have the following error in ccm.log related to a lot of custom plugins: java.lang.NoClassDefFoundError: org.apache.log4j.Logger

I have downloaded the SDK 7.0.2 and i cant import the class import org.apache.log4j.Logger;

The server is using liberty.

How can i log my extensions now?
Can i import the class?

Thank you

Accepted answer

permanent link
Ralph Schoon (63.1k33646) | answered Nov 18 '22, 9:10 a.m.
edited Nov 18 '22, 9:13 a.m.

Hi Alvaro,

it is absolutely a best practice, to try and package EWM extensions with the EWM SDK that matches the version of the EWM server the plugins are supposed to work in.

Having said that, I have seen pretty much no cases where the API broke in a way that you would not be able to deploy in higher versions of EWM. I believe some changes of the Java Version require a rebuild.

Again having said that there is an exception, which is 7.0.2SR1. The removal of Log4J1 and the change to Log4J2 absolutely breaks extensions that use Log4J (1). 

You must setup a new development environment with the new SDK for 7.0.2SR1 and you will have to modify your code. You definitely need the code for the plugin in order to do that. 

The code changes are for example the removal of the old imports for log4j and adding new imports:

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

Getting the logger now looks like this:

private static final Logger logger = LogManager.getLogger();

Changing the warning level now looks like this.


Also see my experience with the SDK and the plain Java Client Libraries for 7.0.2SR1 and beyond here:

Álvaro Alonso selected this answer as the correct answer

Álvaro Alonso commented Nov 21 '22, 3:21 a.m. | edited Nov 23 '22, 4:30 p.m.

 Thank you Ralph!

I compiled again using the SDK from v7 (environment configured using the workshop) and I changed the code.

Now ccm.log doesn’t throw any error and all the plugins look great!

One other answer

permanent link
David Honey (1.8k17) | answered Nov 18 '22, 8:55 a.m.

log4j v1 was removed from ELM applications in order to address security vulnerabilities. Custom code should instead be referencing log4j v2 - see for details.

Your answer

Register or to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.