dice-group / AGDISTIS

AGDISTIS - Agnostic Named Entity Disambiguation
http://aksw.org/Projects/AGDISTIS.html
GNU Affero General Public License v3.0
140 stars 37 forks source link

Strange behaviour with properties files #35

Closed ghost closed 7 years ago

ghost commented 7 years ago

Sorry in advance, if this question is too java-specific for the issues tracker. But I am having problems with the provided properties file.

I want to use AGDISTIS as a dependency in my Maven project, so I have added AGDISTIS as a JAR file in my local maven repository. In order to make the properties file still accessible, I relocated it in my classpath under /my-program/src/main/resources/agdistis-config/agdistis.properties instead of /my-program/local-repository/org/aksw/AGDISTIS/0.4.0/AGDISTIS-0.4.0.jar/config/agdistis.properties.

I also changed the code in every class where the properties file is accessed, for example:

public NEDAlgo_HITS() throws IOException {

    Properties prop = new Properties();
    InputStream input = NEDAlgo_HITS.class.getResourceAsStream("/agdistis-config/agdistis.properties");
    prop.load(input);

    ...

}

Before adding the JAR to my local repository, I even deleted the whole config folder in AGDISTIS to prevent some kind of fallback and to force the use of my own properties file outside of AGDISTIS.

Now comes the strange part: I can run my program, but it does neither use my new properties file nor the old one (because I have deleted them). It uses some kind of default values for AGDISTIS, which appear as soons as the Properties object is created. This is not desired, of course.

So, how can I extract the properties file out of the JAR properly? In other words: How can I configure AGDISTIS from my own program with AGDISTIS as a dependency?

Any help is very appreciated. :)

RicardoUsbeck commented 7 years ago

Hi, the question fits fine here and we are glad to help. From which branch are you using it?

ghost commented 7 years ago

Glad to hear that. I am currently using the mergeT branch.

DiegoMoussallem commented 7 years ago

Hey @Phauly1, I think that you are doing everything right. The stranger behavior comes from this line https://github.com/AKSW/AGDISTIS/blob/mergeT/src/main/java/org/aksw/agdistis/webapp/GetDisambiguation.java#L83

Please, trying to comment it and tell me whether it works.

RicardoUsbeck commented 7 years ago

Another thing to check is, how are you building and using the jar from your project? If you do it via mvn install and a pom, please try to delete if from ~/.m2/repositories and reinstall it

ghost commented 7 years ago

Thanks for your suggestions so far!

@DiegoMoussallem I have commented out this line, but nothing changed.

@RicardoUsbeck The JAR of my main program is built via mvn install and a pom file, yes. I have deleted everything in .m2 and installed it from scratch, but it also does not solve the problem.

But I made a new discovery:

I downloaded a new and untouched AGDISTIS version from mergeT and just excluded the config folder via the pom file and commented out the aforementioned line of code. After that, I run mvn install and get an AGDISTIS JAR with no config folder or properties files in it. I am doing this, because I just want to see, if there will be some error later on, triggered by missing configuration parameters.

If I add this AGDISTIS JAR to my local maven repository with mvn install:install-file there is still no config folder or properties file in the AGDISTIS JAR - good. But now, when I run mvn install or even mvn clean install on my main program, there suddenly is a config folder with all AGDISTIS properties files in the main program's JAR. I have absolutely no idea how this happens. Edit: These appearing properties files seem to be the defaults I was talking about in my first post.

Do you have any idea what causes this behaviour?

RicardoUsbeck commented 7 years ago

I have never seen that behaviour before. Can you debug what's happening with Eclipse?

RicardoUsbeck commented 7 years ago

Hmm maybe related to http://stackoverflow.com/questions/34131991/properties-file-reads-old-data-when-jar-is-executed-from-command-line ?

ghost commented 7 years ago

I have repeated the whole procedure and installed everything again. I really do not know what the problem was, but now I am able to configure AGDISTIS out of my own resource folder. Thank you very much for your help!