I have a RESTful service that runs as a Tomcat servlet as per the following specification in web.xml:
<servlet>
<servlet-name>User Service</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>demo.web.ix.users</param-value>
</init-param>
<init-param>
<param-name>jersey.config.server.provider.classnames</param-name>
<param-value>org.glassfish.jersey.filter.LoggingFilter;org.glassfish.jersey.media.multipart.MultiPartFeature</param-value>
</init-param>
<init-param>
<param-name>myCustomParam</param-name>
<param-value>some_value</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>User Service</servlet-name>
<url-pattern>/web/ix/users/*</url-pattern>
</servlet-mapping>
In the demo.web.ix.users package, there is class called UserService that implements the RESTful methods but does not extend any other class. It just features annotations (@GET, @POST, etc) which allow Jersey to pick it up.
I need to read the value of myCustomParam from the servlet code. I found out that calling servletConfig.getInitParameter("myCustomParam") would be the way to do it if the servlet extended any of the servlet classes (Generic, Http, etc).
I tried to change UserService so that it extends org.glassfish.jersey.servlet.ServletContainer but it doesn't help because the getServletConfig() method always returns null.
What am I missing?