0

I am getting file not found exception when i read the file from server,but I can read a file fine when i execute the program from main,please tell me the suggestion for this issue. Thanks in advance.

static Ontology ontology = new SingleFileOntologyImpl("data/Thesaurus_V21.ontology");
        System.err.println("Ontology file read!");

        tokenizerFactory = TokenizerFactoryImpl.createDefaultTokenizerFactory(new UMLSGeneChemTokenizer());

        normalizerFactory = NormalizerFactoryImpl.createDefaultNormalizerFactory(new LVGNormalizer("/home/rajendraprasad.yk/projects/FSTA/FSTA_NLP/tools/lvg2006/data/config/lvg.properties"));
        System.err.println("LVG initialized");

        disambiguator = new TypeDisambiguatorImpl(new RuleDisambiguator[] { new StrictDisambiguator(),new LooseDisambiguator() });
        disambiguationDecisionMaker = new ThresholdDisambiguationDecisionMakerImpl();
        String ontologyLanguageToLoad = null;
        System.out.println(new Date());
        peregrine = new PeregrineImpl(ontology, tokenizerFactory,normalizerFactory, disambiguator,disambiguationDecisionMaker, ontologyLanguageToLoad);
        System.err.println("Peregrine Initialized ! "+ new Date());

Exception is :java.lang.RuntimeException: java.io.FileNotFoundException: data/Thesaurus_V21.ontology (No such file or directory)

Rajendra_Prasad
  • 1,300
  • 4
  • 18
  • 36

1 Answers1

1

Your server has obviously set its current working directory to another path as you have for your application when running from main.

If this file always relative to your class, you might want to get your path to the file with help of the class loader, see here at stackoverflow.

If this does not help, you might want to print out the current working directory of the server (see here at stackoverflow) as a help to adjust your path.

Possibly it is then a good idea to have a relative or absolute path in your server configuration.

Community
  • 1
  • 1
Aconcagua
  • 24,880
  • 4
  • 34
  • 59