I have the following problem.
First, my configuration. My environment is comprised of:
1. Somebody else’s specialized server that talks proprietary protocol and does weird things, and that is accessible over the network;
2. My Tomcat server that houses my RESTful servlet edu.mit.WeirdQuery implemented in Jersey;
3. Native C library that implements interface to that weird server.
My servlet (2) needs to talk to that remote server (1). The only way to do so is by invoking functions in that native library (2). I implemented the interface between (2) and (3) via JNI. At initialization the native library gets loaded, connection to the server (1) established, and from that point on my servlet (2) can process RESTful requests and interact with that weird server.
As I understand, currently Tomcat (and/or Jersey) would load my servlet when the first REST request arrives for it (and then my servlet would run @PostConstruct init() and do all those nifty things to get the connection up and running).
It all works, but there is a problem: for reasons I don’t want to delve into right now, I need to initialize my servlet (2) when the Tomcat comes up, rather than when the first REST request comes in, and Tomcat/Jersey load and initialize my servlet.
I tried to trick Tomcat into loading my servlet by adding the following to its web.xml file:
<servlet>
<servlet-name>my-servlet</servlet-name>
<servlet-class>edu.mit.WeirdQuery</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
to make Tomcat load it upon startup. The result was that the servlet and the server both froze. ☹
Yes, I know this server doesn’t display the best manners – but it’s not under my control, and I need to proxy RESTful requests for it.
Would appreciate any advice.
Thanks!
--
Regards,
Uri Blumenthal