Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading Resources from JAR fails in experiments.sts2013baseline.util.StopwordFilter #13

Open
nicolaierbs opened this issue Mar 30, 2015 · 17 comments
Labels

Comments

@nicolaierbs
Copy link
Member

Original issue 13 created by dkpro on 2013-08-19T14:46:06.000Z:

What steps will reproduce the problem?

  1. Download the 1.0.1 stable version of the sts2013baseline (gpl package)
  2. Run Pipeline -D

Run terminates with Exception:

Caused by: java.io.FileNotFoundException: class path resource [stopwords/stopwords_english_punctuation.txt] cannot be resolved to absolute file path because it does not reside in the file system:
jar:file:/home/someuser/.m2/repository/de/tudarmstadt/ukp/similarity/dkpro/de.tudarmstadt.ukp.similarity.dkpro.data-asl/1.0.1/de.tudarmstadt.ukp.similarity.dkpro.data-asl-1.0.1.jar!/stopwords/stopwords_english_punctuation.txt
at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:204)
at org.springframework.core.io.AbstractFileResolvingResource.getFile(AbstractFileResolvingResource.java:52)
at de.tudarmstadt.ukp.similarity.experiments.sts2013baseline.util.StopwordFilter.initialize(StopwordFilter.java:75)
... 15 more

Suggested Bugfix:

Replace res.getFile(); with res.getInputStream(); in
de.tudarmstadt.ukp.similarity.experiments.sts2013baseline.util.StopwordFilter.initialize(StopwordFilter.java:75)

@nicolaierbs
Copy link
Member Author

Comment #1 originally posted by dkpro on 2013-08-19T15:51:01.000Z:

There is actually at least one more bug of the same type...

Figured out it an easier work-around is to copy the data needed (datasets, goldstandards, stopwords) from the jar file into a separate folder and add it manually to the class path...

Cheers Michael

@nicolaierbs
Copy link
Member Author

Comment #2 originally posted by dkpro on 2013-08-19T15:53:55.000Z:

Yes, this will certainly work, too.

Could you point out the other location, where the same error occurs, so that we can fix that, too?

ps: And thanks for the patch.

@nicolaierbs
Copy link
Member Author

Comment #4 originally posted by dkpro on 2013-08-19T16:03:50.000Z:

Next one was caused by sts2013baseline.util.Features2Arff.toArffFile(Features2Arff.java:49)
Same res.getFile() problem


Exception in thread "main" java.io.FileNotFoundException: class path resource [goldstandards/semeval-2012/train/STS.gs.ALL.txt] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/home/mschuhma/.m2/repository/de/tudarmstadt/ukp/similarity/dkpro/de.tudarmstadt.ukp.similarity.dkpro.data-asl/1.0.1/de.tudarmstadt.ukp.similarity.dkpro.data-asl-1.0.1.jar!/goldstandards/semeval-2012/train/STS.gs.ALL.txt
at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:204)
at org.springframework.core.io.AbstractFileResolvingResource.getFile(AbstractFileResolvingResource.java:52)
at de.tudarmstadt.ukp.similarity.experiments.sts2013baseline.util.Features2Arff.toArffFile(Features2Arff.java:49)
at de.tudarmstadt.ukp.similarity.experiments.sts2013baseline.Pipeline.runTest(Pipeline.java:155)
at de.tudarmstadt.ukp.similarity.experiments.sts2013baseline.Pipeline.main(Pipeline.java:101)

@nicolaierbs
Copy link
Member Author

Comment #5 originally posted by dkpro on 2013-08-20T15:06:59.000Z:

I fixed the issue at those two locations.
Hopefully that fixed it.

@avineshpvs
Copy link

A Similar problem surfaced at sts2013baseline.util.Evaluator.java (Evaluator.java:311)

Exception in thread "main" java.io.FileNotFoundException: class path resource [goldstandards/semeval-2012/train/STS.gs.MSRpar.txt] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/home/.m2/repository/dkpro/similarity/dkpro.similarity.uima.data-asl/2.1.0/dkpro.similarity.uima.data-asl-2.1.0.jar!/goldstandards/semeval-2012/train/STS.gs.MSRpar.txt
at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:205)
at org.springframework.core.io.AbstractFileResolvingResource.getFile(AbstractFileResolvingResource.java:52)
at dkpro.similarity.experiments.sts2013baseline.util.Evaluator.computePearsonCorrelation(Evaluator.java:311)
at dkpro.similarity.experiments.sts2013baseline.util.Evaluator.runEvaluationMetric(Evaluator.java:232)
at dkpro.similarity.experiments.sts2013baseline.Pipeline.runTrain(Pipeline.java:122)
at dkpro.similarity.experiments.sts2013baseline.Pipeline.main(Pipeline.java:85)

@nicolaierbs
Copy link
Member Author

I am not sure whether your issue has the same cause. Could you please post the line where you load the file "goldstandards/semeval-2012/train/STS.gs.MSRpar.txt"?

@nicolaierbs nicolaierbs reopened this Oct 21, 2015
@avineshpvs
Copy link

I get the error at the 2nd line.
Resource res = r.getResource(gsScoresFilePath);
File gsScoresFile = res.getFile();

@nicolaierbs
Copy link
Member Author

Can you just use the file path directly? 'File file = new File("goldstandards/semeval-2012/train/STS.gs.MSRpar.txt")'? Resource is a class which provides functionality to load files from a jar in the classpath. (It should work though...)

@nicolaierbs
Copy link
Member Author

The file "STS.gs.MSRpar.txt" is in the jar dkpro.similarity.uima.data-asl (version 2.1.0). Running from the command line will not work because several other dependencies are required. If you the dependencies to a maven project it should work fine.

@avineshpvs
Copy link

Thanks. I had all the dependencies in the maven project. The pipeline was running fine until this point and it was reading couple of other files from the dkpro.similarity.uima.data-asl, just that it was not able to read this particular file.

@nicolaierbs
Copy link
Member Author

Ok, I'm running out of ideas. It would be good if you could debug it. It might be due to another version of the artifact, but I'm not sure about that.

@zesch
Copy link
Member

zesch commented Oct 22, 2015

Could you please try to navigate to the jar in the exception
file:/home/.m2/repository/dkpro/similarity/dkpro.similarity.uima.data-asl/2.1.0/dkpro.similarity.uima.data-asl-2.1.0.jar
and then look whether the specified file is actually in there?
/goldstandards/semeval-2012/train/STS.gs.MSRpar.txt

@avineshpvs
Copy link

Yes it is there in the location.

Regards
Avinesh

On Thu, Oct 22, 2015 at 8:56 AM, Torsten Zesch [email protected]
wrote:

Could you please try to navigate to the jar in the exception

file:/home/.m2/repository/dkpro/similarity/dkpro.similarity.uima.data-asl/2.1.0/dkpro.similarity.uima.data-asl-2.1.0.jar
and then look whether the specified file is actually in there?
/goldstandards/semeval-2012/train/STS.gs.MSRpar.txt


Reply to this email directly or view it on GitHub
#13 (comment)
.

@zesch
Copy link
Member

zesch commented Oct 23, 2015

If it is there, I don't see why the exception you have reported should be thrown.

@reckart
Copy link
Member

reckart commented Oct 23, 2015

Exception in thread "main" java.io.FileNotFoundException: class path resource [goldstandards/semeval-2012/train/STS.gs.MSRpar.txt] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/home/.m2/repository/dkpro/similarity/dkpro.similarity.uima.data-asl/2.1.0/dkpro.similarity.uima.data-asl-2.1.0.jar!/goldstandards/semeval-2012/train/STS.gs.MSRpar.txt
at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:205)

So this looks like the calling code is expecting the resource to be located in the file system and tries using getFile() to get a File object representing the resource. However, since the resource is in a JAR, it cannot be addressed using a File object. This would work if the user has DKPro Similarity checked out in the local machine (in which case the resource would be in the Maven target folder on disk), but not if the user is using the resource through a Maven dependency.

@zesch
Copy link
Member

zesch commented Oct 23, 2015

Right. Thanks Richard.
I didn't saw the problem earlier as the experiment is in GPL tmp repository that still awaits its move to the main repository.

So the quick word around is to check out all of dkpro-similarity.
But in the long run we should replace the file references with streams or use ResourceUtils.resolveLocation()

@avineshpvs
Copy link

Thanks Richard and Torsten.

Regards
Avinsh

On Fri, Oct 23, 2015 at 3:59 PM, Torsten Zesch [email protected]
wrote:

Right. Thanks Richard.
I didn't saw the problem earlier as the experiment is in GPL tmp
repository that still awaits its move to the main repository.

So the quick word around is to check out all of dkpro-similarity.
But in the long run we should replace the file references with streams or
use ResourceUtils.resolveLocation()


Reply to this email directly or view it on GitHub
#13 (comment)
.

@reckart reckart added bug and removed Type-Defect labels Nov 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants