views:

54

answers:

1

I have two web applications running in same Servlet container (Tomcat), A and B. These two connect to each other using Spring Remoting. On startup, B needs to call A to open a connection automatically, it's basically a really simple authentication call.

However since B is (in my case) loaded before A, B's application context blocks until the entire application is started up. What this means is that the B application will be stuck until timeouts etc. occur and only then A is allowed to start, however at this point B is now incapable of connecting to A and the required connection between two web applications won't be created.

So, how do I work around this? I'm currently hooking the connection command using InitializingBean and the application context is initialized using a listener.

A: 

Two options come to my mind:

  • Run two instances of Tomcat, on different ports.
  • perform the authentication in a new thread (preferably using an ExecutorService). Thus the "main" thread won't block and the deployment will continue.
Bozho
Running the two applications in same servlet container is actually requirement so the first option is unfortunately out of the question. I'm trying to avoid boilerplate code for running the "connector" because otherwise it's going to be used just like a normal bean and that would require additional boilerplating to get it back to "normal" state.
Esko