dmnapolitano / stanford-thrift

A Stanford CoreNLP server, with example clients, using Apache Thrift.
47 stars 8 forks source link

Class "org.apache.thrift.TApplicationException" not found? #27

Open tabidots opened 9 years ago

tabidots commented 9 years ago

Hello,

I'm familiar with CoreNLP but new to Thrift. I'm having problems getting Thrift to work.

I'm running Yosemite and was not able to compile Thrift manually, so I installed v.0.9.2 using MacPorts.

With Thrift and Log4J installed, I got this error: (specifying JAVA_HOME because I had to install Java 1.8 just for this)

Justins-MacBook-Pro:scripts justin$ JAVA_HOME=$(/usr/libexec/java_home -v 1.8) ./start_server.sh 5000 3g config ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console. Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/thrift/TApplicationException at org.ets.research.nlp.stanford_thrift.StanfordCoreNLPServer.main(Unknown Source) Caused by: java.lang.ClassNotFoundException: org.apache.thrift.TApplicationException 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) ... 1 more

I then downloaded all the rest of the JARs listed in the Requirements section and put them in my $CLASSPATH (/Library/Java/Extensions), but I still get the same error.

What else do I need to do?

dmnapolitano commented 9 years ago

Hello! Sorry about the trouble. :confused: (Also sorry for the Java 1.8 requirement; that actually comes from the CoreNLP folks.) Would you be willing to share your $CLASSPATH with me, at least the relevant parts? Then I'll compare what I have here. Thanks. :smile:

tabidots commented 9 years ago

Thanks for the fast response :)

Not really sure if I'm doing this right - originally I had it set to /Library/Java/Extensions. Then I realized it wasn't actually doing anything with the files inside the folder. So right now my $CLASSPATH is set to /Library/Java/Extensions/*.

Justins-MacBook-Pro:scripts justin$ echo $CLASSPATH
/Library/Java/Extensions/commons-cli-1.2.jar /Library/Java/Extensions/commons-codec-1.10.jar /Library/Java/Extensions/commons-lang3-3.4.jar /Library/Java/Extensions/commons-logging-1.2.jar /Library/Java/Extensions/ejml-0.23.jar /Library/Java/Extensions/fluent-hc-4.5.jar /Library/Java/Extensions/hamcrest-core-1.3.jar /Library/Java/Extensions/httpclient-4.5.jar /Library/Java/Extensions/httpclient-cache-4.5.jar /Library/Java/Extensions/httpclient-win-4.5.jar /Library/Java/Extensions/httpcore-4.4.1.jar /Library/Java/Extensions/httpcore-ab-4.4.1.jar /Library/Java/Extensions/httpcore-nio-4.4.1.jar /Library/Java/Extensions/httpmime-4.5.jar /Library/Java/Extensions/jna-4.1.0.jar /Library/Java/Extensions/jna-platform-4.1.0.jar /Library/Java/Extensions/joda-time.jar /Library/Java/Extensions/jollyday.jar /Library/Java/Extensions/junit-4.12.jar /Library/Java/Extensions/log4j-1.2-api-2.3.jar /Library/Java/Extensions/log4j-api-2.3.jar /Library/Java/Extensions/log4j-core-2.3.jar /Library/Java/Extensions/servlet-api-3.0-alpha-1.jar /Library/Java/Extensions/slf4j-api-1.7.12.jar /Library/Java/Extensions/slf4j-jdk14-1.7.12.jar /Library/Java/Extensions/slf4j-log4j12-1.7.12.jar /Library/Java/Extensions/stanford-corenlp-3.4.1-models.jar /Library/Java/Extensions/stanford-corenlp-3.4.1.jar /Library/Java/Extensions/xom.jar

Also, from what you said about the Java 1.8 req, I assume that the wrapper assumes CoreNLP 3.5.0+ by default? I know I'm using JARs from an older version, but even then it doesn't seem to be getting past the TApplicationException issue. (And just out of curiosity, would it be possible to use an older version?)

dmnapolitano commented 9 years ago

Hi again, thanks for sharing this information! I might be missing it, but I think your $CLASSPATH doesn't have the Thrift JAR on it. I have one here (slightly older version of Thrift but I have used this wrapper with the latest one) like libthrift-0.9.0.jar.

This wrapper has been in development for a while now and used with several different versions of CoreNLP with extremely little modification. So I think the version you have should be fine, so you can stick to Java < 1.8 if you wish. :+1:

tabidots commented 9 years ago

Brilliant, thanks! :+1: Glad it turned out to be something as simple as that.

Now it's giving me this:

Loading parser from serialized file edu/stanford/nlp/models/srparser/englishSR.ser.gz ... edu.stanford.nlp.io.RuntimeIOException: java.io.IOException: Unable to resolve "edu/stanford/nlp/models/srparser/englishSR.ser.gz" as either class path, filename or URL

I have commented out the Shift-Reduce line in the config file for now, but if I want to add it, how would I do that?

tabidots commented 9 years ago

One more thing — I'm running through the test scripts and the parser, tagger, and tokenizer are good to go, which is pretty exciting. But when I run coref_client and ner_client, I wait and wait and... no response from the server. When I hit Ctrl+C, I get this:

Traceback (most recent call last): File "coref_client.py", line 50, in <module> result = client.resolve_coreferences_in_trees(trees) File "build/bdist.macosx-10.6-intel/egg/corenlp/StanfordCoreNLP.py", line 486, in resolve_coreferences_in_trees File "build/bdist.macosx-10.6-intel/egg/corenlp/StanfordCoreNLP.py", line 497, in recv_resolve_coreferences_in_trees File "build/bdist.macosx-10.6-intel/egg/thrift/protocol/TBinaryProtocol.py", line 126, in readMessageBegin File "build/bdist.macosx-10.6-intel/egg/thrift/protocol/TBinaryProtocol.py", line 206, in readI32 File "build/bdist.macosx-10.6-intel/egg/thrift/transport/TTransport.py", line 58, in readAll File "build/bdist.macosx-10.6-intel/egg/thrift/transport/TTransport.py", line 159, in read File "build/bdist.macosx-10.6-intel/egg/thrift/transport/TSocket.py", line 105, in read

I assume the communication between server & client is handled identically across all test scripts, so I'm not sure what could be happening here. Any ideas?

dmnapolitano commented 9 years ago

Hello again! Sorry for the delayed response this time. :confused:

As to your first question, you'll need to include the JAR containing the shift-reduce model(s) on your $CLASSPATH. You can get it from http://nlp.stanford.edu/software/srparser.shtml but I'm not entirely sure how to find older versions of the JAR.

As to your other question, unfortunately I am experiencing the same thing here. I'm thinking I modified coref and ner but forgot to modify the clients, which is weird because those scripts are how I test each service. I apologize and I'll try to look into this today. :confused:

tabidots commented 9 years ago

Thanks again. Any word on the NER issue?