• 5 Subscribers

I added JFreeChart as a dependency for my program, and I'm trying to generate a chart with it. Problem is that everytime I try to create the chart, JFreeChart throws me this error

    at org.jfree.chart.ChartFactory.createPieChart(ChartFactory.java:343) ~[?:?]
    at com.djrapitops.plan.ui.graphs.GMTimesPieChart_AWT.createChart(GMTimesPieChart_AWT.java:28) ~[?:?]
    at com.djrapitops.plan.utilities.AnalysisUtils.createPieChart(AnalysisUtils.java:15) ~[?:?]
    at com.djrapitops.plan.ui.DataRequestHandler.getDataHtml(DataRequestHandler.java:52) ~[?:?]
    at com.djrapitops.plan.ui.webserver.Response.sendStaticResource(Response.java:60) ~[?:?]
Caused by: java.util.MissingResourceException: Can't find bundle for base name org.jfree.chart.plot.LocalizationBundle, locale fi_FI
    at java.util.ResourceBundle.throwMissingResourceException(Unknown Source) ~[?:1.8.0_112]
    at java.util.ResourceBundle.getBundleImpl(Unknown Source) ~[?:1.8.0_112]
    at java.util.ResourceBundle.getBundle(Unknown Source) ~[?:1.8.0_112]
    at org.jfree.chart.util.ResourceBundleWrapper.getBundle(ResourceBundleWrapper.java:128) ~[?:?]
    at org.jfree.chart.plot.PiePlot.<clinit>(PiePlot.java:526) ~[?:?]
    ... 11 more

I have no idea how to fix it and I need some way to generate chart images to view on the webserver. Here is my code:

public static String createChart(HashMap<GameMode, Long> gmTimes, String uuid) {
    DefaultPieDataset dataset = new DefaultPieDataset();
    for (GameMode gm : gmTimes.keySet()) {
        dataset.setValue(gm.name(), gmTimes.get(gm));            
    JFreeChart chart = ChartFactory.createPieChart("Gamemode usage", dataset, true, false, false); // LINE 28
    int width = 480;
    int height = 360;
    Plan plugin = getPlugin(Plan.class);
    File pluginFolder = plugin.getDataFolder();
    File chartFolder = new File(pluginFolder+File.separator+"ChartImages");
    File chartImg = new File(pluginFolder+File.separator+"ChartImages", uuid+".jpeg");
    try {
        ChartUtilities.saveChartAsJPEG(chartImg, chart, width, height);
    } catch (IOException ex) {
    return chartImg.getAbsolutePath();

I am using maven assembly plugin to get the dependency to my jar. I don't need any locale functions for my use of JFreeCharts

Any alternatives or ways to fix this? Thanks :)

0 answers in total

Answer this questsion