Note that there are some explanatory texts on larger screens.

plurals
  1. POxml file is not accessible
    text
    copied!<p>I am creating some REST APIs. For this I have some application level common name value pairs. To configure those name value pairs , I just created an xml file in WebContent and accessed values from the xml in a static block of a class and initialized with static variables. So all values which are given for each name in xml will be assigned to respective static variable from a class's static block. </p> <p>I am able to access those variables and get values in each classes other than from a REST API client. The problem comes, when I'm creating a REST API client for consuming API's created in the same project, FileNotFoundException is throwing for the path I have given for my xml file(WebContent/myxml.xml).</p> <p>I can see that, its searching for the same xml file in my eclipse path(/home/aneesh/eclipse/WebContent/myxml.xml). And FileNotFoundException throwing. How can I resolve this issue?</p> <pre><code>1. class which accessing xml file class Constants { public static String name; static { initializeConstants(); } public static void initializeConstants() { try { //initializing Constants //"Reading file" File xmlFile = new File("WebContent/myxml.xml"); ....... //file is getting read perfectly and "name" is initialized } } 2. class accepting static variable Constants.name // accepting value of 'name' using Constants.name successfully // writing a method which is accepting some parameters and using Constants.name. // writing a "main" method and calling this class's methods will work perfectly. // value of Constants.name will be accessible here. 3. REST API created which will call methods of second class with parameters. 4. Webscript client created for consuming above created API. // Here the exception is coming. // Eception is throwing from the class Constants //Exception from Constants : FileNotFoundException java.io.FileNotFoundException: /home/aneesh/eclipse/eclipse/WebContent/myxml.xml (No such file or directory) </code></pre> <p>So, why in this case its looking for the file in eclipse's path? How to resolve it? Tried by putting into src folder also, but not working.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload