I have a problem with my code and that it always throws NullPointerException:
public class WhateverResource extends ServerResource {
@Get("json")
public Representation represent(){
InputStream is = getContext().getClass().getClassLoader().getResourceAsStream("/whatever.properties");
Properties props = new Properties();
try {
props.load(is);
String whatever = props.getProperty("whatever_key");
setStatus(Status.SUCCESS_OK);
} catch (IOException e) {
e.printStackTrace();
setStatus(Status.SERVER_ERROR_INTERNAL);
}
return new StringRepresentation(props.toString());
}
}
I check the WAR file generator and the target folder contains the file propertiesin the folder WEB-INF. What could be wrong with this code?
source
share