Firstly, there are many solutions, and I already read a lot. But for some reason I am not working.
I am trying to redirect my configuration data for my webapp so that I can implement it after deployment.
This is my property service:
public class PropertiesService {
Properties properties;
public PropertiesService() {
try {
properties = new Properties();
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
InputStream stream = classLoader.getResourceAsStream("META-INF/config.properties");
properties.load(stream);
} catch (Exception e) {
e.printStackTrace();
}
}
public String getHost(){
return properties.getProperty("server_host");
}
public String getServerName(){
return properties.getProperty("server_naming");
}
}
After debugging, I noticed that the variable stream remains zero! But I do not know why -.-
Help is needed: -)
here is the error log:
java.lang.NullPointerException
at java.util.Properties$LineReader.readLine(Properties.java:418)
at java.util.Properties.load0(Properties.java:337)
at java.util.Properties.load(Properties.java:325)
Update
Now I do the following:
properties.load(this.getClass().getResourceStream("/config/config.properties"));
And I still get nullPointerException
source
share