I am building a jersey-2 webapp. I can't access config.property file from resource. What am I missing?
@Bean(name = com.tarkshala.photo.drive.Configuration.CONFIGURATION_BEAN_NAME)
public Properties getConfiguration() throws IOException {
Properties properties = new Properties();
InputStream input = new FileInputStream("config.properties");
properties.load(input);
return properties;
}
Bean initialization fails with following error:
Caused by: java.lang.NullPointerException
at com.tarkshala.photo.spring.SpringAppConfig.getConfiguration(SpringAppConfig.java:47)
at com.tarkshala.photo.spring.SpringAppConfig$$EnhancerBySpringCGLIB$$3ecfb6f6.CGLIB$getConfiguration$5(<generated>)
at com.tarkshala.photo.spring.SpringAppConfig$$EnhancerBySpringCGLIB$$3ecfb6f6$$FastClassBySpringCGLIB$$45328ae1.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358)
You can try YourCurrentClass.class.getClassLoader().getResourceAsStream("config.properties")