java.lang.NullPointerException

QOS.ch JIRA | Daniel Hlynskyi | 3 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    I want to do log rollover on application start. I'm using this code: {code:title=Bar.java|borderStyle=solid} JoranConfigurator configurator = new JoranConfigurator(); configurator.setContext(context); context.reset(); configurator.doConfigure(u); @SuppressWarnings({ "rawtypes", "unchecked" }) HashMap<String, Appender<?>> appenderBag = (HashMap) configurator .getInterpretationContext() .getObjectMap().get(ActionConst.APPENDER_BAG); for (Appender<?> a : appenderBag.values()) { System.out.println("Rolling file for " + a.getName()); if (a instanceof RollingFileAppender) { System.out.println("really Rolling file for " + a.getName()); try { ((RollingFileAppender<?>)a).rollover(); } catch (Exception e) { e.printStackTrace(); } } } {code} I get this exception: {code:title=Bar.java|borderStyle=solid} java.lang.NullPointerException at ch.qos.logback.core.rolling.helper.FileFilterUtil.afterLastSlash(FileFilterUtil.java:46) at ch.qos.logback.core.rolling.TimeBasedRollingPolicy.rollover(TimeBasedRollingPolicy.java:149) at ch.qos.logback.core.rolling.RollingFileAppender.attemptRollover(RollingFileAppender.java:158) at ch.qos.logback.core.rolling.RollingFileAppender.rollover(RollingFileAppender.java:137) at config.log.LoggerUtils.loadLoggingConfig(LoggerUtils.java:73) at config.ProjectContextListener.contextInitialized(ProjectContextListener.java:52) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:672) at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1862) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) {code} When rollover happens on it's own (as defined in .xml file) everything is OK. I think this is a bug My XML: {code:xml} <appender name="warnings-to-file" class="ch.qos.logback.core.rolling.RollingFileAppender"> <filter class="config.log.ActionMarkerFilter"> <OnMatch>DENY</OnMatch> <OnMismatch>NEUTRAL</OnMismatch> </filter> <filter class="config.log.TimingMarkerFilter"> <OnMatch>DENY</OnMatch> <OnMismatch>NEUTRAL</OnMismatch> </filter> <file>${LOG_PATH}/warnings.log</file> <encoder> <pattern>%d{HH:mm:ss} %-4level %msg%n</pattern> </encoder> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>${LOG_PATH}/warnings-%d{yyyy-MM-dd}.%i.log</fileNamePattern> <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> <maxFileSize>100MB</maxFileSize> <elapsedPeriodsFileName>warnings.log</elapsedPeriodsFileName> </timeBasedFileNamingAndTriggeringPolicy> </rollingPolicy> </appender> {code}

    QOS.ch JIRA | 3 years ago | Daniel Hlynskyi
    java.lang.NullPointerException
  2. 0

    I want to do log rollover on application start. I'm using this code: {code:title=Bar.java|borderStyle=solid} JoranConfigurator configurator = new JoranConfigurator(); configurator.setContext(context); context.reset(); configurator.doConfigure(u); @SuppressWarnings({ "rawtypes", "unchecked" }) HashMap<String, Appender<?>> appenderBag = (HashMap) configurator .getInterpretationContext() .getObjectMap().get(ActionConst.APPENDER_BAG); for (Appender<?> a : appenderBag.values()) { System.out.println("Rolling file for " + a.getName()); if (a instanceof RollingFileAppender) { System.out.println("really Rolling file for " + a.getName()); try { ((RollingFileAppender<?>)a).rollover(); } catch (Exception e) { e.printStackTrace(); } } } {code} I get this exception: {code:title=Bar.java|borderStyle=solid} java.lang.NullPointerException at ch.qos.logback.core.rolling.helper.FileFilterUtil.afterLastSlash(FileFilterUtil.java:46) at ch.qos.logback.core.rolling.TimeBasedRollingPolicy.rollover(TimeBasedRollingPolicy.java:149) at ch.qos.logback.core.rolling.RollingFileAppender.attemptRollover(RollingFileAppender.java:158) at ch.qos.logback.core.rolling.RollingFileAppender.rollover(RollingFileAppender.java:137) at config.log.LoggerUtils.loadLoggingConfig(LoggerUtils.java:73) at config.ProjectContextListener.contextInitialized(ProjectContextListener.java:52) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:672) at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1862) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) {code} When rollover happens on it's own (as defined in .xml file) everything is OK. I think this is a bug My XML: {code:xml} <appender name="warnings-to-file" class="ch.qos.logback.core.rolling.RollingFileAppender"> <filter class="config.log.ActionMarkerFilter"> <OnMatch>DENY</OnMatch> <OnMismatch>NEUTRAL</OnMismatch> </filter> <filter class="config.log.TimingMarkerFilter"> <OnMatch>DENY</OnMatch> <OnMismatch>NEUTRAL</OnMismatch> </filter> <file>${LOG_PATH}/warnings.log</file> <encoder> <pattern>%d{HH:mm:ss} %-4level %msg%n</pattern> </encoder> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>${LOG_PATH}/warnings-%d{yyyy-MM-dd}.%i.log</fileNamePattern> <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> <maxFileSize>100MB</maxFileSize> <elapsedPeriodsFileName>warnings.log</elapsedPeriodsFileName> </timeBasedFileNamingAndTriggeringPolicy> </rollingPolicy> </appender> {code}

    QOS.ch JIRA | 3 years ago | Daniel Hlynskyi
    java.lang.NullPointerException
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.NullPointerException

      No message provided

      at ch.qos.logback.core.rolling.helper.FileFilterUtil.afterLastSlash()
    2. Logback Core Module
      RollingFileAppender.rollover
      1. ch.qos.logback.core.rolling.helper.FileFilterUtil.afterLastSlash(FileFilterUtil.java:46)
      2. ch.qos.logback.core.rolling.TimeBasedRollingPolicy.rollover(TimeBasedRollingPolicy.java:149)
      3. ch.qos.logback.core.rolling.RollingFileAppender.attemptRollover(RollingFileAppender.java:158)
      4. ch.qos.logback.core.rolling.RollingFileAppender.rollover(RollingFileAppender.java:137)
      4 frames
    3. config.log
      LoggerUtils.loadLoggingConfig
      1. config.log.LoggerUtils.loadLoggingConfig(LoggerUtils.java:73)
      1 frame
    4. config
      ProjectContextListener.contextInitialized
      1. config.ProjectContextListener.contextInitialized(ProjectContextListener.java:52)
      1 frame
    5. Glassfish Core
      HostConfig$DeployDescriptor.run
      1. org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973)
      2. org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
      3. org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      4. org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
      5. org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
      6. org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
      7. org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:672)
      8. org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1862)
      8 frames
    6. Java RT
      Thread.run
      1. java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
      2. java.util.concurrent.FutureTask.run(Unknown Source)
      3. java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      4. java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      5. java.lang.Thread.run(Unknown Source)
      5 frames