Hi James,

You have a bit of a chicken-and-egg situation there. Usually, people don't
want the connectors started until the
contexts have been started (and load-on-init servlets started etc), so they
are ready to service requests.

If you want to, you could change that around by subclassing
org.eclipse.jetty.server.Server and overriding
the doStart() method to do things in the other order (much like the
org.mortbay.setuid.SetUIDServer does).

Alternatively you could use o.e.j.s.Server.addBean(Object bean) method to
add a LifeCycle object that will
be started and stopped along with the server to initialize your 2nd servlet.

Or just lazily initialize the 2nd servlet on its first request.

Jan

On 18 August 2011 12:46, James Cook <[email protected]> wrote:

> 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?
>
> _______________________________________________
> jetty-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/jetty-users
>
>
_______________________________________________
jetty-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/jetty-users

Reply via email to