Weird java.lang.ExceptionInInitializerError JSoup

In my newest Project I use JSoup to retrieve a Webpage, get all Elements with the class ".heads" and then save specific parts of it to a file. When I run it, I get this error:

java.lang.ExceptionInInitializerError
    at org.jsoup.nodes.Entities$EscapeMode.<clinit>(Entities.java:19) ~[?:?]
    at org.jsoup.nodes.Document$OutputSettings.<init>(Document.java:373) ~[?:?]
    at org.jsoup.nodes.Document.<init>(Document.java:18) ~[?:?]
    at org.jsoup.parser.TreeBuilder.initialiseParse(TreeBuilder.java:29) ~[?:?]
    at org.jsoup.parser.TreeBuilder.parse(TreeBuilder.java:42) ~[?:?]
    at org.jsoup.parser.HtmlTreeBuilder.parse(HtmlTreeBuilder.java:53) ~[?:?]
    at org.jsoup.parser.Parser.parseInput(Parser.java:30) ~[?:?]
    at org.jsoup.helper.DataUtil.parseByteData(DataUtil.java:94) ~[?:?]
    at org.jsoup.helper.HttpConnection$Response.parse(HttpConnection.java:603) ~[?:?]
    at org.jsoup.helper.HttpConnection.get(HttpConnection.java:195) ~[?:?]
    at de.zbs.advancedheads.main.AdvancedHeads.downloadDatabase(AdvancedHeads.java:48) ~[?:?]
    at de.zbs.advancedheads.main.AdvancedHeads.onEnable(AdvancedHeads.java:33) ~[?:?]
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-fdc1440-53fac9f]
    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-fdc1440-53fac9f]
    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-fdc1440-53fac9f]
    at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:357) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-fdc1440-53fac9f]
    at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:317) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-fdc1440-53fac9f]
    at org.bukkit.craftbukkit.v1_8_R3.CraftServer.reload(CraftServer.java:741) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-fdc1440-53fac9f]
    at org.bukkit.Bukkit.reload(Bukkit.java:535) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-fdc1440-53fac9f]
    at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:25) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-fdc1440-53fac9f]
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-fdc1440-53fac9f]
    at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-fdc1440-53fac9f]
    at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchServerCommand(CraftServer.java:627) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-fdc1440-53fac9f]
    at net.minecraft.server.v1_8_R3.DedicatedServer.aO(DedicatedServer.java:412) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-fdc1440-53fac9f]
    at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:375) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-fdc1440-53fac9f]
    at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:653) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-fdc1440-53fac9f]
    at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:556) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-fdc1440-53fac9f]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_73]
Caused by: java.lang.NullPointerException
    at java.util.Properties$LineReader.readLine(Unknown Source) ~[?:1.8.0_73]
    at java.util.Properties.load0(Unknown Source) ~[?:1.8.0_73]
    at java.util.Properties.load(Unknown Source) ~[?:1.8.0_73]
    at org.jsoup.nodes.Entities.loadEntities(Entities.java:236) ~[?:?]
    at org.jsoup.nodes.Entities.<clinit>(Entities.java:220) ~[?:?]
    ... 28 more

My Code is the following:

private boolean downloadDatabase() {
    new File(path).mkdirs();
    try {
        Document doc = Jsoup.connect("http://heads.freshcoal.com/maincollection.php").get();
        Elements head = doc.select(".heads");
        System.out.println(head);
        for (Element e : head) {
            Attributes att = e.attributes();
            System.out.println(att);
            String command = att.get("data-clipboard-text");
            System.out.println(command);
            String remover = command.replace("/give @p skull 1 3 {display:{Name:\"", "");
            String name = remover.substring(0, 5);
            Bukkit.broadcastMessage(name);
            String texture = remover.substring(30, 50);
            Bukkit.broadcastMessage(texture);
        }
        return true;
    } catch (IOException e) {
        e.printStackTrace();
        return false;
    }
}

Yes, I already checked wether the jsoup library is installed, I didn't know how to make it a library so I just took the sources of it and put it into my project.

Thanks for any help in advance!

Jon Skeet
people
quotationmark

The problem is what you've done with the library, basically. You don't need to make it a library - you just download it as a jar file and put that in your classpath.

It looks like you've included the source, but you haven't included the properties files which are assumed to be available - in this case, entities-base.properties. You're getting a NullPointerException because Entities.class.getResourceAsStream(filename) is returning null. While there are no doubt ways of fixing this with your "just include the source" approach, you really, really should just use the prepackaged jar file.

people

See more on this question at Stackoverflow