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:
to make Tomcat load it upon startup. The result was that the servlet and the server both froze. L
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.
Hi Uri,it's not possible to assess this issue without having some more information about the server itself.
Was there any log produced? Is the JVM still running? Can you do jstack <pid>?
Also, how is your edu.mit.WeirdQuery servlet using Jersey? Why don't you use org.glassfish.jersey.servlet.ServletContainer?
(I mean something like:
<servlet> <servlet-name>testServlet1</servlet-name> <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class> <init-param> <param-name>javax.ws.rs.Application</param-name> <param-value>org.glassfish.jersey.tests.integration.servlet_25_init_1.Servlet25init1</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>testServlet1</servlet-name> <url-pattern>/servlet_path/*</url-pattern> </servlet-mapping>)
Ah, you most likely do the JNI stuff there somehow and then
extending or wrapping Jersey Servlet (is that correct?). Anyway,
it could be implemented in a class managed by Jersey, but that
shouldn't really matter.
On 14/09/16 16:04, Blumenthal, Uri - 0553 - MITLL wrote:
|Free forum by Nabble||Edit this page|