title: Spring/RMI server error
body: <p>We have a Spring MVC web app (WAR) deploying to Tomcat (6.0.35) that launches a thread inside a separate JVM at deploy time (don't ask why - <strong>not</strong> my design) and then communicates with that thread via RMI over port 8888.</p>
  
  <p>Despite being totally convoluded, this was working perfectly fine up until yesterday, and now the thread is failing at startup and despite our best efforts to add logging into the mix, we are hitting a wall. This is the only exception we are able to find in the logs:</p>
  
  <pre><code>Jun 12, 2012 3:11:36 AM com.ourapp.ImageController destroy
  SEVERE: Shutdown Error: Lookup of RMI stub failed; nested exception is      java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
      java.net.ConnectException: Connection refused
  Jun 12, 2012 3:11:37 AM org.apache.catalina.core.StandardContext listenerStop
  SEVERE: Exception sending context destroyed event to listener instance of class    org.springframework.web.context.ContextLoaderListener
  java.lang.NoClassDefFoundError: org/springframework/web/context/ContextCleanupListener
      at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:80)
      at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:3973)
      at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4577)
      at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1165)
      at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1271)
      at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:296)
      at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
      at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337)
      at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
      at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
      at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
      at java.lang.Thread.run(Thread.java:662)
  Caused by: java.lang.ClassNotFoundException: org.springframework.web.context.ContextCleanupListener
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
      ... 12 more
  </code></pre>
  
  <p>The <code>ImageController</code> is the Spring MVC <code>Controller</code> that is responsible for kicking off this daemon/spawned RMI thread. Based on the verbage of this error, does anybody have <em>any</em> idea what might be causing this "connection refused" error?</p>
  
  <p>Running a <code>netstat -an | grep 8888</code> (this is a Linux machine) produces no output which means nothing is listening on that port. Thanks in advance for any ideas/suggestions that lead to a fix.</p>
  
  <p><strong>Edit</strong>: Here's another <code>ConnectionException</code> we're seeing:</p>
  
  <pre><code>Caused by: java.net.ConnectException: Connection refused
      at java.net.PlainSocketImpl.socketConnect(Native Method)
      at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
      at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
      at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
      at java.net.Socket.connect(Socket.java:529)
      at java.net.Socket.connect(Socket.java:478)
      at java.net.Socket.&lt;init&gt;(Socket.java:375)
      at java.net.Socket.&lt;init&gt;(Socket.java:189)
      at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
      at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
      at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:595)
      ... 74 more
  </code></pre>