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

NoSuchMethodError in jasper report after importing a jar file


ishanisamaraweera

Recommended Posts

I have added a jar file to add a chart customizer class in my jasper report. But when compiling it gives the NoSuchMethodError. I have added enough libraries to the classpath and I am using jasperreports-6.5.1 and jfreechart-1.5.0.

Jasper exception:

java.lang.NoSuchMethodError: org.jfree.chart.title.LegendTitle.setItemLabelPadding(Lorg/jfree/chart/ui/RectangleInsets;)V null java.lang.NoSuchMethodError: org.jfree.chart.title.LegendTitle.setItemLabelPadding(Lorg/jfree/chart/ui/RectangleInsets;)V

Source code in the jar file:

public class ChartCustomizer extends JRAbstractChartCustomizer {DecimalFormat twoPlaces = new DecimalFormat("0.00");@Overridepublic void customize(JFreeChart jFreeChart, JRChart jrChart) {    if (jFreeChart.getPlot().getClass().equals(PiePlot3D.class)) {        formatPiePlot3D((PiePlot3D) jFreeChart.getPlot());                } else if (jFreeChart.getPlot().getClass().equals(PiePlot.class)) {        formatPiePlot((PiePlot) jFreeChart.getPlot());    }    LegendTitle legend = jFreeChart.getLegend();    legend.setItemLabelPadding(new RectangleInsets(2, 2, 2, 999999999));}private void formatPiePlot3D(PiePlot3D plot) {    PieSectionLabelGenerator labelGenerator = new StandardPieSectionLabelGenerator("{2}", new DecimalFormat("0"), new DecimalFormat("0.00%"));    PieSectionLabelGenerator legendGenerator = new StandardPieSectionLabelGenerator("{0} - {1}", new DecimalFormat("#,##0.00", new DecimalFormatSymbols(new Locale("en_US"))), new DecimalFormat("0%"));    plot.setLegendLabelGenerator(legendGenerator);    plot.setLabelGenerator(labelGenerator);}private void formatPiePlot(PiePlot plot) {    PieSectionLabelGenerator labelGenerator = new StandardPieSectionLabelGenerator("{2}", new DecimalFormat("0"), new DecimalFormat("0.00%"));    PieSectionLabelGenerator legendGenerator = new StandardPieSectionLabelGenerator("{0} - {1}", new DecimalFormat("#,##0.00", new DecimalFormatSymbols(new Locale("en_US"))), new DecimalFormat("0%"));    plot.setLegendLabelGenerator(legendGenerator);    plot.setLabelGenerator(labelGenerator);} }[/code]

Libraries imported to the jar file source and classpath:

jcommon-1.0.24 jfreechart-1.5.0 jasperreports-6.5.1 jfreesvg-3.3

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

  • 11 months later...
  • 10 months 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...