Greetings In the webapp \ WEB-INF folder there is an XML file with data for initial loading of the database: webapp \ WEB-INF \ orders.xml

On the server side I do:

final File xmlFile = new File("WEB-INF/orders.xml"); 

But when I start the application, I get an error from TomCat:

 D:\apache\Tomcat8024\bin\WEB-INF\orders.xml (Системе не удается найти указанный путь) 

those. TomCat is not looking for the XML in the application directory \ WEB-INF but in the bin-folder of the server itself. I understand that it is necessary somewhere to indicate the path, but I do not know where.

  • getClass (). getClassLoader (). getResourceAsStream (...) - Stranger in the Q
  • Thank you for the hint, but I don’t quite understand how to connect it with xmlFile? - Vard32
  • Well, you do not need the file but the data from it =) - Stranger in the Q
  • InputStream is = getClass (). GetClassLoader (). GetResourceAsStream ("WEB-INF / orders.xml") - Stranger in the Q
  • Yes, that is exactly what I did, but in "is" why is it null. But! I don’t know if it’s right or wrong, but I moved orders.xml to the resources branch, and rewrote the line of code like this: InputStream stream = getClass (). GetClassLoader (). GetResourceAsStream ("orders.xml"); and earned. But I don’t know if this is considered the right approach) - Vard32

0