Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialpyt bot
Java Web Development Techdegree Student 240 PointsI got an error! SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
I made sure the code was the exact same as the teacher had it. I can't figure out what I did wrong! :(
5 Answers
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 PointsCheck out the Spark Documentation about this problem (Logging section) : http://sparkjava.com/documentation.html#examples
There it says, how to deal with the problem very easily: to add slf4j-simple
logging library dependencies.
No need to go back to Spark 2.3 :)
harshahs
10,137 PointsTo make it work for version 2.5, you can add the following dependency in build.gradle file.
compile 'ch.qos.logback:logback-classic:1.1.7'
Karrtik Iyer
3,738 PointsYes, it worked for me after adding what harshahs has mentioned, but would want to understand why is it so? Isn't gradle supposed to download any transitive dependencies for spark-core, which would be logback-classic?
Blake Larson
13,014 PointsI added that and still get the same error.
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 PointsHi, Blake Larson
Please check out my answer below :
Check out the Spark Documentation about this problem (Logging section) : http://sparkjava.com/documentation.html#examples There it says, how to deal with the problem very easily: to add slf4j-simple logging library dependencies. No need to go back to Spark 2.3 :)
So your build.gradle
should look somewhat like this:
group 'com.teamtreehouse.courses'
version '1.0-SNAPSHOT'
apply plugin: 'java'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile 'com.sparkjava:spark-core:2.5'
// http://mvnrepository.com/artifact/org.slf4j/slf4j-simple
compile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.21'
// optional can be removed
testCompile group: 'junit', name: 'junit', version: '4.11'
}
Why do I insist on solving the problem this way?
Because it is official Spark Documentation solution. Nothing personal
pyt bot
Java Web Development Techdegree Student 240 PointsAfter a google search, I figured out that I needed to change compile 'com.sparkjava:spark-core:2.5' to compile 'com.sparkjava:spark-core:2.3'
markmneimneh
14,132 Pointsif you run into a binding error
[Thread-0] ERROR spark.embeddedserver.jetty.EmbeddedJettyServer - ignite failed java.net.BindException: Address already in use: bind at sun.nio.ch.Net.bind0(Native Method) at sun.nio.ch.Net.bind(Net.java:433) at sun.nio.ch.Net.bind(Net.java:425) at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
fireoff your task manager and check who is using port 4567
bascially, do this is a dos window netstat -anob | findstr "4567"
this will show you the process id
C:\WINDOWS\system32> netstat -anob | findstr "4567" TCP 0.0.0.0:4567 0.0.0.0:0 LISTENING 4184 TCP [::]:4567 [::]:0 LISTENING 4184
in my case PID is 4184
go to task manager and kill it.
then run your spark example
Chris Jones
Java Web Development Techdegree Graduate 23,933 PointsJust FYI for anyone looking at Mark's answer above - you'll need to run the cmd prompt as an administrator. Just right click on the cmd prompt tool and choose "Run as Administrator".
Rares Conea
Courses Plus Student 15,000 PointsHi, This question is old but if there is someone who still has this problem add before the get method this line: port(<a number that represent the port which you want to use>) Ex: port(8080)
Blake Larson
13,014 PointsBlake Larson
13,014 PointsThanks, that worked.
Rebekah Smith
7,263 PointsRebekah Smith
7,263 PointsThanks, this fix works for spark 2.6 too!