Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

 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

0 votes


Accepted answer

Permanent link

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

0 votes

Comments

 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

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.

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,948

Question asked: Nov 18 '22, 8:43 a.m.

Question was seen: 4,660 times

Last updated: Nov 23 '22, 4:30 p.m.

Confirmation Cancel Confirm