title: How can an Exception be created/thrown with no stack trace?
body: <p>I was trawling through some logs today and came across a strange error.</p>
  
  <p>Here's how it appears in the log:</p>
  
  <pre><code>2014/09/11 15:23:52.801 [CC3A5FDD16035540B87F1B8C5E806588:&lt;removed&gt;] WARN a.b.c.Ddd - Main failure 
  java.lang.NullPointerException: null
  2014/09/11 15:23:52.801 [CC3A5FDD16035540B87F1B8C5E806588:&lt;removed&gt;] ...
  </code></pre>
  
  <p>and here's what the code looks like:</p>
  
  <pre><code>} catch (Exception e) {
      Ddd.log.warn("Main failure ", e);
      throw e;
  }
  </code></pre>
  
  <p>The code is in a jsp if that is important. The same exception is repeated once more in the log (as you'd expect from the <code>throw e</code>).</p>
  
  <p>I have no record of what the cause was - the previous line in the log shows execution of a query. This occurred just twice over a 4-day period and seems not to have caused any harm to the system.</p>
  
  <p>Environment: Fairly busy web service running under Tomcat with Java 5.</p>
  
  <p>I am not asking for tips on debugging the system - these errors are long-gone and may even never happen again. I was just stumped as to how any exception (especially an NPE) could be created without a stack trace?</p>
  
  <p><strong>Added</strong></p>
  
  <p>The logger being used is an <code>slf4j</code> driven <code>Logback</code> instance. I believe the <code>warn</code> method is <a href="http://www.slf4j.org/api/org/slf4j/Logger.html#warn%28java.lang.String,%20java.lang.Throwable%29">here</a>. Not sure what <code>Logback</code> method that resolves to but I am confident the <code>Throwable</code> parameter is treated specially and if there was an stack trace attached to the <code>Throwable</code> it <strong>would</strong> appear in the log.</p>
  
  <p>LogBack.xml - as requested:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;configuration&gt;
    &lt;property name="log.package" value="Package" /&gt;
    &lt;property name="log.pattern" value="%date{yyyy/MM/dd HH:mm:ss.SSS} [%X{session}:%X{device}] %level %logger{25} - %msg%n"/&gt; 
    &lt;property name="log.consolePattern" value="%highlight(%-5level) %white(%logger{25}) - %msg%n"/&gt; 
    &lt;if condition='isDefined("catalina.home")'&gt;
      &lt;then&gt;
        &lt;property name="log.dir" value="${catalina.home}/logs" /&gt;
      &lt;/then&gt;
      &lt;else&gt;
        &lt;property name="log.dir" value="." /&gt;
      &lt;/else&gt;
    &lt;/if&gt;
  
    &lt;appender name="console" class="ch.qos.logback.core.ConsoleAppender"&gt;
      &lt;filter class="ch.qos.logback.classic.filter.ThresholdFilter"&gt;
        &lt;level&gt;DEBUG&lt;/level&gt;
      &lt;/filter&gt;
      &lt;encoder&gt;
        &lt;Pattern&gt;${log.consolePattern}&lt;/Pattern&gt;
      &lt;/encoder&gt;
    &lt;/appender&gt;
  
    &lt;appender name="rolling" class="ch.qos.logback.core.rolling.RollingFileAppender"&gt;
      &lt;file&gt;${log.dir}/${log.package}.log&lt;/file&gt;
      &lt;encoder&gt;
        &lt;Pattern&gt;${log.pattern}&lt;/Pattern&gt;
      &lt;/encoder&gt;
      &lt;rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"&gt;
        &lt;fileNamePattern&gt;${log.dir}/${log.package}.%d{yyyy-MM-dd}.%i.log.zip&lt;/fileNamePattern&gt;
        &lt;timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"&gt;
          &lt;!-- or whenever the file size reaches 16MB. --&gt;
          &lt;maxFileSize&gt;16MB&lt;/maxFileSize&gt;
        &lt;/timeBasedFileNamingAndTriggeringPolicy&gt;
        &lt;!-- Keep no more than 3 months data. --&gt;
        &lt;maxHistory&gt;90&lt;/maxHistory&gt;
        &lt;cleanHistoryOnStart&gt;true&lt;/cleanHistoryOnStart&gt;
      &lt;/rollingPolicy&gt;
    &lt;/appender&gt;
  
    &lt;!-- Default logging levels. --&gt;
    &lt;root level="INFO"&gt;
      &lt;appender-ref ref="console"/&gt;
      &lt;appender-ref ref="rolling"/&gt;
    &lt;/root&gt;
    &lt;!-- Specific logging levels. --&gt;
    &lt;!-- Generally set to INFO or ERROR but if you need more details, set to DEBUG. --&gt;
    &lt;logger name="org.apache" level="INFO"/&gt;
    &lt;logger name="net.sf.ehcache" level="ERROR"/&gt;
    &lt;logger name="com.zaxxer" level="ERROR"/&gt;
    &lt;logger name="ch.qos" level="ERROR"/&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>I hand-edited out the values after the session ID in the log to remove customer data.</p>