[
https://issues.apache.org/jira/browse/LOG4J2-1971?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16089161#comment-16089161
]
Gary Gregory commented on LOG4J2-1971:
--------------------------------------
This is what I get with the latest:
{noformat}
karaf@root()> install
file:///C:/vcs/git/apache/logging/logging-log4j2/log4j-api/target/log4j-api-2.9-SNAPSHOT.jar
Bundle ID: 63
karaf@root()> start 63
Error executing command: Error executing command on bundles:
Error starting bundle 63: Not found:
org.apache.logging.log4j.util.Activator
karaf@root()> log:clear
karaf@root()> start 63
Error executing command: Error executing command on bundles:
Error starting bundle 63: Not found:
org.apache.logging.log4j.util.Activator
karaf@root()> log:display
2017-07-16 15:32:40,735 | DEBUG | nsole user karaf |
LoggingCommandSessionListener | 42 - org.apache.karaf.shell.core - 4.1.1 |
Command: 'log:clear' returned 'null'
2017-07-16 15:32:43,601 | DEBUG | nsole user karaf |
LoggingCommandSessionListener | 42 - org.apache.karaf.shell.core - 4.1.1 |
Executing command: 'start 63'
2017-07-16 15:32:43,617 | DEBUG | 2.9-SNAPSHOT.jar | api
| 63 - org.apache.logging.log4j.api - 2.9.0.SNAPSHOT | BundleEvent
STARTING - org.apache.logging.log4j.api
2017-07-16 15:32:43,617 | DEBUG | 2.9-SNAPSHOT.jar | api
| 63 - org.apache.logging.log4j.api - 2.9.0.SNAPSHOT | BundleEvent
STOPPING - org.apache.logging.log4j.api
2017-07-16 15:32:43,617 | DEBUG | 2.9-SNAPSHOT.jar | BlueprintExtender
| 12 - org.apache.aries.blueprint.core - 1.8.0 | Starting
BlueprintContainer destruction process for bundle
org.apache.logging.log4j.api/2.9.0.SNAPSHOT
2017-07-16 15:32:43,617 | DEBUG | 2.9-SNAPSHOT.jar | BlueprintExtender
| 12 - org.apache.aries.blueprint.core - 1.8.0 | Not a blueprint bundle
or destruction of BlueprintContainer already finished for
org.apache.logging.log4j.api/2.9.0.SNAPSHOT.
2017-07-16 15:32:43,617 | DEBUG | 2.9-SNAPSHOT.jar | BlueprintExtender
| 12 - org.apache.aries.blueprint.core - 1.8.0 | Starting
BlueprintContainer destruction process for bundle
org.apache.logging.log4j.api/2.9.0.SNAPSHOT
2017-07-16 15:32:43,617 | DEBUG | 2.9-SNAPSHOT.jar | BlueprintExtender
| 12 - org.apache.aries.blueprint.core - 1.8.0 | Not a blueprint bundle
or destruction of BlueprintContainer already finished for
org.apache.logging.log4j.api/2.9.0.SNAPSHOT.
2017-07-16 15:32:43,617 | DEBUG | 2.9-SNAPSHOT.jar | CommandExtender
| 42 - org.apache.karaf.shell.core - 4.1.1 | org.apache.logging.log4j.api
(63): Starting destruction process
2017-07-16 15:32:43,617 | DEBUG | 2.9-SNAPSHOT.jar | CommandExtender
| 42 - org.apache.karaf.shell.core - 4.1.1 | org.apache.logging.log4j.api
(63): Not an extended bundle or destruction of extension already finished
2017-07-16 15:32:43,617 | DEBUG | 2.9-SNAPSHOT.jar | CommandExtender
| 42 - org.apache.karaf.shell.core - 4.1.1 | org.apache.logging.log4j.api
(63): Starting destruction process
2017-07-16 15:32:43,617 | DEBUG | 2.9-SNAPSHOT.jar | CommandExtender
| 42 - org.apache.karaf.shell.core - 4.1.1 | org.apache.logging.log4j.api
(63): Not an extended bundle or destruction of extension already finished
2017-07-16 15:32:43,617 | DEBUG | 2.9-SNAPSHOT.jar | api
| 63 - org.apache.logging.log4j.api - 2.9.0.SNAPSHOT | BundleEvent
STOPPED - org.apache.logging.log4j.api
2017-07-16 15:32:43,617 | DEBUG | nsole user karaf |
LoggingCommandSessionListener | 42 - org.apache.karaf.shell.core - 4.1.1 |
Command: 'start 63' failed: org.apache.karaf.shell.support.MultiException:
Error executing command on bundles:
Error starting bundle 63: Not found:
org.apache.logging.log4j.util.Activator
2017-07-16 15:32:43,617 | 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 63: 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 63: 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
2017-07-16 15:32:48,000 | DEBUG | nsole user karaf |
LoggingCommandSessionListener | 42 - org.apache.karaf.shell.core - 4.1.1 |
Executing command: 'log:display'
karaf@root()>
{noformat}
> 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)