Search code examples
javanlpcrfstanford-nlp

NER CRF, Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory


I have downloaded the latest version for NER from this link. Then after extracting it, I have run this command.

java -cp stanford-ner.jar edu.stanford.nlp.ie.crf.CRFClassifier -prop austen.prop

This is not working and getting following exception.

CRFClassifier invoked on Mon Jul 25 06:56:22 EDT 2016 with arguments:
   -prop austen.prop
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
    at edu.stanford.nlp.io.IOUtils.<clinit>(IOUtils.java:42)
    at edu.stanford.nlp.util.StringUtils.argsToProperties(StringUtils.java:942)
    at edu.stanford.nlp.util.StringUtils.argsToProperties(StringUtils.java:891)
    at edu.stanford.nlp.ie.crf.CRFClassifier.main(CRFClassifier.java:2994)
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 sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 4 more

In the folder, stanford-ner-2015-12-09 there is another folder lib, it already contains slf4j libraries but still it is not executing above command. I just downloaded and then extracted files and run that command to make a model but this exception is coming. I will be thankful to you if you can help me.


Solution

  • Can you try

    UNIX:

    java -cp stanford-ner.jar:lib/*:. edu.stanford.nlp.ie.crf.CRFClassifier -prop austen.prop
    

    Windows:

    java -cp stanford-ner.jar;lib/*;. edu.stanford.nlp.ie.crf.CRFClassifier -prop austen.prop