Question

I want to use the Jodd library in java because I want to try Jerry out. To do that I've included the library like shown in the answer to this question and used the following code:

File file = new File(SystemUtil.getTempDir(), "test.html");
NetUtil.downloadFile("http://de.wikipedia.org/wiki/Toastbrot", file);
Jerry doc = Jerry.jerry(FileUtil.readString(file));

Executing this code produces the following error message:

 Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
      at jodd.lagarto.LagartoParserEngine.<clinit>(LagartoParserEngine.java:22)
      at jodd.jerry.Jerry$JerryParser.createLagartoDOMBuilder(Jerry.java:80)
      at jodd.jerry.Jerry$JerryParser.<init>(Jerry.java:73)
      at jodd.jerry.Jerry.jerry(Jerry.java:121)
      at jodd.jerry.Jerry.jerry(Jerry.java:53)
      at sla.htmlf.Main.test(Main.java:36)
      at sla.htmlf.Main.main(Main.java:19)
    Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
      at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
      at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:334)
      ... 7 more

at sla.htmlf.Main.test(Main.java:36) at sla.htmlf.Main.main(Main.java:19) of course is referring to classes of my project

This is the first time I encountered a NoClassDefFound exception. It appears that org.slf4j.LoggerFactory is missing, but if I'm not mistaken thats something the jodd library uses - which then should be included there, right?

I'd really appreciate some advice/help with this

Was it helpful?

Solution

As you can see on the download page, jodd-lagarto module (that Jerry belongs to) depends on SLF4J logging library.

Please read more about logging in Jodd. On this page you can also find some quick steps to setup your environment and make it work.

These steps are:

  • Go to http://www.slf4j.org/download.html and download SLF4J distribution package.
  • Put slf4j-api-X.X.X.jar on the classpath
  • If you don't want any logging, just put slf4j-nop-X.X.X.jar on the classpath.
  • Otherwise, go to http://logback.qos.ch/download.html and download LOGback distribution package.
  • Put logback-core.jar and logback-classic.jar on the classpath.

With SLF4J you can choose logging framework you want to use: none, log4j, commons etc; Jodd authors recommend logback.

OTHER TIPS

Looks like you are missing the slf4j library which is being referenced by one of the other libs.

Add slf4j-api-1.7.2.jar to your classpath.

Download: http://www.slf4j.org/dist/slf4j-1.7.2.zip

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