Hot questions for Using JasperReports in ireport

Question:

When i press the button designed to create the report, in the PC on which i developed is ok, on another is ok, on another one it gives me the error:

net.sf.jasperreports.engine.JRException: Error compiling report java source files : C:.....\file_1188085947562_837366.java

I read, on stackoverflow too, that a fix is to include Jasper-jdt-compiler.jar, but in my downloaded zip of jasperproject there is no such jar, where can i find it? And why it is not present? Jasper project downloaded is version 6.1.0


Answer:

I have done some investigations into this question. The org.eclipse compiler was once called jtd-compiler, but in latest jasper report relase it is called

ecj-4.3.1.jar

So it is still included in jasper project/lib, but with another name

Have fun

Question:


Answer:

In jrxml you can define the structured fields (for nested objects) like this:

<field name="dateRange" class="my.package.DateRange">
    <property name="com.jaspersoft.studio.field.label" value="dateRange"/>
</field>
<field name="posts" class="java.util.List">
    <property name="com.jaspersoft.studio.field.label" value="posts"/>
</field>

And then use values from nested objects like $F{dateRange}.getBegin().


But in your case it seems that you have always one topic and iterate posts for it. Then it would be better to:

  • pass topic as a parameter: parameters.put("topic", topic)
  • create DataSource for posts: JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(topic.getPosts())
  • define parameter topic in the report: <parameter name="topic" class="my.package.Topic"/>
  • in report render topic values using parameter expression: $P{topic}.getTopicName()
  • define fields for Post in the report
  • in report render post values using fields (i.e. $F{postName}) in the detail band - JasperReport will automatically iterate all posts and render them

Update (to answer the updated part of the question): To render values of type Collection (List) you can use subreports - see here: Creating Subreport within list in iReport It means that you will create subreport to render user values.

Or you can use table to render users with subDataSet created from users list:

<jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
    <datasetRun subDataset="usersDataSet">
        <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{users})]]></dataSourceExpression>
    </datasetRun>
    ...
</jr:table>

And you must also define the subDataset for the table:

<subDataset name="usersDataSet">
    <field name="userName" class="java.lang.String">
        <fieldDescription><![CDATA[userName]]></fieldDescription>
    </field>
    <field name="userPoints" class="java.lang.Integer">
        <fieldDescription><![CDATA[userPoints]]></fieldDescription>
    </field>
</subDataset>

Question:

My problem is I can't seem to view the ireport file that i created and saved. here is the java coding:

private void btnreportActionPerformed(java.awt.event.ActionEvent evt) {                                          
    Connection c; 

    try {
        c = DBConnect.DB();
        String report = "C:\\Users\\p.bwalya\\Documents\\Reports\\NPS Report.jrprint ";
        JasperReport JR = JasperCompileManager.compileReport(report);
        JasperPrint JP = JasperFillManager.fillReport(JR,null,c);
        JasperViewer.viewReport(JP);
    } catch(SQLException | JRException e) {
        e.printStackTrace();
    }
}                                         

and here is the error message:

net.sf.jasperreports.engine.JRException: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Invalid byte 1 of 1-byte UTF-8 sequence. at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:302) at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:285) at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:274) at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:219) at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:194) at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:185) at net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:288) at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:575) at ireport.main(ireport.java:35)

Does anyone know what is wrong with my code?


Answer:

You compile the jrxml file not the .jasper file (its already complied) nor the jrprint (JasperPrint object, its already filled)

String report = "C:\\Users\\p.bwalya\\Documents\\Reports\\NPS Report.jrprint ";
JasperReport JR = JasperCompileManager.compileReport(report);

you need to pass the .jrxml

es.

String report = "C:\\Users\\p.bwalya\\Documents\\Reports\\NPS_Report.jrxml";
JasperReport JR = JasperCompileManager.compileReport(report);

If you like to know more about the different jasper report formats..

what-is-the-difference-between-jasperreport-formats

Note:

  1. if you already have the .jasper file there is no need to compile the jrxml, just pass the .jasper file to the fillReport instead of the JasperReport see @Lefteris Bab comment.
  2. in the fillReport consider passing an empty HashMap instead of null.

Question:

I want to create simple report with jasper iReport. I don't know how to iterate thought object C fields. For that purpose I created sub report. Example of my classes:

public class D {
    private A a;
    private B b;
    private ArrayList<C> c;
    //getters setters
}

public class C {
   int id;    
   String name;
   // getters setters
}

In main report I declared :

<subreport>
.....
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{c})]]></dataSourceExpression>
<subreportExpression><![CDATA["C:\\path\\report1_subreport2.jasper"]]></subreportExpression>
</subreport>

In sub report :

<field name="c" class="java.util.Collections"/>

My question: how to access fields of class C?

I tried to change class java.util.Collections to C, to create fields with names of C but nothing helps.


Answer:

When you define the fields, do it as follows

<field name="c.id" class="java.lang.String"/>

<field name="c.name" class="java.lang.String"/>

where c is the object and, id and name are the fields of class C. Also make changes in the class as in the code.

Question:

I have a Subreport, that works well, and I have a another report that is using the Subreport and also works well in the IReport; always that I use the subreport from "file Path".

But, I want to add the reports in a JAR (OSGI Bundle), and will execute the report using InputStream to load the Jasper Reports.

Using IReport Designer(version 5.6.0), The Tool to design the Report, is giving me a "Warning" when I change from "File Path" to "Inputstream" in the SubReport Expression Property.

The warning is:

Unable to locate the subreport with expression: "$P{SUBREPORT_1}".

What is the best way to run the report using IReport?


Answer:

This warning just means that iReport is trying to compile the subreport, but can't find it.

When you were using "File Path", you could put the full path to the subreport file, and iReport would find it.

Since you changed to an InputStream, iReport doesn't know how to find the subreport to compile it.

When the report runs inside your application, though, you will feed that information as a parameter and it will run normally.

If you want to stop that warning, just disable the compilation of subreports. Go to Tools, Options, iReport, Compilation and Execution and untick the option labeled "Compile Subreports (if can be found)".

Question:


Answer:

The jasperreports-core-renderer.jar was not and is not part of the jasper reports distribution

It is part of iReport distribution and contains code for rendering xhtml (used by editor)

If you are not developing tool similar to iReport you can remove (and you should never have included) this library

Question:

I'm using ireport and json datasource to generate report,

Issue is ireport is not looping through json array,

My JSON file content is,

{
    "PartOn":[
              {
              "TypeOfPart":"Rotable"
              },
              {
              "TypeOfPart":"Rotable1"
              }]
}

My jrxml file content is,

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Test" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="746af965-a199-4603-be60-5c5ee40d397c">
    <queryString language="json">
        <![CDATA[PartOn]]>
    </queryString>
    <field name="TypeOfPart" class="java.lang.String">
        <fieldDescription><![CDATA[TypeOfPart]]></fieldDescription>
    </field>
    <background>
        <band splitType="Stretch"/>
    </background>
    <columnHeader>
        <band height="61" splitType="Stretch">
            <staticText>
                <reportElement x="280" y="2" width="100" height="20" uuid="ea8134cf-d2db-46ea-923f-5f1feadbd50e"/>
                <text><![CDATA[PartOn.TypeOfPart]]></text>
            </staticText>
        </band>
    </columnHeader>
    <detail>
        <band height="125" splitType="Stretch">
            <textField>
                <reportElement x="280" y="68" width="100" height="20" uuid="66712268-3adc-4c5e-bbd4-f77fe1a83b18"/>
                <textFieldExpression><![CDATA[$F{TypeOfPart}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
</jasperReport>

When I view the report, no value is printed in the report.

Help me to solve.


Answer:

I have found a solution, in ireport during json datasource creation i have mentioned

"Use the report JSON expression when filling the report"

This solved the problem.

Question:

I want to generate a PDF report using JasperReports with JSP

and this is my code

<% 
Class.forName("oracle.jdbc.OracleDriver");
Connection cn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:personnel","user","password");

try {
   File reportFile = new File(application.getRealPath("//reports//rapport_absences.jasper"));
    Map h = new HashMap();

    byte[] bytes = JasperRunManager.runReportToPdf(reportFile.getPath(),h,cn);

    response.setContentType("application/pdf");
    response.setHeader("Content-Disposition",  "inline; filename=report.pdf ");
    response.setContentLength(bytes.length);
    ServletOutputStream outStream = response.getOutputStream();
    outStream.write(bytes,0,bytes.length);
    outStream.flush();
    outStream.close();

}catch (Exception ex){
    ex.printStackTrace();
}
%>

but it give me a blank PDF, although when I run the report from Ireport it runs well and get the data but from jsp it get a blank pdf


Answer:

as always I found the soulution my self since now one could help and here is it I let it here if any one needs it in the future

<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@ page contentType="application/pdf" %>
<%@ page trimDirectiveWhitespaces="true"%>



<%@ page import="net.sf.jasperreports.engine.*" %>
<%@ page import="net.sf.jasperreports.engine.export.*" %>
<%@ page import="java.util.*" %>


<%
Class.forName("oracle.jdbc.OracleDriver");
Connection cn =    DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:personnel","charif","charif123");

response.setHeader("Content-Disposition",  "inline; filename=report.pdf ");
JasperPrint print = JasperFillManager.fillReport("D:\\ISTA\\Projet_Stage\\GestionPersonnel\\web\\reports\\rapport_absences.jasper",
new HashMap(),
cn);


JasperExportManager.exportReportToPdfStream(print,    
response.getOutputStream());

%>

Question:

At first this question is needed for iReport. I have to replace the dot sign with comma. My problem is the type of the field out of our database is BigDecimal und therefore does not exist any replace method. So I changed the type to String, but then I got this message:

it.businesslogic.ireport.gui.logpane.ProblemItem@820dc5 The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files

My code looks like:

new String($F{gewicht}.toString()).replace(".",",")

What can I do?


Answer:

You can use a textfield pattern:

<textField pattern="#,##0.00 €">

This will give you the german format. In this case this is for € values but you can skip the € and add more descimals if wanted:

<textField pattern="#,####0.0000">

Another approach whould be:

new DecimalFormat("#,##0.00 €", new DecimalFormatSymbols(Locale.GERMANY)). format(Double.parseDouble($F{gewicht}))

Question:

I am currently creating a school project in Java using Netbeans.

And I am having problems with iReport 5.5.1

This is how I call my report within the program:

    String report = "G:\\AssessmentRecordSystem\\src\\assessmentrecordsystem\\reports\\report2.jrxml";
 try {
    JasperReport rep = JasperCompileManager.compileReport(report);
    JasperPrint print = JasperFillManager.fillReport(rep, null, connect);
    JasperViewer.viewReport(print);
} 
catch (JRException ex) {
  //  Logger.getLogger(frmReportChooser.class.getName()).log(Level.SEVERE, null, ex);
    JOptionPane.showMessageDialog(null, ex.getMessage());
}

The above code is called when a button is pressed. Then this comes out in the output window in Netbeans and nothing happens:

    2014-09-23 14:01:23,302 WARN  [AWT-EventQueue-0] net.sf.jasperreports.engine.component.ComponentsEnvironment: Found two components for namespace http://jasperreports.sourceforge.net/jasperreports/components`
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/commons/javaflow/bytecode/Continuable
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:446)
    at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:849)
    at assessmentrecordsystem.AssessmentRecordSystemMainForm.jButton2ActionPerformed(AssessmentRecordSystemMainForm.java:2166)
    at assessmentrecordsystem.AssessmentRecordSystemMainForm.access$1400(AssessmentRecordSystemMainForm.java:58)
    at assessmentrecordsystem.AssessmentRecordSystemMainForm$21.actionPerformed(AssessmentRecordSystemMainForm.java:1476)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
    at java.awt.Component.processMouseEvent(Component.java:6505)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:729)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:688)
    at java.awt.EventQueue$3.run(EventQueue.java:686)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:702)
    at java.awt.EventQueue$4.run(EventQueue.java:700)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:699)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.javaflow.bytecode.Continuable
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    ... 54 more`

And regarding about the imported jar files for the program. This is all the jar files I imported:

jasperreports-applet-4.6.0.jar
jasperreports-fonts-4.6.0.jar
jasperreports-javaflow-4.6.0.jar
jasperreports-4.6.0.jar
groovy-all-1.7.5.jar
commons-beanutils-1.8.0.jar
commons-collections-2.1.1.jar
commons-digester-2.1.1.jar
commons-logging-1.1.1.jar
devtools-1.1-all.jar
rs2xml.jar

Guys, i badly need your help and precious ideas about this problem of mine... Hoping any help will come in my way..


Answer:

Add commons-javaflow-<version>.jar into your Classpath

You can download here

Question:

i made jasper report with a field mapping to my project class and the report wont compile anymore. I put in classpath report the jar of my project which was generated from my exported project in eclipse. This project is a web java with framework vraptor and maven.

my class send to my report:

@Entity
@Table
public class TransacaoBancaria implements Serializable {
    private static final long serialVersionUID = 5081334063974639104L;

    @Id
    @GeneratedValue
    private Long id;

    @NotNull
    @ManyToOne(optional = false)
    private ContaBancaria conta;


    @ManyToOne
    private Usuario usuario;

    @Column(nullable = false)
    @NotNull
    @Temporal(TemporalType.TIMESTAMP)
    private Date data;

    @Column(nullable = false)
    @NotNull
    private BigDecimal saldo = BigDecimal.valueOf(0);

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @param id
     *            the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @return the conta
     */
    public ContaBancaria getConta() {
        return conta;
    }

    /**
     * @param conta
     *            the conta to set
     */
    public void setConta(ContaBancaria conta) {
        this.conta = conta;
    }

    /**
     * @return the usuario
     */
    public Usuario getUsuario() {
        return usuario;
    }

    /**
     * @param usuario
     *            the usuario to set
     */
    public void setUsuario(Usuario usuario) {
        this.usuario = usuario;
    }

    /**
     * @return the data
     */
    public Date getData() {
        return data;
    }

    /**
     * @param data
     *            the data to set
     */
    public void setData(Date data) {
        this.data = data;
    }

    /**
     * @return the saldo
     */
    public BigDecimal getSaldo() {
        return saldo;
    }

    /**
     * @param saldo
     *            the saldo to set
     */
    public void setSaldo(BigDecimal saldo) {
        this.saldo = saldo;
    }

}

the agregate class conta:

@Entity
@Table(uniqueConstraints = @UniqueConstraint(columnNames = { "agencia", "conta", "banco" }))
public class ContaBancaria {
    @Id
    @GeneratedValue
    private Long id;

    @Column(nullable = false)
    @NotNull
    private String agencia;

    @Column(nullable = false)
    @NotNull
    private String conta;

    @Column(nullable = false)
    @NotNull
    private String banco;

    @Column(nullable = false)
    @NotNull
    private Boolean ativa = Boolean.FALSE;

    @ManyToOne
    private Usuario usuario;

    @OneToMany(mappedBy = "conta")
    private List<TransacaoBancaria> transacoes = new ArrayList<TransacaoBancaria>();

    //get-set-gerados-------------------------------------------------------

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getAgencia() {
        return agencia;
    }

    public void setAgencia(String agencia) {
        this.agencia = agencia;
    }

    public String getConta() {
        return conta;
    }

    public void setConta(String conta) {
        this.conta = conta;
    }

    public String getBanco() {
        return banco;
    }

    public void setBanco(String banco) {
        this.banco = banco;
    }

    public Boolean getAtiva() {
        return ativa;
    }

    public void setAtiva(Boolean ativa) {
        this.ativa = ativa;
    }

    public Usuario getUsuario() {
        return usuario;
    }

    public void setUsuario(Usuario usuario) {
        this.usuario = usuario;
    }
}

the agreagate class usuario;

@Entity
@Table
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class Usuario implements Serializable {
    private static final long serialVersionUID = -8066548068818800938L;

    @Id
    @GeneratedValue
    private Long id;

    @Column(unique = true, nullable = false)
    @NotNull
    private String email;

    @Column(nullable = false)
    @NotNull
    private String password;

    @Column(nullable = false)
    @NotNull
    private String nome;

    @Column(nullable = false)
    @NotNull
    private String endereco;

    @Column(nullable = false)
    @NotNull
    private String cep;

    private String telefone;

    @Column(nullable = false)
    @NotNull
    private BigDecimal saldo = BigDecimal.valueOf(0);

    @OneToMany(mappedBy = "usuario")
    private List<ContaBancaria> contasBancarias = new ArrayList<ContaBancaria>();

    @OneToMany(mappedBy = "usuario")
    private List<TransacaoBancaria> transacoes = new ArrayList<TransacaoBancaria>();

    public TipoUsuario getTipoUsuario() {
        return (this instanceof Agencia) ? TipoUsuario.AGENCIA : TipoUsuario.ANUNCIANTE;
    }

    public String getCpfCnpj() {
        return (this instanceof Agencia) ? ((Agencia) this).getCnpj() : ((Anunciante) this).getCpf();
    }

    // get-set-gerados-------------------------------------------------------
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public String getEndereco() {
        return endereco;
    }

    public void setEndereco(String endereco) {
        this.endereco = endereco;
    }

    public String getCep() {
        return cep;
    }

    public void setCep(String cep) {
        this.cep = cep;
    }

    public String getTelefone() {
        return telefone;
    }

    public void setTelefone(String telefone) {
        this.telefone = telefone;
    }

    public BigDecimal getSaldo() {
        return saldo;
    }

    public void setSaldo(BigDecimal saldo) {
        this.saldo = saldo;
    }

    public List<ContaBancaria> getContasBancarias() {
        return contasBancarias;
    }

    public void setContasBancarias(List<ContaBancaria> contasBancarias) {
        this.contasBancarias = contasBancarias;
    }
}

follow my jrxml:

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report1" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="032b97ec-ca85-463c-9603-afb4490dc6f1">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="5"/>
    <import value="br.com.bup.domain.Usuario"/>
    <import value="br.com.bup.domain.ContaBancaria"/>
    <field name="saldo" class="java.math.BigDecimal"/>
    <field name="data" class="java.util.Date"/>
    <field name="conta" class="br.com.bup.domain.ContaBancaria"/>
    <field name="usuario" class="br.com.bup.domain.Usuario"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="79" splitType="Stretch"/>
    </title>
    <pageHeader>
        <band height="35" splitType="Stretch"/>
    </pageHeader>
    <columnHeader>
        <band height="61" splitType="Stretch">
            <staticText>
                <reportElement x="0" y="41" width="100" height="20" uuid="29f8398f-d405-4854-a49c-445cdb90d7a4"/>
                <text><![CDATA[saldo]]></text>
            </staticText>
            <staticText>
                <reportElement x="100" y="41" width="175" height="20" uuid="5084d42d-b909-4b4d-87ca-08d6b88bb18b"/>
                <text><![CDATA[data]]></text>
            </staticText>
            <staticText>
                <reportElement x="275" y="41" width="100" height="20" uuid="97389e53-4e4a-4035-9b85-fd297daf6563"/>
                <text><![CDATA[banco]]></text>
            </staticText>
            <staticText>
                <reportElement x="375" y="41" width="100" height="20" uuid="73c8f4aa-6283-4ba7-ad65-1cc8d0407cdf"/>
                <text><![CDATA[agencia]]></text>
            </staticText>
            <staticText>
                <reportElement x="475" y="41" width="100" height="20" uuid="964e28e1-db05-4c5e-8a3e-b590a5639da4"/>
                <text><![CDATA[conta]]></text>
            </staticText>
            <staticText>
                <reportElement x="575" y="41" width="100" height="20" uuid="bd8a4951-a847-48d0-9769-c5252a501e1c"/>
                <text><![CDATA[nome]]></text>
            </staticText>
        </band>
    </columnHeader>
    <detail>
        <band height="125" splitType="Stretch">
            <textField isBlankWhenNull="true">
                <reportElement x="0" y="0" width="100" height="20" uuid="2e55cd40-9d21-49b8-beb7-03708aaaf76f"/>
                <textFieldExpression><![CDATA[$F{saldo}.toString()]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true" pattern="dd/MM/yyyy" isBlankWhenNull="true">
                <reportElement x="100" y="0" width="175" height="20" uuid="9b675e66-51a5-455a-8a36-a5445eb8841d"/>
                <textFieldExpression><![CDATA[$F{data}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                <reportElement x="275" y="0" width="100" height="20" uuid="194dae97-d53a-4368-939f-dd632c9e6e3a"/>
                <textFieldExpression><![CDATA[$F{conta}.banco]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                <reportElement x="375" y="0" width="100" height="20" uuid="7d97aeab-9764-4a32-8391-483dc90bf49a"/>
                <textFieldExpression><![CDATA[$F{conta}.agencia]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                <reportElement x="475" y="0" width="100" height="20" uuid="16c2fc1b-903e-4d30-a2bb-4a2c262a452c"/>
                <textFieldExpression><![CDATA[$F{conta}.conta]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                <reportElement x="575" y="0" width="100" height="20" uuid="49e7797e-c803-49dd-8529-9218fc95a6d2"/>
                <textFieldExpression><![CDATA[$F{usuario}.nome]]></textFieldExpression>
            </textField>
        </band>
    </detail>
    <columnFooter>
        <band height="45" splitType="Stretch"/>
    </columnFooter>
    <pageFooter>
        <band height="54" splitType="Stretch"/>
    </pageFooter>
    <summary>
        <band height="42" splitType="Stretch"/>
    </summary>
</jasperReport>

compiler error:  

Compiling to file... /Users/andreluisdionisio/git/bup/bup/src/main/webapp/WEB-INF/reports/report1.jasper
Error compiling the report java source!
java.lang.UnsupportedClassVersionError: br/com/bup/domain/ContaBancaria : Unsupported major.minor version 51.0     at java.lang.ClassLoader.defineClass1(Native Method)     at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)     at java.lang.ClassLoader.defineClass(ClassLoader.java:621)     at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)     at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)     at java.net.URLClassLoader.access$000(URLClassLoader.java:58)     at java.net.URLClassLoader$1.run(URLClassLoader.java:197)     at java.security.AccessController.doPrivileged(Native Method)     at java.net.URLClassLoader.findClass(URLClassLoader.java:190)     at java.lang.ClassLoader.loadClass(ClassLoader.java:306)     at java.lang.ClassLoader.loadClass(ClassLoader.java:295)     at java.lang.ClassLoader.loadClass(ClassLoader.java:247)     at java.lang.Class.forName0(Native Method)     at java.lang.Class.forName(Class.java:249)     at net.sf.jasperreports.engine.util.JRClassLoader.loadClassForRealName(JRClassLoader.java:157)     at net.sf.jasperreports.engine.util.JRClassLoader.loadClassForName(JRClassLoader.java:115)     at net.sf.jasperreports.engine.base.JRBaseField.getValueClass(JRBaseField.java:128)     at net.sf.jasperreports.engine.design.JRVerifier.verifyFields(JRVerifier.java:981)     at net.sf.jasperreports.engine.design.JRVerifier.verifyDataset(JRVerifier.java:2210)     at net.sf.jasperreports.engine.design.JRVerifier.verifyDesign(JRVerifier.java:386)     at net.sf.jasperreports.engine.design.JRVerifier.verifyDesign(JRVerifier.java:357)     at net.sf.jasperreports.engine.design.JRAbstractCompiler.verifyDesign(JRAbstractCompiler.java:268)     at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:153)     at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:512)     at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)     at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997) 
Compilation running time: 18

my pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>br.com.bup</groupId>
    <artifactId>bup</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>Propaganda</name>

    <repositories>
        <repository>
            <id>prime-repo</id>
            <name>PrimeFaces Maven Repository</name>
            <url>http://repository.primefaces.org</url>
            <layout>default</layout>
        </repository>
    </repositories>

    <dependencies>

        <!-- VRaptor -->
        <dependency>
            <groupId>br.com.caelum</groupId>
            <artifactId>vraptor</artifactId>
            <version>4.1.4</version>
        </dependency>

        <!--  -->
        <dependency>
            <groupId>br.com.caelum.vraptor</groupId>
            <artifactId>vraptor-quartzjob</artifactId>
            <version>4.0.2</version> 
            <scope>compile</scope>
        </dependency>

        <!-- JSTL -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

        <!-- TILES - Apache Tiles is a framework that implements the Composite 
            View pattern... -->
        <dependency>
            <groupId>org.apache.tiles</groupId>
            <artifactId>tiles-extras</artifactId>
            <version>3.0.5</version>
        </dependency>

        <!-- LOG -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.5</version>
        </dependency>

        <!-- CDI -->
        <dependency>
            <groupId>org.jboss.weld.servlet</groupId>
            <artifactId>weld-servlet-core</artifactId>
            <version>2.1.2.Final</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.weld</groupId>
            <artifactId>weld-core-impl</artifactId>
            <version>2.1.2.Final</version>
        </dependency>
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
            <!-- uncomment this line on app servers -->
            <!-- <scope>provided</scope> -->
        </dependency>

        <!-- Expression Language API -->
        <dependency>
            <groupId>javax.el</groupId>
            <artifactId>el-api</artifactId>
            <version>2.2</version>
            <scope>provided</scope>
        </dependency>

        <!-- HIBERNATE -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>4.3.8.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator-cdi</artifactId>
            <version>5.1.1.Final</version>
        </dependency>
        <!-- <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> 
            <version>5.1.3.Final</version> </dependency> -->

        <!-- for JPA, use hibernate-entitymanager instead of hibernate-core -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>4.3.8.Final</version>
        </dependency>

        <!-- JUnit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
        </dependency>

        <!-- H2 in-memory database -->
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>1.2.145</version>
        </dependency>

        <!-- MySQL database driver -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.34</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>net.sf.jasperreports</groupId>
            <artifactId>jasperreports</artifactId>
            <version>6.1.0</version>
        </dependency>
        <dependency>
            <groupId>br.com.prixma</groupId>
            <artifactId>vraptor-jasperreport</artifactId>
            <version>4.1.0</version>
        </dependency>
    </dependencies>

    <properties>
        <maven.test.skip>true</maven.test.skip>
    </properties>

    <build>
        <plugins>
<!--        <plugin> -->
<!--             <groupId>com.alexnederlof</groupId> -->
<!--             <artifactId>jasperreports-plugin</artifactId> -->
<!--             <version>1.6</version> -->
<!--             <executions> -->
<!--                 <execution> -->
<!--                    <phase>prepare-package</phase> -->
<!--                     <goals> -->
<!--                             <goal>jasper</goal> -->
<!--                     </goals> -->
<!--                 </execution> -->
<!--             </executions> -->
<!--             <configuration> -->
<!--                 <compiler>net.sf.jasperreports.engine.design.JRJdtCompiler</compiler> -->
<!--                  <sourceDirectory>src/main/jasperreports</sourceDirectory> -->
<!--                 <outputDirectory>target/${project.artifactId}-${project.version}/WEB-INF/reports</outputDirectory> -->
<!--                 <outputDirectory>src/main/jasperreports</outputDirectory> -->
<!--                 <outputDirectory>src/main/webapp/WEB-INF/reports</outputDirectory> -->

<!--                 <outputFileExt>.jasper</outputFileExt> -->
<!--                 <xmlValidation>true</xmlValidation> -->
<!--                 <verbose>false</verbose> -->
<!--                 <numberOfThreads>4</numberOfThreads> -->
<!--             </configuration> -->
<!--         </plugin> -->

<!--            <plugin> -->
<!--                <groupId>org.codehaus.mojo</groupId> -->
<!--                <artifactId>jasperreports-maven-plugin</artifactId> -->
<!--                <version>1.0-beta-2</version> -->
<!--                <configuration> -->
<!--                    <outputDirectory>target/${project.artifactId}/WEB-INF/reports</outputDirectory> -->
<!--                </configuration> -->
<!--                <executions> -->
<!--                    <execution> -->
<!--                        <phase>prepare-package</phase> -->
<!--                        <inherited>false</inherited> -->
<!--                        <goals> -->
<!--                            <goal>compile-reports</goal> -->
<!--                        </goals> -->
<!--                    </execution> -->
<!--                </executions> -->
<!--            </plugin> -->

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <encoding>ISO-8859-1</encoding>
                </configuration>
            </plugin>
        </plugins>

        <testResources>
            <testResource>
                <filtering>false</filtering>
                <directory>src/test/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </testResource>
            <testResource>
                <directory>src/test/resources</directory>
            </testResource>
        </testResources>
    </build>

</project>

my controller:

    package br.com.bup.controller;

import java.util.List;
import java.util.ResourceBundle;

import javax.inject.Inject;
import javax.inject.Named;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import br.com.bup.annotation.OpenTransaction;
import br.com.bup.dao.TransacaoBancariaDAO;
import br.com.bup.dao.UsuarioDAO;
import br.com.bup.domain.TransacaoBancaria;
import br.com.bup.util.BaseWeb;
import br.com.bup.web.UsuarioSession;
import br.com.caelum.vraptor.Controller;
import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.jasperreports.Report;
import br.com.caelum.vraptor.jasperreports.ReportBuilder;
import br.com.caelum.vraptor.jasperreports.download.ReportDownload;
import br.com.caelum.vraptor.jasperreports.formats.Pdf;
import br.com.caelum.vraptor.observer.download.Download;
import br.com.caelum.vraptor.validator.Validator;

@Controller
@Named("relatorio")
public class RelatorioController extends BaseWeb {
    private final static Logger LOGGER = LoggerFactory.getLogger(AgenciaController.class);

    private final UsuarioDAO usuarioDAO;
    private final TransacaoBancariaDAO transacaoBancariaDAO;

    /**
     * @deprecated CDI eyes only
     */
    protected RelatorioController() {
        this(null, null, null, null, null, null);
    }

    @Inject
    public RelatorioController(Result result, Validator validator, TransacaoBancariaDAO transacaoBancariaDAO,
            UsuarioSession usuarioSession, UsuarioDAO usuarioDAO, ResourceBundle i18n) {
        super(result, validator, usuarioSession, i18n);
        this.usuarioDAO = usuarioDAO;
        this.transacaoBancariaDAO = transacaoBancariaDAO;

    }

    @OpenTransaction
    public Download teste() {
        List<TransacaoBancaria> dataList = transacaoBancariaDAO.buscarTodos();
        Report report = new ReportBuilder().withTemplate("report1.jasper").withData(dataList).build();
        return new ReportDownload(report, new Pdf(), false); //boolean indica que deve ou nao baixar direto... por exemplo... caso false o chrome tenta abrir o arquivo no proprio navegador
    }
}

Answer:

Class br.com.bup.domain.ContaBancaria in your classpath is compiled with jdk 7 and your development machine is using below jdk 7. Please upgrade your JDK.

Question:

I try sum and avg arithmetic operations using ireport for BigDecimal values. Has error anyways when i doing.

-All types are defined BigDecimal in ireport.

-In separete, variables in this example works fine, but i can't doing arithmetic operations with variables.

How sum and average values type BigDecimal?

In my exemple, This is not work:

$F{faturasAuditadasValorTotalLiberado}
.add(new BigDecimal($F{admissaoValorTotalLiberado}, new MathContext(100)))

I try using Java sintax in ireport, but don't work.

I'm use version 3.0.0 ireport. I can't find solution in Jaspersoft community

The default configuration sintax for expression in ireport 3.0.0 is Java

new Long($F{faturasAuditadasQtdDiarias}) + new Long($F{faturasAuditadasQtdDiarias})

I tried, but don't work:

new Long($F{faturasAuditadasQtdDiarias}).sum($F{faturasAuditadasQtdDiarias})


new Long($F{faturasAuditadasQtdDiarias}).sum(new Long($F{faturasAuditadasQtdDiarias}))


$F{faturasAuditadasQtdDiarias}.sum($F{faturasAuditadasQtdDiarias})


$F{faturasAuditadasQtdDiarias} + $F{faturasAuditadasQtdDiarias}

Answer:

i solved the problem for sum :

 $F{faturasAuditadasValorTotalCobrado} 
.add($F{admissaoValorTotalCobrado}, new MathContext(100)) 
.add($F{altasValorTotalCobrado}, new MathContext(100))

Question:

From my application calling jasper report using below code :

List<TransactionResponse> listobject = new ArrayList<TransactionResponse>();
................
JRBeanCollectionDataSource dataSource = new JRBeanCollectionDataSource(listobject);
Map<String, Object> parameters = new HashMap<String,Object>();
parameters.put("transactionResponse", dataSource );
.........
jasperPrint  = JasperFillManager.fillReport(reportTemplate, parameters, dataSource);

and for JRXML report : follow same step

but still 1st record not printing.

JRXML : 1) Declare a new Dataset in the report and parameter name "inquiryResponse" with JRBeanCollectionDataSource Datatype

<subDataset name="transactionResponseDataset" uuid="1a6f1035-fd54-4e45-8d74-e8ee2693d878">
    <queryString language="SQL">
        <![CDATA[]]>
    </queryString>
    <field name="amount" class="java.lang.String">
        <fieldDescription><![CDATA[billNetAmount]]></fieldDescription>
    </field>
    <field name="CustomerId" class="java.lang.String">
        <fieldDescription><![CDATA[customerId]]></fieldDescription>
    </field>
</subDataset>
<parameter name="inquiryResponse" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/>

2 ) Table Component in Detail band:

<componentElement>
            <reportElement key="table 3" stretchType="RelativeToTallestObject" x="0" y="0" width="802" height="75" isPrintWhenDetailOverflows="true" forecolor="#FFFFFF" uuid="7ee968c9-0c6a-4f3e-a8f6-03da6a599429"/>
            <jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
                <datasetRun subDataset="transactionResponseDataset" uuid="e577da21-baf8-49e6-89ae-b72ef1240a4c">
                    <dataSourceExpression><![CDATA[$P{inquiryResponse}]]></dataSourceExpression>
                </datasetRun>
                <jr:column width="100" uuid="f7289bee-9305-408f-8a06-8bf479643735">
                    <jr:columnHeader style="table" height="71" rowSpan="1">
                        <staticText>
                            <reportElement x="0" y="0" width="100" height="71" uuid="253bf2ab-ffb6-40cc-a7f8-11f84fe9001a"/>
                            <box topPadding="5" leftPadding="3" bottomPadding="2" rightPadding="3"/>
                            <textElement textAlignment="Center" verticalAlignment="Top">
                                <font fontName="SansSerif" size="11" isBold="true"/>
                            </textElement>
                            <text><![CDATA[AMOUNT]]></text>
                        </staticText>
                    </jr:columnHeader>
                    <jr:detailCell style="table 1_TD" height="63" rowSpan="1">
                        <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                            <reportElement stretchType="RelativeToTallestObject" x="0" y="0" width="100" height="63" uuid="e03b99f0-8973-438e-8eb8-f030b031444a"/>
                            <box topPadding="2" leftPadding="2" bottomPadding="2" rightPadding="2"/>
                            <textElement>
                                <font fontName="SansSerif"/>
                            </textElement>
                            <textFieldExpression><![CDATA[$F{billNetAmount}]]></textFieldExpression>
                        </textField>
                    </jr:detailCell>
                </jr:column>
                <jr:column width="94" uuid="ce1d342c-5f74-4329-91a9-8b2d10c3dfbc">
                    <jr:tableFooter height="30" rowSpan="1"/>
                    <jr:columnHeader style="table" height="71" rowSpan="1">
                        <staticText>
                            <reportElement x="0" y="0" width="94" height="71" uuid="25eae146-8aa4-46d5-add1-ae60c154eb3a"/>
                            <box topPadding="5" leftPadding="3" bottomPadding="2" rightPadding="3"/>
                            <textElement textAlignment="Center" verticalAlignment="Top">
                                <font fontName="SansSerif" size="11" isBold="true"/>
                            </textElement>
                            <text><![CDATA[CustomerId]]></text>
                        </staticText>
                    </jr:columnHeader>
                    <jr:detailCell style="table 1_TD" height="63" rowSpan="1">
                        <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                            <reportElement stretchType="RelativeToTallestObject" x="0" y="0" width="94" height="63" uuid="fdd054df-7c76-4a1d-8faf-a93e9737c837"/>
                            <box topPadding="2" leftPadding="2" bottomPadding="2" rightPadding="2"/>
                            <textElement>
                                <font fontName="SansSerif"/>
                            </textElement>
                            <textFieldExpression><![CDATA[$F{customerId}]]></textFieldExpression>
                        </textField>
                    </jr:detailCell>
                </jr:column>
            </jr:table>
        </componentElement>

Answer:

This usually happens when people use the same dataSource twice in their reports:

  • once for the main dataSet, when filling the report, and
  • once again for a subDataSet-based component or a subReport placed in the detail band

Your main dataSet has already consumed the 1st record when the table component reuses the same dataSource.

In your case, you could easily fix this by:

  • using the so-called empty dataSource when filling:

    jasperPrint = JasperFillManager.fillReport(reportTemplate, parameters, new JREmptyDataSource());
    
  • or by using a clone when passing it as a parameter:

    parameters.put("transactionResponse", dataSource.cloneDataSource());
    

Question:

i am following this tutorial to passing json to jrxml. my dummy json file success parse into good looking report.

but i have trouble while passing json code to jrxml. in this tutorial there is configuration like picture below

i tried to passing json like this

Map<String,Object> params = new HashMap<String,Object>();

String sPath = "/reports/master_standar_test_kertas.jrxml";
URL uReport = this.getClass().getResource(sPath);

String sJson = "{\"parameter\": { \"status\":\"success\" },\"data\":[{\"kode\":\"001\",\"title\":\"ENAMEL\"}]}";
System.out.println((new JSONObject(sJson)));
InputStream is = new ByteArrayInputStream(sJson.getBytes());
JsonDataSource source = new JsonDataSource(is);

params.put(JsonQueryExecuterFactory.JSON_SOURCE, is);

JasperReport jr = JasperCompileManager.compileReport(uReport.getPath());
JasperPrint jpPrint = JasperFillManager.fillReport(jr, params,source);
JasperViewer jpView = new JasperViewer(jpPrint);

but i got error

net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: $P{net.sf.jasperreports.json.source}

my question :

  1. I am sure my code is wrong, but i don't know the exact wrong code
  2. I am realy want to understand how jasperreport works, but i am new in java, what there is any tutorial that i can read...?

Answer:

  1. I would try to set the JsonQueryExecuterFactory.JSON_INPUT_STREAM parameter instead, as it seems to be exactly what you need. The JsonQueryExecuterFactory.JSON_SOURCE parameter can only be:

    • a resource on the classpath
    • a file from the filesystem, with an absolute or relative path
    • a url
  2. Most of the resources for getting yourself familiar with JasperReports can be found on the Jaspersoft Community website. You may find useful the:

Question:

I use Jasper Reports for the reporting purposes on a java SE software. I configured the report for currency formatting and it appeared correctly on the iReports.

But when I get the same report from jasper viewer (on the software) it appeared without formatting according to the pattern.

Is there a way to fix this?

P.S. I retrieve data from a table (using a query), I'm using Jasper Reports 5.1.0


Answer:

Judging by the difference in the date formats in the upper right corner, it would appear that your iReport and JasperViewer installations run in different locales. You can pass any locale to the standard REPORT_LOCALE report parameter.

Question:

Hi I am creating an invoice report using iReport. I have a table named orderstable and within it there are 6 fields; Order Number, Account Number, Invoice Number, Description, Amount and VAT.

Data contained is as follows:

record 1: 1, PA0001, 10005, Monthly Charge, 200, 20
record 2: 2, PA0001, 10005, Training Delivered, 250, 20

Now when I run my report it asks me for the invoice number. In this case I put in 10005 and this returns a report with the 1st record only. How can I get it so that the details of the Description, Amount and VAT fields are returned for both records?

Thank you.


Answer:

If you put the Table in the Details Section then i donot think that this situation will arise it will repeat the values as this is the property of the details section in IReport.

Question:

I am using IReport 5.6.0 (though 5.0.0 has the same behavior) on Windows 10 64 bit machine.

I have tried to run The IReport with: jdk 1.6 64 bit, jre 1.7 64 bit, jre 1.7 32 bit (I have also jdk 1.8 installed but I am not using that with iReport as I now there is an incompatibility issues).

The environment starts normally - however if i try to push import or export buttons on datasource window - the iReport just exits and the window is closed - no error message is shown.

My colleagues with the same type of machines (W10 jre 1.7 32 bit) have no problem what so ever.

My question is - is there a way to get more information - as of why iReport exits what kind of exception is thrown etc... In other words how to debug this behavior?


Answer:

From https://community.jaspersoft.com/project/ireport-designer

As of version 5.5.0, Jaspersoft Studio will be the official design client for JasperReports. iReport will remain as a supported product in maintenance-only mode until December 31, 2015

Which basically tells that you should switch to JasperSoft Studio

That said the best way for you to debug iReport is to check it's log that you can find in

C:\Users\[your user]\.ireport\[version of iReport]\var\log\messages.log

You can hunt and try to fix errors by yourself but don't expect JasperReport team to fixes these, since now they have moved to a new software.

Question:

I have this:

Map<String, Object> parameters = new HashMap<String, Object>();

ArrayList<String> prueba= new ArrayList<String>();
 prueba.add("juan");
 prueba.add("pablo");
 prueba.add("pedro");

parameters.put("NombresDeMuestra", prueba);

JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, new JREmptyDataSource());

I need show this:

juan

pablo

pedro

My jrxml is this:

    <parameter name = "NombresDeMuestra" class = "java.util.List"/>

<title>
    <band height="79">
 <textField>
            <reportElement x="257" y="11" width="100" height="19"/>
            <textFieldExpression>
                <![CDATA[$P{NombresDeMuestra}]]>
            </textFieldExpression>
        </textField>
    </band>
</title>

But this show: [juan,pablo,pedro]. Thanks


Answer:

To get what you want, you may do like this:

String s = "";
for(String z : prueba) s = s + z + "\n\n";
parameters.put("NombresDeMuestra", s);

and

<parameter name = "NombresDeMuestra" class = "java.lang.String"/>

Question:

I have designed a report using iReport which has 2 detail bands and one page header and footer. There is a page break between the 2 detail bands to make sure that both start from a new page. Content of the first detail band has more data than the second detail band.

The basic output is a PDF with 2 pages along with header,footer. If the content grows the number of pages increase.

Problem: There are some cases in which the first detail band has 2 pages of data and the second one has only one page. In the above scenario, I should be getting 3 pages in total, but I am getting a blank page at the end of the second detail band. If the first detail band has only one page, then second page doesn't create a blank page at the end.

I have removed all the additional bands from the report and also extra space at of each band is removed. Some guidance of experience is highly appreciated.


Answer:

I could reach at finding a solution to the above problem by keeping the page break at the divider of 2 bands and double clicking the line at the end of each band to make sure that there is no space before that line and the last element in the page which is difficult to achieve by just moving the line manually. This gave a fantastic output of only required pages.

Question:

Actually i want to convert some calculation(eg:123 in Words as One Hundred Twenty Three). So i separately designed a jar file and in ireport designer 5.6.0 from "Tools"-->"options"-->"classpath" and added that jar and in "scriptlet" i wrote com.reporter.jasper.ConvertToWord and created a text field in report and added "$REPORT_SCRIPTLET.readNumber($V{Total})" and saved it. So When i click on preview tab its working perfect(eg:64501 as sixty four thousand five hundred one).

Now here comes the problem.I copied the report.jrxml and report.jasper and pasted it in "/WEB-INF/reports/report.jrxml" and run it on server so as to convert into PDF,DOC,XLS,XLSX it is displaying an error like this image

I am giving the code of jar file as well

package com.reporter.jasper;
import java.io.PrintStream;
import net.sf.jasperreports.engine.JRDefaultScriptlet;

public class ConvertToWord extends JRDefaultScriptlet {
     String numberInWord = "";
        String inpstr = "";
        int inputLength;
        String temp = "";

        public String readNumber(double xDouble) {
            long x = (long)xDouble;
            this.inpstr = "" + x;
            this.inpstr = this.inpstr.trim();
            this.inputLength = this.inpstr.length();
            this.numberInWord = "";
            if (this.inpstr.substring(0, 1).trim().equalsIgnoreCase("-")) {
                this.inpstr = this.inpstr.substring(1);
                --this.inputLength;
            }
            this.getDigits(this.inputLength);
            return this.numberInWord;
        }

Showing ireport images

As you can see in above image in scriptlet class "com.reporter.jasper" is package and "ConvertToWord" is class.

In the Text field $P{REPORT_SCRIPTLET}.readNumber($V{Sub Total} +$V{Output VAT and CST and Service Tax}) readNumber is method name.

So what i have to do now so that it will successfully display the data to PDF,DOC,XLS and XLSX.


Answer:

Your class ConvertToWord need to be also in the classpath of your web application, hence its not enough to add the jar to iReport, you need to added it to WEB-INF.

As a note: Can't see the whole of your ConvertToWord class but if you are not overriding the methods of JRDefaultScriptlet (scriplet are made to do code on beforeDetailEval()).

Scriptlets are sequences of Java code that are executed every time a report event occurs. Values of report variables can be affected through scriptlets

there is no need to extend it you can simple do a class with a method and call this from your jrxml

public class ReportHelper{
  public static synchronized String readNumber(double xDouble) {
    ...
  }
}

and then call you class in jrxml es.

ReportHelper.readNumber($V{Sub Total} +$V{Output VAT and CST and Service Tax})

If you are using package, included full path of package definition. If you do not like it static, pass the ReportHelper class as a parameter or define it as a variable.

Naturally the class need's to always be in classpath.

Question:

Trying to make a Jasper Report and I'm having troubles using Java's Date class. I am working with a .CSV file so unfortunately can't use SQL to solve my issues.

I've narrowed it down to this statement:

new Long( 1L * $V{Date2Long} -  1L * $V{Date1Long})

Where Date2Long and Date1Long are: (both variable classes are Date)

new Long($V{Date2}.getTime())
new Long($V{Date1}.getTime())

Where Date2 and Date1 are: (both variable classes are Long)

new SimpleDateFormat("MM/dd/yyyy HH:mm").parse($F{Date2CSVColumnName})
new SimpleDateFormat("MM/dd/yyyy HH:mm").parse($F{Date1CSVColumnName})

Using the date examples: Date2 = "05/05/2015 13:22" Date1 = "04/28/2015 16:54"

Difference should be = 6 days, 20 hours, 28 minutes

Using java's .getTime() I get: Date2 = "1430850120000" Date1 = "1430258040000"

ProductionDateInMilliseconds - CreateDateInMilliseconds: My java equation above = 58860000 (0.68125 Days) <---- ERROR Difference should be = 592080000 (6.85 Days)

The only assumption I can make is that I made an overflow error somewhere. But I don't see how that is possible when all I used was longs. Are longs just broken in IReport?


Answer:

I have tried this and nothing wrong with the iReport. Here is my JRXML file-

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report1" language="groovy" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="322b2351-0f86-4ebd-9c51-905d97f5d8f8">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <parameter name="Date2CSVColumnName" class="java.lang.String" isForPrompting="false">
        <defaultValueExpression><![CDATA["05/05/2015 13:22"]]></defaultValueExpression>
    </parameter>
    <parameter name="Date1CSVColumnName" class="java.lang.String" isForPrompting="false">
        <defaultValueExpression><![CDATA["04/28/2015 16:54"]]></defaultValueExpression>
    </parameter>
    <variable name="Date2" class="java.util.Date">
        <initialValueExpression><![CDATA[new SimpleDateFormat("MM/dd/yyyy HH:mm").parse($P{Date2CSVColumnName})]]></initialValueExpression>
    </variable>
    <variable name="Date1" class="java.util.Date">
        <initialValueExpression><![CDATA[new SimpleDateFormat("MM/dd/yyyy HH:mm").parse($P{Date1CSVColumnName})]]></initialValueExpression>
    </variable>
    <variable name="Date2Long" class="java.lang.Long">
        <variableExpression><![CDATA[]]></variableExpression>
        <initialValueExpression><![CDATA[new Long($V{Date2}.getTime())]]></initialValueExpression>
    </variable>
    <variable name="Date1Long" class="java.lang.Long">
        <variableExpression><![CDATA[]]></variableExpression>
        <initialValueExpression><![CDATA[new Long($V{Date1}.getTime())]]></initialValueExpression>
    </variable>
    <title>
        <band height="138" splitType="Stretch">
            <textField>
                <reportElement x="101" y="0" width="358" height="22" uuid="16e461b2-4c7a-49c6-802e-9bd66b818ce1"/>
                <textFieldExpression><![CDATA[$V{Date2}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="101" y="22" width="358" height="22" uuid="5609ffc9-354c-48ba-bbda-4ef8753875a7"/>
                <textFieldExpression><![CDATA[$V{Date1}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="101" y="58" width="358" height="22" uuid="70582d8a-2c68-463a-ad73-6068bd2c58fd"/>
                <textFieldExpression><![CDATA[$V{Date2Long}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="101" y="80" width="358" height="22" uuid="e48af180-0bb1-4d19-b908-fa7b1a962f45"/>
                <textFieldExpression><![CDATA[$V{Date1Long}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="101" y="116" width="358" height="22" uuid="71ffab1a-f70d-4601-978c-96b73ae0f268"/>
                <textFieldExpression><![CDATA[new Long( 1L * $V{Date2Long} -  1L * $V{Date1Long})]]></textFieldExpression>
            </textField>
        </band>
    </title>
</jasperReport>

Have a look.

Question:

I have successfully make a spring MVC 2.5 application based on this sample : Spring Web MVC - Spring Web Flow Working With JasperReports

But when i tried to access a pdf view of a report built with IREPORT 5.5 i have this exception :

Etat HTTP 500 - Request processing failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mbamsusers': Initialization of bean failed; nested exception is java.lang.ClassCastException: cannot assign instance of net.sf.jasperreports.engine.base.JRBaseStyle to field net.sf.jasperreports.engine.base.JRBaseParagraph.paragraphContainer of type net.sf.jasperreports.engine.JRParagraphContainer in instance of net.sf.jasperreports.engine.base.JRBaseParagraph

type Rapport d'exception

message Request processing failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mbamsusers': Initialization of bean failed; nested exception is java.lang.ClassCastException: cannot assign instance of net.sf.jasperreports.engine.base.JRBaseStyle to field net.sf.jasperreports.engine.base.JRBaseParagraph.paragraphContainer of type net.sf.jasperreports.engine.JRParagraphContainer in instance of net.sf.jasperreports.engine.base.JRBaseParagraph

description Le serveur a rencontré une erreur interne qui l'a empêché de satisfaire la requête.

exception

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mbamsusers': Initialization of bean failed; nested exception is java.lang.ClassCastException: cannot assign instance of net.sf.jasperreports.engine.base.JRBaseStyle to field net.sf.jasperreports.engine.base.JRBaseParagraph.paragraphContainer of type net.sf.jasperreports.engine.JRParagraphContainer in instance of net.sf.jasperreports.engine.base.JRBaseParagraph
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:583)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
cause mère

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mbamsusers': Initialization of bean failed; nested exception is java.lang.ClassCastException: cannot assign instance of net.sf.jasperreports.engine.base.JRBaseStyle to field net.sf.jasperreports.engine.base.JRBaseParagraph.paragraphContainer of type net.sf.jasperreports.engine.JRParagraphContainer in instance of net.sf.jasperreports.engine.base.JRBaseParagraph
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:478)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    java.security.AccessController.doPrivileged(Native Method)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
    org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:220)
    org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
    org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
    org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
    org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)
    org.springframework.web.servlet.view.ResourceBundleViewResolver.initFactory(ResourceBundleViewResolver.java:244)
    org.springframework.web.servlet.view.ResourceBundleViewResolver.loadView(ResourceBundleViewResolver.java:186)
    org.springframework.web.servlet.view.AbstractCachingViewResolver.createView(AbstractCachingViewResolver.java:159)
    org.springframework.web.servlet.view.AbstractCachingViewResolver.resolveViewName(AbstractCachingViewResolver.java:78)
    org.springframework.web.servlet.DispatcherServlet.resolveViewName(DispatcherServlet.java:1205)
    org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1154)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:901)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
cause mère

java.lang.ClassCastException: cannot assign instance of net.sf.jasperreports.engine.base.JRBaseStyle to field net.sf.jasperreports.engine.base.JRBaseParagraph.paragraphContainer of type net.sf.jasperreports.engine.JRParagraphContainer in instance of net.sf.jasperreports.engine.base.JRBaseParagraph
    java.io.ObjectStreamClass$FieldReflector.setObjFieldValues(ObjectStreamClass.java:2063)
    java.io.ObjectStreamClass.setObjFieldValues(ObjectStreamClass.java:1241)
    java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1995)
    java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1913)
    java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1796)
    java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1348)
    java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1989)
    java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:499)
    net.sf.jasperreports.engine.base.JRBaseStyle.readObject(JRBaseStyle.java:1429)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:601)
    java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1004)
    java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1891)
    java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1796)
    java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1348)
    java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1989)
    java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1913)
    java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1796)
    java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1348)
    java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
    java.util.ArrayList.readObject(ArrayList.java:733)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:601)
    java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1004)
    java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1891)
    java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1796)
    java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1348)
    java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1989)
    java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1913)
    java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1796)
    java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1348)
    java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1989)
    java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1913)
    java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1796)
    java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1348)
    java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
    net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:192)
    org.springframework.web.servlet.view.jasperreports.AbstractJasperReportsView.loadReport(AbstractJasperReportsView.java:516)
    org.springframework.web.servlet.view.jasperreports.AbstractJasperReportsView.loadReport(AbstractJasperReportsView.java:498)
    org.springframework.web.servlet.view.jasperreports.AbstractJasperReportsView.initApplicationContext(AbstractJasperReportsView.java:327)
    org.springframework.context.support.ApplicationObjectSupport.initApplicationContext(ApplicationObjectSupport.java:119)
    org.springframework.web.context.support.WebApplicationObjectSupport.initApplicationContext(WebApplicationObjectSupport.java:69)
    org.springframework.context.support.ApplicationObjectSupport.setApplicationContext(ApplicationObjectSupport.java:73)
    org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:70)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:350)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1329)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:471)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    java.security.AccessController.doPrivileged(Native Method)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
    org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:220)
    org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
    org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
    org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
    org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)
    org.springframework.web.servlet.view.ResourceBundleViewResolver.initFactory(ResourceBundleViewResolver.java:244)
    org.springframework.web.servlet.view.ResourceBundleViewResolver.loadView(ResourceBundleViewResolver.java:186)
    org.springframework.web.servlet.view.AbstractCachingViewResolver.createView(AbstractCachingViewResolver.java:159)
    org.springframework.web.servlet.view.AbstractCachingViewResolver.resolveViewName(AbstractCachingViewResolver.java:78)
    org.springframework.web.servlet.DispatcherServlet.resolveViewName(DispatcherServlet.java:1205)
    org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1154)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:901)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note La trace complète de la cause mère de cette erreur est disponible dans les fichiers journaux de Apache Tomcat/6.0.36.

Apache Tomcat/6.0.36

I have not been able to solve this problem for a week. Please help me.


Answer:

Thank you for your help. You're right, but I only add a single version of jasperreport in the classpath.

To solve the problem I copy all required libraries from the ireport installation folder to the lib folder and the error disappeared.

commons-beanutils-1.8.2.jar
commons-collections-3.2.1.jar
commons-dbcp-1.2.2.jar
commons-digester-1.7.jar
commons-logging-1.1.jar
commons-pool-1.3.jar
hsqldb-1.8.0-10.jar
iText-2.1.7.jar
jasperreports-4.0.1.jar
jasperreports-chart-themes-4.0.1.jar
jasperreports-extensions-3.5.3.jar
jasperreports-fonts-4.0.1.jar

Question:

I created one Java program and create jar file for that program in the program class name is DateFormate and static method is demo()

Then added that jar file to iReport file then i call that static method as

new com.it.DateFormate.demo()

then this error raised:

com.it.DateFormate cannot be resolved to a type

Answer:

If it is a static method the call will be

com.it.DateFormate.demo()

Hence, no new

To make it work the class needs to be in classpath, if you like it to work inside of your IDE make sure you add a jar (to the IDE) that contains this class.

Question:

I am working on a Java Swing project that prints small cards on A4 size paper.

  • Data Source is : Table Model Data Source.
  • iReport version : 2.0.3

I want to print cards grid in the paper. I deleted other columns without details columns and Added field COLUMN_1 drop it into details column.

It successfully prints my values vertically like this, It means Java Code parses all values and parameters as expected.

  • AA
  • BB
  • CC
  • DD
  • EE
  • FF

But I want to print it like a grid with three columns.

  • AA | BB | CC
  • DD | EE | FF

I think this is adjusted to be in the report. Any idea how to do this? any suggestions would be appreciated, Thanks.


Answer:

Set Column Count = 3 in your jrxml template.