I have class LoggerInitializer
with method:
public static void initLogger() {
try {
LogManager
.getLogManager()
.readConfiguration(
Service.class.getResourceAsStream("/logging.properties"));
} catch (IOException e) {
System.err.println("Could not setup logger configuration: " + e.toString());
}
}
When I start test in classes which have method
@BeforeClass
public static void initEnvironment() {
LoggerInitializer.initLogger();
}
Getting an error
java.lang.NullPointerException
at java.util.Properties$LineReader.readLine(Properties.java:434)
at java.util.Properties.load0(Properties.java:353)
at java.util.Properties.load(Properties.java:341)
at java.util.logging.LogManager.readConfiguration(LogManager.java:1409)
at com.netcracker.edu.inventory.LoggerInitializer.initLogger(LoggerInitializer.java:23)
at com.netcracker.edu.inventory.model.impl.BatteryTest.initEnvironment(BatteryTest.java:18)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
What can be the cause of these errors? How to solve this problem?