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

  • Home
  • SEARCH
  • 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 7872531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:13:36+00:00 2026-06-03T02:13:36+00:00

I have Java webapp and I am trying to read a file from classpth.

  • 0

I have Java webapp and I am trying to read a file from classpth.

 if (fileName == null){
        fileName = Thread.currentThread().getContextClassLoader().getResource("config.properties");
    }
objFile = new File(fileName.toURI());

I have config.properties in my classpath. WEB-INF/classes. When I inspect locally it gives: fileName.toURI(), it gives me file:/D:/dev/Tomcat_6_0/webapps/testApp/WEB-INF/classes/config.properties. And works fine.

Issue is on production linux server I am getting this path there vfsfile:/export/home/u/bin/jboss-5.1.0.BE/server/default/deploy/testApp.war/WEB-INF/classes/config.properties.

And I am getting following exception.

Caused by: java.lang.IllegalArgumentException: URI scheme is not "file"
    at java.io.File.<init>(File.java:366)
    at com.utils.ConfigLoader.loadConfigFilePath(ConfigLoader.java:87)

What is the workaround for handeling vfs?

  • 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-03T02:13:37+00:00Added an answer on June 3, 2026 at 2:13 am

    You must not try to convert a resource from the classpath to a File. It may not even be a File if it’s inside a WAR/JAR. The File class only represents filesystem objects.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get a certificate from the appreg.intuit.com area. I have a webapp
I have a Java webapp WAR file that depends on multiple jars in it's
I have a Java webapp, running in Tomcat 6, that loads RSS feeds from
I have a java webapp which needs to upload files via http and then
I have a Java EE webapp that works perfectly when I run it on
I'm trying to make an executable war file ( java -jar myWarFile.war ) that
I'm trying to stream the file from file system to browser and cant get
I have a Java/Spring MVC/JSP/JSTL webapp. We have a designer that gave us some
I am currently trying to build a Java Project with several dependencies. I have
I'm trying to learn annotations. I currently have a webapp that runs an init()

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.