jenkinsci/winstone — pull request #7 by jglick (2013-02-04 15:41:07+00:00)
Title: Disable AJP by default

Disables [AJP](http://en.wikipedia.org/wiki/Apache_JServ_Protocol) by default, so you need to pass `--ajp13Port=…` to enable.

Desirable for Jenkins embedding since so many people run with Winstone as the one and only HTTP server. (Even people running an Apache reverse proxy often do so via HTTP rather than AJP.)

Having an extra open port and listener wastes startup time and available sockets. It also means that you cannot run two Jenkins masters on the same machine merely by passing `--httpPort=8081` to the second; you get a cryptic error about AJP which you then need to do some work to interpret:

```
… winstone.Logger logInternal
INFO: HTTP Listener started: port=8081
… winstone.Logger logInternal
INFO: Winstone shutdown successfully
… winstone.Logger logInternal
SEVERE: Container startup failed
java.io.IOException: Failed to start a listener: winstone.ajp13.Ajp13Listener
at winstone.Launcher.spawnListener(Launcher.java:229)
at winstone.Launcher.(Launcher.java:182)
at winstone.Launcher.main(Launcher.java:384)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at Main._main(Main.java:273)
at Main.main(Main.java:98)
Caused by: java.io.IOException: Failed to listen on port 8009
at winstone.ajp13.Ajp13Listener.start(Ajp13Listener.java:89)
at winstone.Launcher.spawnListener(Launcher.java:220)
... 8 more
Caused by: java.net.BindException: Address already in use
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376)
at java.net.ServerSocket.bind(ServerSocket.java:376)
at java.net.ServerSocket.(ServerSocket.java:237)
at java.net.ServerSocket.(ServerSocket.java:181)
at winstone.ajp13.Ajp13Listener.start(Ajp13Listener.java:84)
... 9 more

… winstone.Logger logInternal
INFO: HTTP Listener shutdown successfully
Exception in thread "pool-2-thread-2" java.lang.NullPointerException
at org.jvnet.hudson.reactor.Reactor$1.run(Reactor.java:153)
at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:94)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
… hudson.WebAppMain$2 run
SEVERE: Failed to initialize Jenkins
java.lang.InterruptedException
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Object.java:503)
at org.jvnet.hudson.reactor.Reactor.execute(Reactor.java:244)
at jenkins.InitReactorRunner.run(InitReactorRunner.java:43)
at jenkins.model.Jenkins.executeReactor(Jenkins.java:894)
at jenkins.model.Jenkins.(Jenkins.java:796)
at hudson.model.Hudson.(Hudson.java:81)
at hudson.model.Hudson.(Hudson.java:77)
at hudson.WebAppMain$2.run(WebAppMain.java:214)

Exception in thread "pool-2-thread-1" java.lang.NullPointerException
at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:191)
at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:94)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
```

([JENKINS-5753](https://issues.jenkins-ci.org/browse/JENKINS-5753) claims the AJP connector does not work anyway!)