Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7858889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:39:31+00:00 2026-06-02T21:39:31+00:00

In eclipse IDE,there is a standalone java application which reads files.The files are all

  • 0

In eclipse IDE,there is a standalone java application which reads files.The files are all in a folder under the project.
I created another web application and wrote a servlet and added the jar file of the above application in WEB_INF/lib so that I can use all the classes in it.The servlet is pretty simple but the java application is unable to read files as it used to earlier.I get java.io.FileNotFoundException (The system cannot find the path specified).
I checked the jar file and it contains the folder containing the files to be read.I even tried adding the folder to the classpath in TOMCAT . but still I cannot get rid of that error.Can someone tell me what is wrong?

The place where I get the error

public class KnowledgeSummaryServlet extends HttpServlet {

Answerer a = new Answerer();

The class Answerer is something like this

public class Answerer {
Lookup lvg  = new Lookup("resources/test/xyz", "resources/test/test.txt");

This is the error trace once I run the servlet

java.io.FileNotFoundException: resources\test\xyz (The system cannot              
find the path specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.util.Scanner.<init>(Scanner.java:656)
at com.Lookup.localInitialize(Lookup.java:49)
at com.Lookup.<init>(Lookup.java:44)
at com.Answerer.<init>(Answerer.java:27)
at com.web.KnowledgeSummaryServlet.<init>(KnowledgeSummaryServlet.java:20)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at java.lang.Class.newInstance0(Class.java:372)
at java.lang.Class.newInstance(Class.java:325)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:119)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1048)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:799)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:135)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:108)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:558)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:379)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:259)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:281)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T21:39:33+00:00Added an answer on June 2, 2026 at 9:39 pm

    You should not get classpath resources as local disk file system resources using FileInputStream. This makes no sense. Get classpath resources as classpath resources using ClassLoader.

    Given that you’re in a servlet and assuming that the /resources folder is part of the classpath, just get them as follows:

    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    InputStream xyzInput = classLoader.getResourceAsStream("test/xyz");
    InputStream txtInput = classLoader.getResourceAsStream("test/test.txt");
    // ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a java project which I work on using Eclipse ide. I have
Is there a way to add sun one application server 7 to eclipse IDE.
I have an Android project for which I use the Eclipse IDE and I
I know why not to commit Eclipse/IDE-specific files into a VCS like Git (which
I'm developing Java application using Eclipse IDE. problem is my PC is every low
Is there any way, with the Eclipse IDE, to have a master folder containing
I am using Eclipse IDE for my Java Project. I have one problem. I
I made an application in Java (using the Eclipse IDE) and i refer in
is there something like a Quickfix in Eclipse IDE available in VisualStudio 2008? Thanks,
I uninstalled the Spket plugin from Eclipse, but there is still an <Spket IDE>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.