Not Able to Read the Configuration Files from java web application

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ajmerasunny
    New Member
    • Mar 2008
    • 4

    Not Able to Read the Configuration Files from java web application

    Hi All,

    I have a java web application in which I need to read a configuration file(WebAgent.c onf) that has the reference of another configuration file(SmHost.con f). I am placing both these configuration files in the <root-dir> of the application.

    I am specifying the path for WebAgent.conf as “/WebAgent.conf” in my AuthenticateUse r java class and in WebAgent.conf, the reference to SmHost.conf is given as “/SmHost.conf”.


    I am copying the content of the all the files for your reference below:

    AuthenticateUse r.java

    String webagentConfigF ile = "/WebAgent.conf";
    InitDef initdef = new InitDef();
    int retcode = agentapi.getCon fig(initdef, agentName, webagentConfigF ile); // retcode=-1 which implies that code is unable to read the configuration file.
    AuthBean authbean = new AuthBean();

    WebAgent.conf:

    agentconfigobje ct="1365-pmtrade-trd-dvl4-443-aco"
    hostconfigfile= "/SmHost.conf"

    But with this approach, I am unable to read this configuration files. Kindly let me know where I am going wrong.
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    No .. This is not the path the Class file looks for.
    You need to use ServletConext.g etRealPath(), it returns the path of root directory. Or you can put the conf file where the Class file dropped.
    Or you can set the System environment variable java.dir.

    You better to keep it inside the Class path where you Reader Class exists ;)

    Comment

    Working...