CogComp / saul

Saul : Declarative Learning-Based Programming
Other
64 stars 18 forks source link

Error when running classifier test #365

Closed Rahgooy closed 8 years ago

Rahgooy commented 8 years ago

edu.illinois.cs.cogcomp.saul.util.Logging assumes that the org.slf4j.Logger implementation is ch.qos.logback.classic.Logger, which is in contrast with the whole point of the interface.

Here is the explanation from http://www.slf4j.org/codes.html#multiple_bindings :

Embedded components such as libraries or frameworks should not declare a dependency on any SLF4J binding but only depend on slf4j-api. When a library declares a compile-time dependency on a SLF4J binding, it imposes that binding on the end-user, thus negating SLF4J's purpose. When you come across an embedded component declaring a compile-time dependency on any SLF4J binding, please take the time to contact the authors of said component/library and kindly ask them to mend their ways.

Because there is multiple dependencies, when running Saul applications, I get warning about multiple bindings:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/taher/.ivy2/cache/org.slf4j/slf4j-log4j12/jars/slf4j-log4j12-1.7.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/taher/.ivy2/cache/ch.qos.logback/logback-classic/jars/logback-classic-1.1.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
01:19:44 INFO  SpRLApp$:39 - Loading default configuration parameters

the selection is almost random:

The warning emitted by SLF4J is just that, a warning. Even when multiple bindings are present, SLF4J will pick one logging framework/implementation and bind with it. The way SLF4J picks a binding is determined by the JVM and for all practical purposes should be considered random. As of version 1.6.6, SLF4J will name the framework/implementation class it is actually bound to.

and if the one that selected is org.slf4j.impl.Log4jLoggerFactory , then I get this error when I run a classifier test:

Exception in thread "main" java.lang.ClassCastException: org.slf4j.impl.Log4jLoggerAdapter cannot be cast to ch.qos.logback.classic.Logger
    at edu.illinois.cs.cogcomp.saul.util.Logging$loggerConfig$Logger.<init>(Logging.scala:81)
    at edu.illinois.cs.cogcomp.saul.classifier.Learnable.test(Learnable.scala:295)
    at edu.illinois.cs.cogcomp.saul.classifier.Learnable.test(Learnable.scala:290)
    at edu.illinois.cs.cogcomp.saul.classifier.Learnable.test(Learnable.scala:271)
    at edu.illinois.cs.cogcomp.saulexamples.nlp.SpatialRoleLabeling.SpRLApp$.runClassifier(SpRLApp.scala:70)
    at edu.illinois.cs.cogcomp.saulexamples.nlp.SpatialRoleLabeling.SpRLApp$.delayedEndpoint$edu$illinois$cs$cogcomp$saulexamples$nlp$SpatialRoleLabeling$SpRLApp$1(SpRLApp.scala:49)
    at edu.illinois.cs.cogcomp.saulexamples.nlp.SpatialRoleLabeling.SpRLApp$delayedInit$body.apply(SpRLApp.scala:22)
    at scala.Function0$class.apply$mcV$sp(Function0.scala:34)
    at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
    at scala.App$$anonfun$main$1.apply(App.scala:76)
    at scala.App$$anonfun$main$1.apply(App.scala:76)
    at scala.collection.immutable.List.foreach(List.scala:381)
    at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:35)
    at scala.App$class.main(App.scala:76)
    at edu.illinois.cs.cogcomp.saulexamples.nlp.SpatialRoleLabeling.SpRLApp$.main(SpRLApp.scala:22)
    at edu.illinois.cs.cogcomp.saulexamples.nlp.SpatialRoleLabeling.SpRLApp.main(SpRLApp.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
danyaljj commented 8 years ago

I'll have a look during during weekend.

kordjamshidi commented 8 years ago

ok, thanks @danyaljj. Meanwhile @Rahgooy feel free to make a PR if you have any suggestions to fix this. This does not allow us to run some experiments now.