Jasper Report – Chinese Language

<style name="Arial Unicode MS" isDefault="true" fontName="ArialUnicodeMS" fontSize="10" 
	pdfFontName="d:reportsARIALUNI.TTF" pdfEncoding="Identity-H" isPdfEmbedded="true"/>

It works fine with Chinese Language in Java or Uni Code.


Reports: Jasper Vs Apache POI Excel

After working with Jasper Reports….these are the points to remember while designing the reports.

1. Go for Jasper, only if it is required. Other wise better to use Apache POI Excel

Generally PDFs are read only. It is good to print invoices, bills, receipts, …etc

When there is a report with 40 pages, who is having time to print and read it.

If we use Apache POI  to write data to excel, it is easy to filter the data and do more drill down offline.


It is very difficult to format the report in Jasper Reports. It is easy to do in Excel.


We can off load the business logic to Excel and do in macros. This reduces burden on server side.

We can’t do in PDFs.


We can provide templates in Excel and we can import the data back from supervisor from a trip.

We can’t do this in PDFs.


Conclusion: User Jasper Reports, only if it is required. Other wise easy to complete same stuff with Apache POI Excel API.


Problem with Apache POI Excel API, client’s must need to have Windows and MS Office to read the documents.


Also better to use http://www.displaytag.sf.net to show data in tabular view.
1. user can sort the data easily.
2. Easy to provide reports in footer.

Jasper Reports 3.7.3, JBoss 4.2.3, Java 1.6.21 upgrade Problem

Problem: When upgrading to Jasper Reports 3.7.3, JBoss 4.2.3, Java 1.6.21 upgrade Problem, got the following problem.

org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/classes/application-context.xml]; nested exception is java.lang.ClassCastException: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to javax.xml.parsers.DocumentBuilderFactory
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:420)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)

Solution: XML Parser is provided by JBoss and Java 1.6. Due to this we need to knock down it from deployment


Jasper Reports – Pie Chart Shadows

Problem: Getting ugly shadows around tiny pie charts.

Solution: In palette select Theme as “aegean”

We will get this following error

Caused by: net.sf.jasperreports.engine.JRRuntimeException: Chart theme ‘aegean’ not found.

We need to add to the pom file.

Maven is not pulling them from repository.
We need to install.

Note: Try to use the files comes with respective jar bundle. Otherwise we will get version related errors.

Restlet – Read HTTP Headers

Problem: How to read HTTP Headers in Restlet? Also we need to get Date from HTTP Headers.

Series<Parameter> headers = (Series<Parameter>) getRequest().getAttributes().get("org.restlet.http.headers");
Set<String> headerNames = headers.getNames();
for(String headerName:headerNames)
	System.out.println( "name==>"+headerName+" value==>"+ headers.getFirstValue(headerName));


name==>accept-encoding value==>gzip,deflate
name==>connection value==>keep-alive
name==>accept-language value==>en-us,en;q=0.5
name==>host value==>localhost:8080
name==>accept-charset value==>ISO-8859-1,utf-8;q=0.7,*;q=0.7
name==>user-agent value==>Mozilla/5.0 (Windows; U; Windows NT 4.x; en-US; rv:1.x.x.x) Gecko/23423423 Firefox/2.4.6
name==>accept value==>text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
name==>keep-alive value==>300

Observation: Date is missing when tried from Browser.

When tried from Restlet Client, it is working.

Form attributes = new Form();  
attributes.add( "message.date", "Mar-03-2010 10:30 AM" );
request.getAttributes().put( "org.restlet.http.headers", attributes );

Final Solution:
It is difficult to depend on HTTP Headers when clients are from Flex and other applications.
Easiest way is add Query String parameter like &date=123123123123123