Question

I'm try to create chart with JasperReports and DynamicJasper API looking at Bar3DChartBuilderTest site.

But my code throw exception :

java.lang.ClassNotFoundException: Integer.class.getName()
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Unknown Source)
ar.com.fdvs.dj.core.layout.AbstractLayoutManager.registerChartVariable(AbstractLayoutManager.java:1181)
ar.com.fdvs.dj.core.layout.AbstractLayoutManager.createChart(AbstractLayoutManager.java:1143)
ar.com.fdvs.dj.core.layout.AbstractLayoutManager.layoutCharts(AbstractLayoutManager.java:917)
ar.com.fdvs.dj.core.layout.AbstractLayoutManager.endLayout(AbstractLayoutManager.java:159)
ar.com.fdvs.dj.core.layout.ClassicLayoutManager.endLayout(ClassicLayoutManager.java:160)
ar.com.fdvs.dj.core.layout.AbstractLayoutManager.applyLayout(AbstractLayoutManager.java:106)
ar.com.fdvs.dj.core.DynamicJasperHelper.generateJasperReport(DynamicJasperHelper.java:555)
ar.com.fdvs.dj.core.DynamicJasperHelper.generateJasperReport(DynamicJasperHelper.java:533)
com.ay.ireport.DynamicJasperTemplate.buildReport(DynamicJasperTemplate.java:62)
org.apache.jsp.checkboxes_jsp._jspService(checkboxes_jsp.java:124)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

Please help me to solve this problem.

I try to create chart dynamically from user choose.

public void buildReport(String a[]) throws Exception{
    int i=0;
    List<Object> dt=getDataType(a,tname);
    for(int k= 0;k<dt.size();k++)
        System.out.println(dt.get(k));
    String query = createQuery(a,this.tname);
    //Create report layout
    DynamicReport dr = buildReportLayout(a,dt);

    JRDataSource ds = getDataSource(a, query);
    //Exception line
    JasperReport jr = DynamicJasperHelper.generateJasperReport(dr, new ClassicLayoutManager(), null);
    JasperPrint jp = JasperFillManager.fillReport(jr, null, ds);

    //JasperDesignViewer.viewReportDesign(DynamicJasperHelper.generateJasperReport(dr, new ClassicLayoutManager(),null));


    JasperExportManager.exportReportToPdfFile(jp,"C:/report-out.pdf");

}

private DynamicReport buildReportLayout(String[] a,List dtt) {
    DynamicReportBuilder  drb = new DynamicReportBuilder ();

    Font font = new Font(10,"Serif",true);
    Style headerStyle = new Style();
    headerStyle.setFont(font);
    headerStyle.setHorizontalAlign(HorizontalAlign.LEFT);
    headerStyle.setVerticalAlign(VerticalAlign.MIDDLE);

    font = new Font(8,"Serif",false);
    Style detailStyle = new Style();
    detailStyle.setFont(font);
    detailStyle.setHorizontalAlign(HorizontalAlign.LEFT);
    detailStyle.setVerticalAlign(VerticalAlign.MIDDLE);

    Object obj="NUMBER";
    Object obj1="VARCHAR2";
    String type = null;
    for(i=0; i<a.length; i++) {

        if(dtt.get(i).equals(obj)){
            type="Integer.class.getName()";
        }
        else if(dtt.get(i).equals(obj1)){
            type="String.class.getName()";
        }

        AbstractColumn col = ColumnBuilder.getNew()
                .setColumnProperty(a[i],type)
                .setTitle(a[i]).setWidth(200)
                .setStyle(detailStyle)
                .setHeaderStyle(headerStyle)
                .build();
                drb.addColumn(col); 
    }       
    drb.setUseFullPageWidth(true);


    DJAxisFormat categoryAxisFormat = new DJAxisFormat("category");
            categoryAxisFormat.setLabelFont(Font.ARIAL_SMALL);
            categoryAxisFormat.setLabelColor(Color.DARK_GRAY);
            categoryAxisFormat.setTickLabelFont(Font.ARIAL_SMALL);
            categoryAxisFormat.setTickLabelColor(Color.DARK_GRAY);
            categoryAxisFormat.setTickLabelMask("");
            categoryAxisFormat.setLineColor(Color.DARK_GRAY);

            DJAxisFormat valueAxisFormat = new DJAxisFormat("value");
            valueAxisFormat.setLabelFont(Font.ARIAL_SMALL);
            valueAxisFormat.setLabelColor(Color.DARK_GRAY);
            valueAxisFormat.setTickLabelFont(Font.ARIAL_SMALL);
            valueAxisFormat.setTickLabelColor(Color.DARK_GRAY);
            valueAxisFormat.setTickLabelMask("#,##0.0");
            valueAxisFormat.setLineColor(Color.DARK_GRAY);

            DJChart djChart = new DJBar3DChartBuilder()
                //chart     
                .setX(20)
                .setY(10)
                .setWidth(500)
                .setHeight(250)
                .setCentered(false)
                .setBackColor(Color.LIGHT_GRAY)
                .setShowLegend(true)
                .setPosition(DJChartOptions.POSITION_FOOTER)
                .setTitle("Bosum")
                .setTitleColor(Color.DARK_GRAY)
                .setTitleFont(Font.ARIAL_BIG_BOLD)
                .setSubtitle("subtitle")
                .setSubtitleColor(Color.DARK_GRAY)
                .setSubtitleFont(Font.COURIER_NEW_BIG_BOLD)
                .setLegendColor(Color.DARK_GRAY)
                .setLegendFont(Font.COURIER_NEW_MEDIUM_BOLD)
                .setLegendBackgroundColor(Color.WHITE)
                .setLegendPosition(DJChartOptions.EDGE_BOTTOM)
                .setTitlePosition(DJChartOptions.EDGE_TOP)
                .setLineStyle(DJChartOptions.LINE_STYLE_DOTTED)
                .setLineWidth(1)
                .setLineColor(Color.DARK_GRAY)
                .setPadding(5)
                //dataset
                .setOrientation(PlotOrientation.VERTICAL)
                .setCategory((PropertyColumn)drb.getColumn(2))
                .addSerie(drb.getColumn(0))
                //plot
                .setXOffset(10)
                .setyOffset(10)
                .setShowLabels(false)
                .setCategoryAxisFormat(categoryAxisFormat)
                .setValueAxisFormat(valueAxisFormat)
                .build();
            drb.addChart(djChart);

            System.out.println("vvvvvvvvvvvvvvvvv0");
            DynamicReport dr = drb.build();
    return dr;
}
Was it helpful?

Solution

DJchart.getColumn().getValueClassNameForExpression()

is passed with NULL value. You need check inside your DJReport. It internally creates DJChart.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top