The Burp Suite User Forum was discontinued on the 1st November 2024.

Burp Suite User Forum

For support requests, go to the Support Center. To discuss with other Burp users, head to our Discord page.

SUPPORT CENTER DISCORD

Importing external JFreeChart library - ClassNotFoundException

Nadia | Last updated: Jun 16, 2023 08:34PM UTC

Hi, I'm developing a Burp extension in Montoya, and I'm using the external JFreeChart library to implement some graphing functionality. I have added it as a dependency in the following way: In the project build.gradle file: dependencies { implementation 'net.portswigger.burp.extensions:montoya-api:2023.5' implementation fileTree(dir: 'libs', include: ['*.jar']) } In the libs folder (contained in the same folder as the build.gradle file): jcommon-1.0.24.jar jfreechart-1.5.2.jar In the Burp extension Java class: import org.jfree.chart.*; import org.jfree.data.*; import org.jfree.data.statistics.HistogramDataset; And in the code: HistogramDataset dataset = new HistogramDataset(); double[] values1 = responseTimes1.stream().mapToDouble(Long::doubleValue).toArray(); double[] values2 = responseTimes2.stream().mapToDouble(Long::doubleValue).toArray(); dataset.addSeries("Dataset 1", values1, 10); dataset.addSeries("Dataset 2", values2, 10); JFreeChart chart = ChartFactory.createHistogram( "Histogram", // Chart title "Values", // X-axis label "Frequency", // Y-axis label dataset // Dataset ); The project builds successfully in Gradle and shows no dependency issues, but when I import into Burp I immediately get the error: java.lang.ClassNotFoundException: org.jfree.data.xy.IntervalXYDataset at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) at example.contextmenu.ContextMenu$MySuiteTab.<init>(ContextMenu.java:222) at example.contextmenu.ContextMenu.initialize(ContextMenu.java:65) I'm wondering why this is happening. Is there a different way to import external libraries in Burp? Note that I'm not specifically referencing functions from the IntervalXYDataset interface. Importing org.jfree.data.xy.IntervalXYDataset in the .java class file does not solve the error. Thank you for your help!

Hannah, PortSwigger Agent | Last updated: Jun 19, 2023 08:52AM UTC

Hi

Are you packaging all of the libraries into your JAR?

Can you include the following in your "build.gradle" file and run this task? Does it then load into Burp appropriately?
task fatJar(type: Jar) {
    from { configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
    with jar
}

Nadia | Last updated: Jun 19, 2023 01:37PM UTC

Hi Hannah, I already have the fatJar... lines in my build.gradle file, and I still get the same error. It's interesting that I am able to use other external classes, such as org.jfree.data.statistics.HistogramDataset - the code specifically fails when trying to create a new JFreeChart as above. In regards to packaging the libraries into my .jar, is the fatJar... section of build.gradle sufficient to do this? Thank you!

Hannah, PortSwigger Agent | Last updated: Jun 21, 2023 08:52AM UTC