Jump to content
We've recently updated our Privacy Statement, available here ×

Can\'t generate report in jdeveloper


jluix

Recommended Posts

Hi! This is my first post in this forum.

I'd appreciate a lot a bit of help.

I've been trying to create my first testing bean based report using jasper+ireport under jdeveloper for a while.

This is the report I've prepared:

<?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="report4" language="groovy" pageWidth="792" pageHeight="612" orientation="Landscape" columnWidth="752" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <field name="nombre" class="java.lang.String"/>
    <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"/>
    </columnHeader>
    <detail>
        <band height="125" splitType="Stretch">
            <textField>
                <reportElement x="107" y="37" width="100" height="20"/>
                <textElement/>
                <textFieldExpression class="java.lang.String"><$F{nombre}></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>

 

I've developed this pojo bean class:

      public class Persona{
         
          private String nombre;
         
          public Persona(String pnombre){
            nombre=pnombre;
          }

            public void setNombre(String nombre) {
                this.nombre = nombre;
            }

            public String getNombre() {
                return nombre;
            }
        }
 

---

After this, I've used the next code inside my program:

 

     ArrayList al = new ArrayList();
     al.add(new Persona("Pedro"));
     al.add(new Persona("Juan"));

     JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(al,false);     

        try {
            JasperReport jasperReport = JasperCompileManager.compileReport("~/report4.jrxml");
            JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, new HashMap(),ds);
            JasperExportManager.exportReportToPdfFile(jasperPrint, "~/report4.pdf");
        } catch (JRException e) {
            System.out.println("error ");
        }

When executing this code, at the line marked in yellow, jdeveloper throws an exception saying:

 

Unknown property nombre.

Error retrieving field value from bean : nombre

I've look on the Internet (and I've tried a lot of things) but I haven't found any solution to this. I'm getting mad.

Please, Help me.

 

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...