{"action":"created","issue":{"url":"https://api.github.com/repos/powermock/powermock/issues/861","repository_url":"https://api.github.com/repos/powermock/powermock","labels_url":"https://api.github.com/repos/powermock/powermock/issues/861/labels{/name}","comments_url":"https://api.github.com/repos/powermock/powermock/issues/861/comments","events_url":"https://api.github.com/repos/powermock/powermock/issues/861/events","html_url":"https://github.com/powermock/powermock/issues/861","id":265767177,"number":861,"title":"java.util.ServiceConfigurationError: not a subtype when using log4j2 2.9.x","user":{"login":"d53dave","id":3652719,"avatar_url":"https://avatars1.githubusercontent.com/u/3652719?v=4","gravatar_id":"","url":"https://api.github.com/users/d53dave","html_url":"https://github.com/d53dave","followers_url":"https://api.github.com/users/d53dave/followers","following_url":"https://api.github.com/users/d53dave/following{/other_user}","gists_url":"https://api.github.com/users/d53dave/gists{/gist_id}","starred_url":"https://api.github.com/users/d53dave/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/d53dave/subscriptions","organizations_url":"https://api.github.com/users/d53dave/orgs","repos_url":"https://api.github.com/users/d53dave/repos","events_url":"https://api.github.com/users/d53dave/events{/privacy}","received_events_url":"https://api.github.com/users/d53dave/received_events","type":"User","site_admin":false},"labels":[{"id":102818830,"url":"https://api.github.com/repos/powermock/powermock/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":11,"created_at":"2017-10-16T13:19:11Z","updated_at":"2018-02-26T15:50:15Z","closed_at":"2017-11-11T10:06:44Z","author_association":"NONE","body":"Hi,\r\n\r\nwe have been seeing some weird issues on our build server recently and after investigating found out that the problem stemmed from using powermock with log4j2 after upgrading log4j2 from 2.8.3 to 2.9.1. It seems to be a classloading issue and I am not sure the problem lies with powermock - but it might be.\r\n\r\nQuestionaire:\r\n### What steps will reproduce the problem?\r\nHave the class under test (or an injected class) get a log4j2 logger, i.e.\r\n```java\r\nimport org.apache.logging.log4j.LogManager;\r\nimport org.apache.logging.log4j.Logger;\r\n\r\n[...]\r\n\r\nfinal Logger logger = LogManager.getLogger(Example.class);\r\n```\r\n\r\n### What is the expected output?\r\nTesting works with log4j2 2.9.x as it did with 2.8.x.\r\n\r\n### What do you see instead?\r\n\r\n```java\r\njava.util.ServiceConfigurationError: org.apache.logging.log4j.spi.Provider: Provider org.apache.logging.log4j.core.impl.Log4jProvider not a subtype\r\n\tat java.util.ServiceLoader.fail(ServiceLoader.java:239)\r\n\tat java.util.ServiceLoader.access$300(ServiceLoader.java:185)\r\n\tat java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:376)\r\n\tat java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)\r\n\tat java.util.ServiceLoader$1.next(ServiceLoader.java:480)\r\n\tat org.apache.logging.log4j.util.ProviderUtil.loadProviders(ProviderUtil.java:101)\r\n\tat org.apache.logging.log4j.util.ProviderUtil.<init>(ProviderUtil.java:67)\r\n\tat org.apache.logging.log4j.util.ProviderUtil.lazyInit(ProviderUtil.java:142)\r\n\tat org.apache.logging.log4j.util.ProviderUtil.hasProviders(ProviderUtil.java:126)\r\n\tat org.apache.logging.log4j.LogManager.<clinit>(LogManager.java:89)\r\n\tat com.company.project.module.logic.users.InjectedClassWithLogger.<clinit>(InjectedClassWithLogger.java:87)\r\n\tat sun.reflect.GeneratedSerializationConstructorAccessor6.newInstance(Unknown Source)\r\n\tat java.lang.reflect.Constructor.newInstance(Constructor.java:423)\r\n\tat org.objenesis.instantiator.sun.SunReflectionFactoryInstantiator.newInstance(SunReflectionFactoryInstantiator.java:45)\r\n\tat org.objenesis.ObjenesisBase.newInstance(ObjenesisBase.java:73)\r\n\tat org.mockito.internal.creation.instance.ObjenesisInstantiator.newInstance(ObjenesisInstantiator.java:14)\r\n\tat org.powermock.api.mockito.repackaged.ClassImposterizer.createProxy(ClassImposterizer.java:149)\r\n\tat org.powermock.api.mockito.repackaged.ClassImposterizer.imposterise(ClassImposterizer.java:64)\r\n\tat org.powermock.api.mockito.internal.mockcreation.DefaultMockCreator.createMethodInvocationControl(DefaultMockCreator.java:121)\r\n\tat org.powermock.api.mockito.internal.mockcreation.DefaultMockCreator.createMock(DefaultMockCreator.java:69)\r\n\tat org.powermock.api.mockito.internal.mockcreation.DefaultMockCreator.mock(DefaultMockCreator.java:46)\r\n\tat org.powermock.api.mockito.PowerMockito.mock(PowerMockito.java:201)\r\n\tat org.powermock.api.extension.listener.AnnotationEnabler.standardInject(AnnotationEnabler.java:118)\r\n\tat org.powermock.api.extension.listener.AnnotationEnabler.beforeTestMethod(AnnotationEnabler.java:63)\r\n\tat org.powermock.tests.utils.impl.PowerMockTestNotifierImpl.notifyBeforeTestMethod(PowerMockTestNotifierImpl.java:82)\r\n\tat org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(PowerMockJUnit44RunnerDelegateImpl.java:308)\r\n\tat org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTestInSuper(PowerMockJUnit47RunnerDelegateImpl.java:131)\r\n\tat org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.access$100(PowerMockJUnit47RunnerDelegateImpl.java:59)\r\n\tat org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner$TestExecutorStatement.evaluate(PowerMockJUnit47RunnerDelegateImpl.java:147)\r\n\tat org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.evaluateStatement(PowerMockJUnit47RunnerDelegateImpl.java:107)\r\n\tat org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTest(PowerMockJUnit47RunnerDelegateImpl.java:82)\r\n\tat org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runBeforesThenTestThenAfters(PowerMockJUnit44RunnerDelegateImpl.java:298)\r\n\tat org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:86)\r\n\tat org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:49)\r\n\tat org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:218)\r\n\tat org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods(PowerMockJUnit44RunnerDelegateImpl.java:160)\r\n\tat org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.run(PowerMockJUnit44RunnerDelegateImpl.java:134)\r\n\tat org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:33)\r\n\tat org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:45)\r\n\tat org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run(PowerMockJUnit44RunnerDelegateImpl.java:136)\r\n\tat org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:121)\r\n\tat org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:57)\r\n\tat org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:59)\r\n\tat org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)\r\n\tat org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)\r\n\tat org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:539)\r\n\tat org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:761)\r\n\tat org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:461)\r\n\tat org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:207)\r\n\r\n\r\n```\r\n\r\n### What version of the product are you using? \r\npowermock-api-mockito 1.7.3\r\npowermock-module-junit4 1.7.3\r\nwith\r\nmockito-all 1.10.9\r\n"},"comment":{"url":"https://api.github.com/repos/powermock/powermock/issues/comments/368547550","html_url":"https://github.com/powermock/powermock/issues/861#issuecomment-368547550","issue_url":"https://api.github.com/repos/powermock/powermock/issues/861","id":368547550,"user":{"login":"philippebn","id":1213845,"avatar_url":"https://avatars3.githubusercontent.com/u/1213845?v=4","gravatar_id":"","url":"https://api.github.com/users/philippebn","html_url":"https://github.com/philippebn","followers_url":"https://api.github.com/users/philippebn/followers","following_url":"https://api.github.com/users/philippebn/following{/other_user}","gists_url":"https://api.github.com/users/philippebn/gists{/gist_id}","starred_url":"https://api.github.com/users/philippebn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philippebn/subscriptions","organizations_url":"https://api.github.com/users/philippebn/orgs","repos_url":"https://api.github.com/users/philippebn/repos","events_url":"https://api.github.com/users/philippebn/events{/privacy}","received_events_url":"https://api.github.com/users/philippebn/received_events","type":"User","site_admin":false},"created_at":"2018-02-26T15:50:14Z","updated_at":"2018-02-26T15:50:14Z","author_association":"NONE","body":"> `Could not initialize class org.apache.logging.log4j.util.PropertiesUtil\r\njava.lang.NoClassDefFoundError: Could not initialize class org.apache.logging.log4j.util.PropertiesUtil\r\n\tat org.apache.logging.log4j.status.StatusLogger.<clinit>(StatusLogger.java:71)\r\n\tat org.apache.logging.log4j.LogManager.<clinit>(LogManager.java:60)`\r\n\r\n\r\n\r\nGot the same issue here with powermock '1.7.3' and log4j '2.10.0' and 2.10.1-SNAPSHOT"}}
{"actor":{"display_login":"philippebn"}}