I am creating a simple REST service, which owns only REST resource (java class with Jersey annotations). This REST resource needs several Java objects to work. These Java objects are very big, a few hundred MB, so it's slow to load them into RAM. Therefore, I am trying to add these objects as static members of this REST class. However, when I send a request to the REST service, it always throws a NullPonterException. Can anyone explain why these static members are not instantiated before the REST resources(classes) are loaded? Or it's some other reasons?
Thanks you guys in advance.
Note: those static members are just some Maps, and Lists objects, created by a class in a dependency jar.
Edit: assume the InfoConstructor below is one utility class which is responsible for creating those static objects.
code for my REST resource class is as below:
@Path("test")
public class TestResource {
public static Map<String, Integer> vocMap = InfoConstructor.getVocMap();
@Get
@Produce(Media.TEXT_HTML)
public String testGet() {
return vocMap.hashCode();
}
}