【问题标题】:File Not Found Exception whlie reading from server从服务器读取时未找到文件异常
【发布时间】:2014-04-11 19:24:25
【问题描述】:

当我从 server 读取文件时,我得到 file not found 异常,但是当我从 ma​​in,请告诉我这个问题的建议。 提前致谢。

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());

例外是:java.lang.RuntimeException: java.io.FileNotFoundException: data/Thesaurus_V21.ontology (No such file or directory)

【问题讨论】:

  • 你能发布一些与问题相关的代码吗?您的路径似乎有问题
  • 这取决于您如何从服务器读取它。显示一些代码。

标签: java web-services filenotfoundexception


【解决方案1】:

您的服务器显然已将其当前工作目录设置为另一个路径,就像您从 main 运行时为您的应用程序所设置的那样。

如果此文件始终与您的类相关,您可能希望借助类加载器获取文件路径,请参阅here at stackoverflow。

如果这没有帮助,您可能需要打印出服务器的当前工作目录(请参阅here at stackoverflow)作为调整路径的帮助。

在您的服务器配置中使用相对或绝对路径可能是个好主意。

【讨论】:

    猜你喜欢
    • 2012-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多