-1

I cannot figure what is causing this error (causing no compile). I am following the absolute most simple example on the front webpage:

http://sparkjava.com/documentation.html

I receive this error.

I have spent a long amount of time trying things myself, I have learnt to get Maven running so have got the same problem now with Netbeans, Eclipse, versions of spark 2.4 and 2.5

Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at spark.Service.<clinit>(Service.java:47)
at spark.Spark$SingletonHolder.<clinit>(Spark.java:49)
at spark.Spark.getInstance(Spark.java:53)
at spark.Spark.<clinit>(Spark.java:59)
at MavenTest01.main(MavenTest01.java:20)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 5 more
P.J.Meisch
  • 18,013
  • 6
  • 50
  • 66
Richard
  • 135
  • 2
  • 11

1 Answers1

1

You need a dependency to the slf4j api in your project. In maven:

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.21</version>
        <scope>compile</scope>
    </dependency>
P.J.Meisch
  • 18,013
  • 6
  • 50
  • 66