473,322 Members | 1,562 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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.conf) that has the reference of another configuration file(SmHost.conf). 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 AuthenticateUser 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:

AuthenticateUser.java

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

WebAgent.conf:

agentconfigobject="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.
Apr 3 '09 #1
1 3791
dmjpro
2,476 2GB
No .. This is not the path the Class file looks for.
You need to use ServletConext.getRealPath(), 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 ;)
Apr 4 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Tom Martin | last post by:
I'm a Java Web developer NEWBIE that has inherited a website that fails every 2 hours due to poor connection pooling between Tomcat 4.0.6 and mySQL. In efforts to resolve this problem, I've...
2
by: Alexander Kienzle | last post by:
I'm new to Java programming. I'm developing a Servlet for tomcat which needs an external configuration file. With external I mean a file (in XML format) which is customizable and not contained in...
0
by: Monica Ferrero | last post by:
Hi! I'm not sure if this is the most adequate mySQL list for this post. If not, please indicat me which one I should use... I'm using Tomcat 4.1.24 with Apache 2 and MySQL 4.0.13. I have the...
5
by: Doug | last post by:
I would appreciate a response on this. I have clients who will be placing text files information about in a network directory for example: http://www.protegen.com/clients/ Is it possible to...
2
by: MrFile | last post by:
I added an app.config file to my application. (c#.net component dll) <?xml version="1.0" encoding="utf-8"?> <configuration> <appSettings> <add key="username" value="xx" /> <add...
1
by: Dan Noel | last post by:
I see many rich classes in System.Configuration, but all of these classes are read-only. While I have many rich classes for extracting information from a config while, I am reduced to the most...
1
by: vkrasner | last post by:
It works with VS2003 and does not in VS2005: in VS2003 : string sMyvalue = ConfigurationSettings.AppSettings; in VS2005 (does not work!!) string sMyvalue = ConfigurationManager.AppSettings; ...
2
by: rrossney | last post by:
Please look at the "what I've already done" section of this message before responding to it: I believe that I've done everything that the people who experience this error are typically told to do....
0
by: narayan2586 | last post by:
Hi all, When ever i am trying to connect my application it's giving below error message: RemoteException occurred in server thread; nested exception is: java.rmi.RemoteException: ; nested...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.