Hello aps,
First, don't use File IO if it isn't necessary (and it isn't here).
Second, see:
http://marc.theaimsgroup.com/?l=tomcat-user&m=103904964313189&w=2
Jake
Friday, December 13, 2002, 11:26:08 AM, you wrote:
ao> 1) Please help, the support class of my servlet is not able to find the file
ao> town.xml. I have this file town.xml at taxi/town.xml, a copy at
ao> taxi/WEB-INF/classes/town.xml I tried to pre-pend with "/" and no "/" with
ao> same results. A snippet of the log is below:
ao> 81 2002-12-13 01:25:05 StandardContext[/taxi]: Starting filters
ao> 82 2002-12-13 01:25:05 okay it found the file and it exist
ao> 83 Making Javaville from file town.xml
ao> 84 ERROR in opening file town.xml
ao> 85 XmlTree creation failure:/town.xml (No such file or directory)
ao> 86 java.io.FileNotFoundException: /town.xml (No such file or directory)
ao> 87 at java.io.FileInputStream.open(Native Method)
ao> Code snippets, on my servlet init() method I have
ao> 18 static String configFileName = "taxisocket.properties";
ao> 19 static String DEFAULT_XML_FILE = "town.xml";
ao> .....
ao> 50 String xmlfile = p.getProperty("xmlfile", DEFAULT_XML_FILE);
ao> 51 System.out.println("Making Javaville from file " + xmlfile);
ao> 52
ao> 53 XmlTree xt = null;
ao> 54 try {
ao> 55 xt = new XmlTree(new File(xmlfile));
ao> 56
ao> on XmlTree.java:
ao> 28 public XmlTree(File f) throws FileNotFoundException, IOException {
ao> 29
ao> 30 //open the file
ao> 31 try {
ao> 32 br = new BufferedReader(new FileReader("/"+f));
ao> 33 } catch (FileNotFoundException fnfe) {
ao> 34 System.err.println("ERROR in opening file " + f);
ao> 35 throw fnfe;
ao> 36 }
ao> 2) Also if I modify the XmlTree to use the following code, TOMCAT just
ao> shutdowns about a second after starting. Why would this code shutdowns Tomcat?
ao> This compiles okay and I assume once the servlet calls this at the init(), it
ao> shuts down Tomcat.
ao> 33 // force to read a File.
ao> 34 InputStream is = getClass().getResourceAsStream("town.xml");
ao> 38 br = new BufferedReader(new InputStreamReader(is));
ao> aps
ao> __________________________________________________
ao> Do you Yahoo!?
ao> Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
ao> http://mailplus.yahoo.com
ao> --
ao> To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
ao> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
--
Best regards,
Jacob mailto:[EMAIL PROTECTED]
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>