org.apache.logging.log4j.core package is not supposed to be available. So the org.apache.logging.log4j.core.LoggerContext#getContext() is not part of the public api. You should use org.apache.logging.log4j.LogManager#getContext() instead.
2017-08-09 19:44 GMT+02:00 Jérémie Brébec <[email protected]>: > Yes, that is the first thing I checked. > > However LoggerContext.getContext() > <https://github.com/apache/logging-log4j2/blob/master/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java#L169> > try > to cast the context into a org.apache.logging.log4j.core.LoggerContext > and Log4jv2LoggerContext > <https://github.com/ops4j/org.ops4j.pax.logging/blob/master/pax-logging-api/src/main/java/org/ops4j/pax/logging/log4jv2/Log4jv2LoggerContext.java> > implements > only org.apache.logging.log4j.spi.LoggerContext so it's doesn't seen to > be related to osgi and classloader. > > Le mercredi 9 août 2017 18:40:55 UTC+2, Achim Nierbeck a écrit : >> >> Hi, >> >> it still might be a class-cast exception when you embed that class in >> your own bundle. Maybe that is the case in your scenario. >> I'd check that first. >> >> regards, Achim >> >> >> 2017-08-09 17:30 GMT+02:00 Jérémie Brébec <[email protected]>: >> >>> Hello, >>> >>> I am using pax-logging 1.10.1 through Karaf 4.1.2 ; >>> >>> I am trying to integrate the log generated by my ElasticSearch bundle to >>> the pax-logging implementation. However, this didn't work because a >>> ClassCastException. I haven't see any "duplicate classloader issues", and >>> when I check the code, the ClassCastException doesn't feel to be >>> osgi-related. Is it a known issue or I am missing something ? >>> >>> Regards, >>> Jérémie >>> >>> java.lang.ClassCastException: >>> org.ops4j.pax.logging.log4jv2.Log4jv2LoggerContext >>> cannot be cast to org.apache.logging.log4j.core.LoggerContext >>> at >>> org.apache.logging.log4j.core.LoggerContext.getContext(LoggerContext.java:190) >>> [6:org.ops4j.pax.logging.pax-logging-log4j2:1.10.1] >>> at >>> org.apache.logging.log4j.core.config.Configurator.setLevel(Configurator.java:291) >>> [6:org.ops4j.pax.logging.pax-logging-log4j2:1.10.1] >>> at >>> org.elasticsearch.common.logging.Loggers.setLevel(Loggers.java:149) >>> [88:features.boss.elasticsearch.bundle:5.5.0] >>> at >>> org.elasticsearch.common.logging.Loggers.setLevel(Loggers.java:144) >>> [88:features.boss.elasticsearch.bundle:5.5.0] >>> at >>> org.elasticsearch.index.SearchSlowLog.setLevel(SearchSlowLog.java:111) >>> [88:features.boss.elasticsearch.bundle:5.5.0] >>> at >>> org.elasticsearch.index.SearchSlowLog.<init>(SearchSlowLog.java:106) >>> [88:features.boss.elasticsearch.bundle:5.5.0] >>> at org.elasticsearch.index.IndexModule.<init>(IndexModule.java:127) >>> [88:features.boss.elasticsearch.bundle:5.5.0] >>> at >>> org.elasticsearch.indices.IndicesService.createIndexService(IndicesService.java:441) >>> [88:features.boss.elasticsearch.bundle:5.5.0] >>> at >>> org.elasticsearch.indices.IndicesService.createIndex(IndicesService.java:414) >>> [88:features.boss.elasticsearch.bundle:5.5.0] >>> at org.elasticsearch.cluster.metadata.MetaDataIndexTemplateServ >>> ice.validateAndAddTemplate(MetaDataIndexTemplateService.java:216) >>> [88:features.boss.elasticsearch.bundle:5.5.0] >>> at org.elasticsearch.cluster.metadata.MetaDataIndexTemplateServ >>> ice.access$200(MetaDataIndexTemplateService.java:63) >>> [88:features.boss.elasticsearch.bundle:5.5.0] >>> at org.elasticsearch.cluster.metadata.MetaDataIndexTemplateServ >>> ice$2.execute(MetaDataIndexTemplateService.java:172) >>> [88:features.boss.elasticsearch.bundle:5.5.0] >>> at >>> org.elasticsearch.cluster.ClusterStateUpdateTask.execute(ClusterStateUpdateTask.java:45) >>> [88:features.boss.elasticsearch.bundle:5.5.0] >>> at >>> org.elasticsearch.cluster.service.ClusterService.executeTasks(ClusterService.java:634) >>> [88:features.boss.elasticsearch.bundle:5.5.0] >>> at org.elasticsearch.cluster.service.ClusterService.calculateTa >>> skOutputs(ClusterService.java:612) [88:features.boss.elasticsearc >>> h.bundle:5.5.0] >>> at >>> org.elasticsearch.cluster.service.ClusterService.runTasks(ClusterService.java:571) >>> [88:features.boss.elasticsearch.bundle:5.5.0] >>> at org.elasticsearch.cluster.service.ClusterService$ClusterServ >>> iceTaskBatcher.run(ClusterService.java:263) >>> [88:features.boss.elasticsearch.bundle:5.5.0] >>> at >>> org.elasticsearch.cluster.service.TaskBatcher.runIfNotProcessed(TaskBatcher.java:150) >>> [88:features.boss.elasticsearch.bundle:5.5.0] >>> at >>> org.elasticsearch.cluster.service.TaskBatcher$BatchedTask.run(TaskBatcher.java:188) >>> [88:features.boss.elasticsearch.bundle:5.5.0] >>> at org.elasticsearch.common.util.concurrent.ThreadContext$Conte >>> xtPreservingRunnable.run(ThreadContext.java:569) >>> [88:features.boss.elasticsearch.bundle:5.5.0] >>> at org.elasticsearch.common.util.concurrent.PrioritizedEsThread >>> PoolExecutor$TieBreakingPrioritizedRunnable.runAndClean(Prio >>> ritizedEsThreadPoolExecutor.java:247) [88:features.boss.elasticsearc >>> h.bundle:5.5.0] >>> at org.elasticsearch.common.util.concurrent.PrioritizedEsThread >>> PoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:210) >>> [88:features.boss.elasticsearch.bundle:5.5.0] >>> at >>> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) >>> [?:?] >>> at >>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) >>> [?:?] >>> >>> -- >>> -- >>> ------------------ >>> OPS4J - http://www.ops4j.org - [email protected] >>> >>> --- >>> You received this message because you are subscribed to the Google >>> Groups "OPS4J" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> >> >> -- >> >> Apache Member >> Apache Karaf <http://karaf.apache.org/> Committer & PMC >> OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer >> & Project Lead >> blog <http://notizblog.nierbeck.de/> >> Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS> >> >> Software Architect / Project Manager / Scrum Master >> >> -- > -- > ------------------ > OPS4J - http://www.ops4j.org - [email protected] > > --- > You received this message because you are subscribed to the Google Groups > "OPS4J" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- ------------------------ Guillaume Nodet -- -- ------------------ OPS4J - http://www.ops4j.org - [email protected] --- You received this message because you are subscribed to the Google Groups "OPS4J" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
