why this code throws exception?
<p>I have a void method which is part of a flow run by quartz scheduler task.</p>

<p>The content of this method is this code:</p>

<pre><code>try {
        InputStream ris = this.getClass().getResourceAsStream("arialuni.ttf");
        byte[] ttfAfm = new byte[1];
        if (ris != null) {
            System.out.println("toByteArray START");
            ttfAfm = IOUtils.toByteArray(ris);
            System.out.println("toByteArray END");
        } else
            System.out.println("input stream from arailuni.ttf is null!!!");
        ris.close();
        ris = null;
        bfChinese =
                BaseFont.createFont("arialuni.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, true, ttfAfm, null);
        System.out.println("in myinit() try catch END");
    } catch (Exception e) {
        System.out.println("exception encountered at myinit() " + e);
    }
</code></pre>

<p>It's very strange that <strong>this works nice about 30 times</strong> (basically, the scheduler scans a directory, take any PCL found and converts it to PDF using this arialuni.ttf font) but suddenly it gives the follwing exception:</p>

<pre><code>19:06:24,316 INFO  [STDOUT] toByteArray START
19:06:28,218 ERROR [ReportPollingJob] java.lang.reflect.InvocationTargetExceptio
n
//nothing else here (yes, the exception is only one line...)
</code></pre>

<p>at <code>IOUtils.toByteArray(ris)</code></p>

<p>Can it be because of memory?
It's very strange that it does not go to my catch but just throws this exception...</p>

<p>Can you give a hint?</p>

<p><strong>UPDATE</strong>: Thanks to mdma: I've changed to catch(Throwable e) and now I see:</p>

<pre><code>java.lang.OutOfMemory: JavaHeap Space
</code></pre>

<p>which will not be easy to solve...</p>
