jflanigan / jamr

JAMR Parser and Generator
BSD 2-Clause "Simplified" License
193 stars 50 forks source link

Error: Could not find or load main class edu.cmu.lti.nlp.amr.CorpusTool #9

Closed hao-cheng closed 8 years ago

hao-cheng commented 8 years ago

After the compilation and split, I try to run PREPROCESS.sh and I got the above error. Does anyone have idea what the problem might be?

sammthomson commented 8 years ago

That seems like the $CLASSPATH environment variable is not being set right. This is usually set by sourcing one of the scripts/config* scripts, which usually gets done by one of the scripts/train* scripts. What are the exact commands you're running?

hao-cheng commented 8 years ago

Thanks for the quick response.

I try to train the parser on LDC2014T12. Here are the commands:

. scripts/config_ACL2014_LDC2014T12.sh
pushd scripts/preprocessing
LDC2014T12/make_splits.sh
./PREPROCESS.sh

The error appears when calling the following command

java -ea -Dfile.encoding=UTF-8 -XX:ParallelGCThreads=2 -Xmx4g -XX:+CMSClassUnloadingEnabled -cp .:${JAMR}/target/scala-2.10/jamr-assembly-0.1-SNAPSHOT.jar edu.cmu.lti.nlp.amr.CorpusTool --tokenized ${JAMR}/data/amr_anno_1.0/data/split/training/training.txt.snt.tok
Error: Could not find or load main class edu.cmu.lti.nlp.amr.CorpusTool
sammthomson commented 8 years ago

Have you run ./compile?

hao-cheng commented 8 years ago

Yes, I got two warnings but success in the end.

[warn] Merging 'META-INF\MANIFEST.MF' with strategy 'discard'
[warn] Strategy 'discard' was applied to a file
sammthomson commented 8 years ago

Those warnings should be harmless. I don't think we use the envvar $JAMR anywhere though, we use ${JAMR_HOME}.

hao-cheng commented 8 years ago

Sorry for the confuse. I just replace the actual path on my computer with ${JAMR}.

sammthomson commented 8 years ago

If you set -x, it will make bash echo back every command that is run, with env vars substituted. Can you do that, then verify that when you run the script, whatever ${JAMR}/target/scala-2.10/jamr-assembly-0.1-SNAPSHOT.jar expands to actually exists?

hao-cheng commented 8 years ago

Yes, I think it expands properly. There are target/scala-2.10/jamr-assembly-0.1-SNAPSHOT.jar and target/scala-2.10/classes/edu/cmu/lti/nlp/amr/CorpusTool.class.

sammthomson commented 8 years ago

What I'm trying to find out is the full expanded out command, as printed out by your shell, copy-pasted without retyping or replacing anything. I mean the command you mentioned before:

java -ea -Dfile.encoding=UTF-8 -XX:ParallelGCThreads=2 -Xmx4g -XX:+CMSClassUnloadingEnabled -cp .:${JAMR}/target/scala-2.10/jamr-assembly-0.1-SNAPSHOT.jar edu.cmu.lti.nlp.amr.CorpusTool --tokenized ${JAMR}/data/amr_anno_1.0/data/split/training/training.txt.snt.tok

The problem seems to be that java can't find jamr-assembly-0.1-SNAPSHOT.jar on its classpath. To debug that, it's import to know exactly what's being passed on the command line, without shortening or replacing anything. It could be a problem like ${JAMR_HOME} has a space in it and it's not being properly quoted, or something like that.

hao-cheng commented 8 years ago

Sorry. Here is the full command

java -ea -Dfile.encoding=UTF-8 -XX:ParallelGCThreads=2 -Xmx4g -XX:+CMSClassUnloadingEnabled -cp /home/chenghao/projects/20150715-amr_parsing/template/jamr.debug20150715/target/scala-2.10/jamr-assembly-0.1-SNAPSHOT.jar edu.cmu.lti.nlp.amr.CorpusTool --tokenized /home/chenghao/projects/20150715-amr_parsing/template/jamr.debug20150715/data/amr_anno_1.0/data/split/training/training.txt.snt.tok
sammthomson commented 8 years ago

Hmmm, I don't see anything obviously wrong there.

And the file /home/chenghao/projects/20150715-amr_parsing/template/jamr.debug20150715/target/scala-2.10/jamr-assembly-0.1-SNAPSHOT.jar exists? It should be about 217M.

If so, I'm sort of stumped. I did a fresh clone into /Users/chenghao/projects/20150715-amr_parsing/template/jamr.debug20150715/ which is as close as I can get to your path on a Mac. I ran through all the commands you said, and I don't get that error. Java 7 is the only version we support, but I tried with Java 6, 7, and 8 just in case and none of them choked.

jflanigan commented 8 years ago

Hi Hao Cheng,

Check to make sure /home/chenghao/projects/20150715-amr_parsing/template/ jamr.debug20150715/target/scala-2.10/jamr-assembly-0.1-SNAPSHOT.jar exists.

Also, make sure to source the config script in the directory you're compiling in and running the experiments in. The problem you encountered could occur if you sourced a config script in a different directory and cd'ed to a new directory to run the experiments (which could easily happen if you were using multiple JAMR directories in different bash windows and cd'ed in one of them). You might try opening a fresh command window, cd to the JAMR directory and run the commands:

. scripts/config.sh

./compile

pushd scripts/preprocessing

./PREPROCESS.sh

You might also try using the train scripts that do all the steps for you, and try it first on Little Prince. These scripts are pretty bulletproof, especially the Little Prince script since it downloads the data by itself. In this case you would do:

cd your_JAMR_dir ./compile (or ./setup if you haven't run that yet) ./scripts/train_Little_Prince.sh (or ./scripts/train_LDC2014T12.sh)

Let us know if this works,

Jeff

On Wed, Jul 15, 2015 at 6:51 PM, Sam Thomson notifications@github.com wrote:

Hmmm, I don't see anything obviously wrong there.

And the file /home/chenghao/projects/20150715-amr_parsing/template/jamr.debug20150715/target/scala-2.10/jamr-assembly-0.1-SNAPSHOT.jar exists? It should be about 217M.

If so, I'm sort of stumped. I did a fresh clone into /Users/chenghao/projects/20150715-amr_parsing/template/jamr.debug20150715/ which is as close as I can get to your path on a Mac. I ran through all the commands you said, and I don't get that error. Java 7 is the only version we support, but I tried with Java 6, 7, and 8 just in case and none of them choked.

— Reply to this email directly or view it on GitHub https://github.com/jflanigan/jamr/issues/9#issuecomment-121771011.

hao-cheng commented 8 years ago

Thanks a lot for all the help. I have made it work.

jflanigan commented 8 years ago

Great! For future reference, how did you fix it?

hao-cheng commented 8 years ago

Thanks for all the help! The problem is caused by path and classpath difference of JVM between Linux and Windows.