You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Raf Geusens <rg...@hotmail.com> on 2002/02/19 17:31:33 UTC

NullPointerException in render

Hi everybody,

I started using Fop today, because I need it urgently for a project, but 
I've got some trouble running my first piece of code in it.
This is the most important part of code, it's part of a jsp-page.
The application always gives at NullPointerException error when it reaches 
driver.render(...). First I tought one of the parameters was null, but when 
I wrote them to the browser they seemed to be fine (xml.blabla@... you 
know). I also wrote the other parameters like driver, file etc... to the 
browser and none of them is equal to null.
So, what can be the solution to my NullPointerException, any ideas anyone?

try {

XSLTInputHandler input = new XSLTInputHandler(new File(file),new
File (props.getString("pdfFase")));

ByteArrayOutputStream uit = new ByteArrayOutputStream();

response.setContentType("application/pdf");

Driver driver = new Driver();
driver.setLogger(log);
driver.setRenderer(Driver.RENDER_PDF);
driver.setOutputStream(uit);

driver.render(input.getParser(), input.getInputSource());

/*byte [] content = uit.toByteArray();
response.setContentLength(content.length);
response.getOutputStream().write(content);
response.getOutputStream().flush();*/

} catch (Exception e) {
%><%= e %><% e.printStackTrace();
}

Greetings,
Raf



_________________________________________________________________
Join the world’s largest e-mail service with MSN Hotmail. 
http://www.hotmail.com


Re: NullPointerException in render

Posted by Bart Locanthi <ba...@sabl.com>.
the jsp systems i know about take great pains to prevent you from doing 
response.getOutputStream(), having done the equivalent Writer thing for 
the jsp page already.

you've commented out the response stuff in your code, and i guess it's 
after your null pointer problem anyway. but you may have use 
uit.toString() eventually.

have you tried
	driver = new Driver(InputSource, OutputStream)
	...
	driver.run()

Raf Geusens wrote:
> Hi everybody,
> 
> I started using Fop today, because I need it urgently for a project, but 
> I've got some trouble running my first piece of code in it.
> This is the most important part of code, it's part of a jsp-page.
> The application always gives at NullPointerException error when it 
> reaches driver.render(...). First I tought one of the parameters was 
> null, but when I wrote them to the browser they seemed to be fine 
> (xml.blabla@... you know). I also wrote the other parameters like 
> driver, file etc... to the browser and none of them is equal to null.
> So, what can be the solution to my NullPointerException, any ideas anyone?
> 
> try {
> 
> XSLTInputHandler input = new XSLTInputHandler(new File(file),new
> File (props.getString("pdfFase")));
> 
> ByteArrayOutputStream uit = new ByteArrayOutputStream();
> 
> response.setContentType("application/pdf");
> 
> Driver driver = new Driver();
> driver.setLogger(log);
> driver.setRenderer(Driver.RENDER_PDF);
> driver.setOutputStream(uit);
> 
> driver.render(input.getParser(), input.getInputSource());
> 
> /*byte [] content = uit.toByteArray();
> response.setContentLength(content.length);
> response.getOutputStream().write(content);
> response.getOutputStream().flush();*/
> 
> } catch (Exception e) {
> %><%= e %><% e.printStackTrace();
> }
> 
> Greetings,
> Raf
> 
> 
> 
> _________________________________________________________________
> Join the world's largest e-mail service with MSN Hotmail. 
> http://www.hotmail.com