I am adding a dependency to my Grails Project which brings in both commons-logging and log4j as transitive dependencies. When I run my app I then get an error
Error Error executing script RunApp: Could not initialize class
org.apache.log4j.LogManager (NOTE: Stack trace has been filtered. Use --verbose to see
entiretrace.) java.lang.NoClassDefFoundError: Could not initialize class
org.apache.log4j.LogManager
I tried to remove the commons-logging dependency as per this link by excluding the commons-logging. But it never helped. I see that commons-logging is not a direct dependency of the dependency I am adding. So if do
runtime ('com.company.i18n:i18n:1.3.4')
{
excludes 'commons-logging'
}
does it exclude all the commons-logging dependencies in my dependency ? Or only the immediate ones. How do I solve this issue?
I tried hard by excluding “log4j” from all the dependencies, but nothing worked. Finally I solved this by avoiding all the transitive dependencies and then adding what ever was necessary.