| Author |
FileNotFoundException
|
Erick Martin
Greenhorn
Joined: May 17, 2002
Posts: 8
|
|
Hi everybody, the following class <URLMappingsXmlDAO> it is supposed to print out all the elements of <whatever.xml> file for testing purposes. It is invoked from a servlet <MyServlet> <MyServlet> is sitting @ WEB-INF/classes/com/mydomain/controller/ <URLMappingsXmlDAO> @ WEB-INF/classes/com/mydomain/controller/web/ <whatever.xml> @ WEB-INF/ I keep getting a FileNotFoundException, for some reason it cannot find the xml file. Any suggestions? Thanks in advance, package com.mydomain.controller.web; import java.io.FileReader; import java.io.IOException; import org.xml.sax.XMLReader; import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.helpers.XMLReaderFactory; import org.xml.sax.helpers.DefaultHandler; import org.xml.sax.SAXException; import org.apache.xerces.parsers.SAXParser; public class URLMappingsXmlDAO extends DefaultHandler { � public static void loadDocument(String location) throws SAXException, IOException { XMLReader xr = new org.apache.xerces.parsers.SAXParser(); URLMappingsXmlDAO handler = new URLMappingsXmlDAO(); xr.setContentHandler(handler); xr.setErrorHandler(handler); FileReader r = new FileReader(location); xr.parse(new InputSource(r)); } � } This is the calling servlet: package com.mydomain.controller; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import javax.naming.NamingException; import javax.naming.InitialContext; import com.mydomain.controller.web.URLMappingsXmlDAO; public class MyServlet extends HttpServlet { public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { try { URLMappingsXmlDAO.loadDocument("/WEB-INF/whatever.xml"); } catch (org.xml.sax.SAXException ex) { System.err.println("SAX Driver: " + ex); } catch (IOException ex) { System.err.println("File: " + ex); } } }
|
sa<br />Sun Certified Programmer for Java 2 Platform<p>"... black holes are those places in the Universe where God attempted to divide by zero"
|
 |
Riaz Mohamed
Greenhorn
Joined: May 31, 2002
Posts: 23
|
|
|
have u mapped u'r servlet in web.xml
|
 |
Erick Martin
Greenhorn
Joined: May 17, 2002
Posts: 8
|
|
The deployment descriptor has the required mapping for the servlet. As you can see the FileNotFoundException is being caught within the servlet. When the mappings r not ok, you get a different kind of error, like "resource not available" or something like that. Any other ideas anyone? Thanks, [ June 07, 2002: Message edited by: Erick Martin ]
|
 |
 |
|
|
subject: FileNotFoundException
|
|
|