0

I am running in Tomcat 9 an app that needs to read several .config files but I get an java.io.IOException.

These .config files are located in WebContent folder.

How can I tell Tomcat to read this path? Can be related to IntelliJ settings for the project?

This is how is loaded the config file:

 ClassLoader classLoader = Thread.currentThread().getContextClassLoader();

InputStream is = classLoader.getResourceAsStream(this.configFile);

Value of this.configFile is: cnp-filter.config

Stefano Maglione
  • 3,946
  • 11
  • 49
  • 96

2 Answers2

0

Try using this:

ClassLoader classLoader = getClass().getClassLoader();
InputStream input = classLoader.getResourceAsStream("your absolute path ");

this might helpful.

Ivan Dimitrov
  • 332
  • 1
  • 10
0

CLASSPATH resources need to be under WEB-INF/classes. Please put the config files under src/main/resources for a maven project.

Alternatively, resources directly under WEB-INF are accessible via ServletContext#getResourceAsStream(String path).

Michal
  • 2,353
  • 1
  • 15
  • 18