[
https://issues.apache.org/jira/browse/LOG4J2-1971?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16085057#comment-16085057
]
Gary Gregory commented on LOG4J2-1971:
--------------------------------------
When I run the Apache Karaf console, I can install log4j-api 2.9-SNAPSHOT but
not start it:
{noformat}
2017-07-12 19:16:53,420 | ERROR | nsole user karaf | ShellUtil
| 42 - org.apache.karaf.shell.core - 4.1.1 | Exception caught while
executing command
org.apache.karaf.shell.support.MultiException: Error executing command on
bundles:
Error starting bundle 57: Not found:
org.apache.logging.log4j.util.Activator
at
org.apache.karaf.shell.support.MultiException.throwIf(MultiException.java:61)
~[42:org.apache.karaf.shell.core:4.1.1]
at
org.apache.karaf.bundle.command.BundlesCommand.doExecute(BundlesCommand.java:67)
[21:org.apache.karaf.bundle.core:4.1.1]
at
org.apache.karaf.bundle.command.BundlesCommand.execute(BundlesCommand.java:52)
[21:org.apache.karaf.bundle.core:4.1.1]
at
org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
[42:org.apache.karaf.shell.core:4.1.1]
at
org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
[42:org.apache.karaf.shell.core:4.1.1]
at
org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
[42:org.apache.karaf.shell.core:4.1.1]
at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:560)
[42:org.apache.karaf.shell.core:4.1.1]
at
org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:486)
[42:org.apache.karaf.shell.core:4.1.1]
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:375)
[42:org.apache.karaf.shell.core:4.1.1]
at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:417)
[42:org.apache.karaf.shell.core:4.1.1]
at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
[42:org.apache.karaf.shell.core:4.1.1]
at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
[42:org.apache.karaf.shell.core:4.1.1]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[?:?]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[?:?]
at java.lang.Thread.run(Thread.java:748) [?:?]
Suppressed: java.lang.Exception: Error starting bundle 57: Not found:
org.apache.logging.log4j.util.Activator
at
org.apache.karaf.bundle.command.BundlesCommand.doExecute(BundlesCommand.java:64)
[21:org.apache.karaf.bundle.core:4.1.1]
at
org.apache.karaf.bundle.command.BundlesCommand.execute(BundlesCommand.java:52)
[21:org.apache.karaf.bundle.core:4.1.1]
at
org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
[42:org.apache.karaf.shell.core:4.1.1]
at
org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
[42:org.apache.karaf.shell.core:4.1.1]
at
org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
[42:org.apache.karaf.shell.core:4.1.1]
at
org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:560)
[42:org.apache.karaf.shell.core:4.1.1]
at
org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:486)
[42:org.apache.karaf.shell.core:4.1.1]
at
org.apache.felix.gogo.runtime.Closure.execute(Closure.java:375)
[42:org.apache.karaf.shell.core:4.1.1]
at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:417)
[42:org.apache.karaf.shell.core:4.1.1]
at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
[42:org.apache.karaf.shell.core:4.1.1]
at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
[42:org.apache.karaf.shell.core:4.1.1]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[?:?]
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[?:?]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[?:?]
at java.lang.Thread.run(Thread.java:748) [?:?]
Caused by: org.osgi.framework.BundleException: Not found:
org.apache.logging.log4j.util.Activator
at
org.apache.felix.framework.Felix.createBundleActivator(Felix.java:4493) ~[?:?]
at
org.apache.felix.framework.Felix.activateBundle(Felix.java:2219) ~[?:?]
at
org.apache.felix.framework.Felix.startBundle(Felix.java:2144) ~[?:?]
at
org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998) ~[?:?]
at
org.apache.karaf.bundle.command.Start.executeOnBundle(Start.java:38) ~[?:?]
at
org.apache.karaf.bundle.command.BundlesCommand.doExecute(BundlesCommand.java:62)
~[?:?]
... 14 more
Caused by: java.lang.ClassNotFoundException:
org.apache.logging.log4j.util.Activator not found by
org.ops4j.pax.logging.pax-logging-api [5]
at
org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1550)
~[?:?]
at
org.apache.felix.framework.BundleWiringImpl.access$200(BundleWiringImpl.java:79)
~[?:?]
at
org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1958)
~[?:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:?]
at
org.apache.felix.framework.BundleWiringImpl.getClassByDelegation(BundleWiringImpl.java:1391)
~[?:?]
at
org.apache.felix.framework.BundleWiringImpl.searchImports(BundleWiringImpl.java:1571)
~[?:?]
at
org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1501)
~[?:?]
at
org.apache.felix.framework.BundleWiringImpl.access$200(BundleWiringImpl.java:79)
~[?:?]
at
org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1958)
~[?:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:?]
at
org.apache.felix.framework.BundleWiringImpl.getClassByDelegation(BundleWiringImpl.java:1391)
~[?:?]
at
org.apache.felix.framework.Felix.createBundleActivator(Felix.java:4489) ~[?:?]
at
org.apache.felix.framework.Felix.activateBundle(Felix.java:2219) ~[?:?]
at
org.apache.felix.framework.Felix.startBundle(Felix.java:2144) ~[?:?]
at
org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998) ~[?:?]
at
org.apache.karaf.bundle.command.Start.executeOnBundle(Start.java:38) ~[?:?]
at
org.apache.karaf.bundle.command.BundlesCommand.doExecute(BundlesCommand.java:62)
~[?:?]
... 14 more
{noformat}
The Activator is there of course. What the?
> ClassCastException: org.eclipse.osgi.internal.loader.SystemBundleLoader$1
> cannot be cast to java.lang.ClassLoader
> -----------------------------------------------------------------------------------------------------------------
>
> Key: LOG4J2-1971
> URL: https://issues.apache.org/jira/browse/LOG4J2-1971
> Project: Log4j 2
> Issue Type: Bug
> Affects Versions: 2.8
> Reporter: liwenxian2017
> Fix For: 2.9
>
>
> When I migrated log4j from log4j 1.2.17 to log4j 2.8, There is an Exception
> like this:
> java.lang.ClassCastException:
> org.eclipse.osgi.internal.loader.SystemBundleLoader$1 cannot be cast to
> java.lang.ClassLoaderat
> org.eclipse.osgi.internal.resolver.BundleDescriptionImpl$DescriptionWiring.getClassLoader(BundleDescriptionImpl.java:1229)
> ~[org.eclipse.osgi.jar:?]at
> org.apache.logging.log4j.core.osgi.Activator.scanBundleForPlugins(Activator.java:70)
> ~[log4j-core.jar:2.8]at
> org.apache.logging.log4j.core.osgi.Activator.bundleChanged(Activator.java:91)
> ~[log4j-core.jar:2.8]at
> org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:847)
> ~[org.eclipse.osgi.jar:?]at
> org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
> ~[org.eclipse.osgi.jar:?]at
> org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
> ~[org.eclipse.osgi.jar:?]at
> org.eclipse.osgi.framework.internal.core.Framework.publishBundleEventPrivileged(Framework.java:1568)
> ~[org.eclipse.osgi.jar:?]at
> org.eclipse.osgi.framework.internal.core.Framework.publishBundleEvent(Framework.java:1504)
> ~[org.eclipse.osgi.jar:?]at
> org.eclipse.osgi.framework.internal.core.Framework.publishBundleEvent(Framework.java:1499)
> ~[org.eclipse.osgi.jar:?]at
> org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:247)
> ~[org.eclipse.osgi.jar:?]at
> org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438)
> ~[org.eclipse.osgi.jar:?]at
> org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:1)
> ~[org.eclipse.osgi.jar:?]at
> org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
> ~[org.eclipse.osgi.jar:?]at
> org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)
> ~[org.eclipse.osgi.jar:?]
> I checked Activator.java in log4j-core:
> ...
> 86 @Override
> 87 public void bundleChanged(final BundleEvent event) {
> 88 switch (event.getType()) {
> 89 // FIXME: STARTING instead of STARTED?
> 90 case BundleEvent.STARTED:
> 91 scanBundleForPlugins(event.getBundle());
> 92 break;
> in line 91, it called scanBundleForPlugins for every bundles. But in line
> 60-61, it does not scan system bundle for plugins
> 57 private static void scanInstalledBundlesForPlugins(final BundleContext
> context) {
> 58 final Bundle[] bundles = context.getBundles();
> 59 for (final Bundle bundle : bundles) {
> 60 // LOG4J2-920: don't scan system bundle for plugins
> 61 if (bundle.getState() == Bundle.ACTIVE && bundle.getBundleId() != 0)
> {
> 62 // TODO: bundle state can change during this
> 63 scanBundleForPlugins(bundle);
> And org.eclipse.osgi_3.8.1 's bundle ID is just 0. So it skipped bundle
> org.eclipse.osgi in line 61-63. but it does not in line 91
> If I changed line 91 to:
> if (event.getBundle().getState() == Bundle.ACTIVE &&
> event.getBundle().getBundleId() != 0) {
> scanBundleForPlugins(event.getBundle());
> }
> The exception goes away.
> So is this a bug? Or this is NOT a bug and there is a workaround for this
> Exception? Thanks.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)