It's all about the answers!

Ask a question

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


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

 Hi,


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 (61.4k33643) | answered Nov 18, 9:10 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Nov 18, 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.

Configurator.setLevel(LogManager.getLogger(logger).getName(),Level.WARN);


Also see my experience with the SDK and the plain Java Client Libraries for 7.0.2SR1 and beyond here: https://rsjazz.wordpress.com/2022/09/13/workitem-command-line-and-rtc-ewm-extensions-workshop-for-7-0-2-sr1/

Álvaro Alonso selected this answer as the correct answer

Comments
Álvaro Alonso commented Nov 21, 3:21 a.m. | edited Nov 23, 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.1k7) | answered Nov 18, 8:55 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

log4j v1 was removed from ELM applications in order to address security vulnerabilities. Custom code should instead be referencing log4j v2 - see https://logging.apache.org/log4j/2.x/ for details.

Your answer


Register or to post your answer.