This is an J2EE / ant / Servlet question. And since I was only able to post it once it goes here (as the J2EE forum seems to be mostly EJB questions). I had a Servlet which worked under WS 3.5. I changed the ant file to support creating a 'ear' file. There was a config file that the Servlet used and I wanted to include that in the 'ear' file. The Servlet looked for config file in the directory in which is runs. And that was the problem. The Servlet was not able to find the config file until I put it here: .../app/XYZ/ Everything in the 'ear' file gets installed into .../app/XYZ/installedApps/ So I was not able to figure out how to include the config file in the 'ear' file, and have settled for installing it as a separate step, outside of the 'ear' file. Any ideas about how I would be able to include the config file in the 'ear' file, so that the Servlet would be able to find it?
Please ignore post, I have no idea what I am talking about.
You are correct. I didn't explain in enough detail. My build.xml makes a 'war' and an 'ear'. So the servlet config file is included in the 'war' file, which is than placed into an 'ear' file. But I still have the same problem. I don't have any problems getting the servlet config file into the 'war' file. The problem is that when the servlet runs it is looking for the config file outside of the directory structure in which the 'war' files are placed.
Wait, are you trying to load the config file from the file system using a FileStream or FileReader? If so, then reading the file from inside a war inside an ear is going to be tough. I would use Class.getResourceAsStream(). I think the servlet should be able to find the file then. Another option is to put the config file into a well known directory on the file system and not into the ear at all.