ics_mauricio
ics_mauricio

Reputation: 369

JasperReports 4.1 + Hibernate 3.6 java.lang.NoSuchFieldError: BOOLEAN

Iam getting an error when iam trying to call a report made in iReport 4.1.1.

        Session sax = HibernateUtil.getSessionFactory().openSession();
        Transaction transaction = sax.beginTransaction();


        Map<String, Object> map = new HashMap<String, Object>();
        map.put(JRHibernateQueryExecuterFactory.PARAMETER_HIBERNATE_SESSION, sax);
        //map.put(, session);



        String relativeWebPath = "/reports/factura_template1.jasper";
        String absoluteDiskPath = getServletContext().getRealPath(relativeWebPath);

        JasperPrint print = JasperFillManager.fillReport(new FileInputStream(new File(absoluteDiskPath)),map);
        byte[] report = JasperExportManager.exportReportToPdf(print);

We are using Hibernate 3.6 (JPA Annotations) and Jasperreports 4.1.1 as report engine, when i try to call the report i get this exception:

java.lang.NoSuchFieldError: BOOLEAN
at net.sf.jasperreports.engine.query.JRHibernateQueryExecuter.<clinit>(JRHibernateQueryExecuter.java:70)
at net.sf.jasperreports.engine.query.JRHibernateQueryExecuterFactory.createQueryExecuter(JRHibernateQueryExecuterFactory.java:136)
at net.sf.jasperreports.engine.fill.JRFillDataset.createQueryDatasource(JRFillDataset.java:724)
at net.sf.jasperreports.engine.fill.JRFillDataset.initDatasource(JRFillDataset.java:625)
at net.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:1238)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:869)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:118)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:435)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:398)
at mx.com.facture.FactureApp.server.ReportExporter.ServletExporter.doGet(ServletExporter.java:198)

Any one else has been in this problem?, how did you solve?

Thank you.

Upvotes: 2

Views: 3461

Answers (2)

vahid kh
vahid kh

Reputation: 1882

Replace your existing hibernate3.jar with that one that exists at JasperReports package.

Upvotes: 2

aruniiird
aruniiird

Reputation: 56

Even I was getting the same error... This is because Hibernate 3.6 has deprecated "org.hibernate.Hibernate.BOOLEAN" (and other similar types). They have consolidated all the types into "org.hibernate.type.StandardBasicTypes" class.

Solution

Solution is very simple.

1) Download the whole (with source) jasper tar.gz file from JasperReports home site

2) Untar the file (let the location be called $JASPER_SOURCE)

3) vim $JASPER_SOURCE/src/net/sf/jasperreports/engine/query/JRHibernateQueryExecuter.java

4) Add the following line in the top import statements

import org.hibernate.type.StandardBasicTypes;

5) Now from line 71 onwards change all "Hibernate" to "StandardBasicTypes" (till the end of the static block, that is till 84th line)

6) Save and exit the editor

7) Copy the latest hibernate3.jar (3.6.x version) into "$JASPER_SOURCE/lib" location

8) Now do the following ant command from $JASPER_SOURCE location

ant jar

You will get the modified jar in lib/jasperreports-4.x.x.jar location. Use that jar for your project

--------------- OR -------------------

Another solution is to use old hibernate3.jar file (version 3.0.x) with your project

Upvotes: 4

Related Questions