function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
etoeto 

@future handler: SF throws a java(!) nullpointer excpetion when calling Pagereference.getContent

I always get a NullPointerException in a @future-method when calling getContent. Here is a really easy example on how to reproduce this:

 




@future
public static void futureTest(){

System.debug('############################################FUTURE');

PageReference pdfPage = new PageReference( '/apex/test' );
//pdfPage.getParameters().put('id',billId);

System.debug(pdfPage);

Blob pdfblob = pdfPage.getContent(); //throws java nullpointer exception

}






<apex:page >
<!-- Begin Default Content REMOVE THIS -->
<h1>Congratulations</h1>
This is your new Page
<!-- End Default Content REMOVE THIS -->
</apex:page>



I tried to call it from a Button, which calls Apex code and from the execute anonymous feature in Eclipse. In both cases i get the Nullpointer.

 

Seems more to be a bug. If it's a non documented restriction I would expect to receive a apex exception instead of a java nullpointer.

 

Or am I missing something?