On 04/ 2/09 12:14 PM, glassfish_at_javadesktop.org wrote:
> Hi I wrote a simple servlet which reads an xml. I placed the xml in SRC folder and loading it using Document doc = docBuilder.parse(new File("tasks.xml"));. But when I run the servlet I get FileNotFound Exception. Please help I might be missing some configuration, i am totally new to Sun App Server
>
>
> java.io.FileNotFoundException: C:\Sun\AppServer\domains\domain1\config\tasks.xml (The system cannot find the file specified)
>
Obviously, any relative file paths are interpreted as being relative to
the domain's config directory.
If you placed your tasks.xml in your webapp's root directory, you should
be able to parse it from
within your servlet like this:
Document doc =
docBuilder.parse(getServletContext().getResourceAsStream("tasks.xml")) ;
Jan
> at java.io.FileInputStream.open(Native Method)
> at java.io.FileInputStream.<init>(FileInputStream.java:106)
> at java.io.FileInputStream.<init>(FileInputStream.java:66)
> at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:70)
> at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:161)
> at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:973)
> at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:184)
> at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:798)
> at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
> at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
> at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:250)
> at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:292)
> at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:172)
> at gov.hud.util.reader.TaskReader.readXml(TaskReader.java:35)
> at gov.hud.resend.servlet.ResendServlet.doGet(ResendServlet.java:26)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:747)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:264)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:178)
> at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:263)
> at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
> at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:225)
> at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:173)
> at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
> at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
> at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
> at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:132)
> at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:933)
> at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:189)
> at com.sun.enterprise.web.connector.grizzly.ProcessorTask.doProcess(ProcessorTask.java:604)
> at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:475)
> at com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:371)
> at com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:264)
> at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:281)
> at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:83)
> [Message sent by forum member 'nutsboltsstruts' (nutsboltsstruts)]
>
> http://forums.java.net/jive/thread.jspa?messageID=340344
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>