Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Calling a servlet from another during initialization

I have a web.xml with two servlets and the <load-at-startup> tag is used to control the ordering of the servlet initialization.

The first servlet starts up fine.

The second servlet attempts to make an HTTP client request against the first servlet in the init() function. Jetty throws this exception:

    java.net.ConnectException: Connection refused
        at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
        at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:567)
        at org.eclipse.jetty.io.nio.SelectorManager$SelectSet.doSelect(SelectorManager.java:690)
        at org.eclipse.jetty.io.nio.SelectorManager.doSelect(SelectorManager.java:193)
        at org.eclipse.jetty.client.SelectConnector.run(SelectConnector.java:180)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:436)
        at java.lang.Thread.run(Thread.java:680)

If I spin off a thread to make the web request with enough of a delay to make sure all servlets have completed initialization, the call works fine.

So, Jetty is not allowing access to any servlets until they all initialize. Is this part of the specification, or an implementation choice? Is there a way to control this behavior?

Back to the top