title: Deploy & Debug remote Jetty with IntelliJ 12
body: <p>I've been hacking and googling for a while now, and I've found several statck overflow threads that seemed like they were written for older versions of intellij, with various application servers. Usually they tell you to enter</p>
  
  <pre><code>java -Xdebug -Xrunjdwp:transport=dt_socket,address=51887,suspend=n,server=y
  </code></pre>
  
  <p><a href="https://stackoverflow.com/a/1088759/1172174">One answer</a> suggests using something like</p>
  
  <pre><code>-agentlib:jdwp:transport=dt_socket,address=51887,suspend=n,server=y
  </code></pre>
  
  <p>But then I get this:</p>
  
  <pre><code>Error occurred during initialization of VM
  Could not find agent library: libjdwp:transport.jnilib (searched /Library/Java/JavaVirtualMachines/1.6.0_37-b06-434.jdk/Contents/Libraries:/System/Library/Java/Extensions:/Library/Java/Extensions:.)
  </code></pre>
  
  <p>Then after one or the other of the above they tell you something like "Edit Configurations> jetty > remote and enter localhost, 51887" (the port number varies) </p>
  
  <p>However in  12, the page you land on after you select remote has a plethora of options, and is asking for JNDI ports, not jdwp ports on another tab it actually suggests the jdwp parameters above. </p>
  
  <p>Researching the JNDI port bit, generally yields instructions to add args like this to your command line...</p>
  
  <pre><code>-Dcom.sun.management.jmxremote= \
  -Dcom.sun.management.jmxremote.port=1099 \
  -Dcom.sun.management.jmxremote.ssl=false \
  -Dcom.sun.management.jmxremote.authenticate=false\
  </code></pre>
  
  <p>I've done that too and I can see port 1099 held by java (using lsof) and I can telnet to 1099, so I know the JVM is listening. (We'll try not to worry about the fact that that appears to say, open up a port by which anyone install arbitrary java code over the network to your computer without a password)</p>
  
  <p>However, in Intellij whenever I try to deploy and debug it gives me the following message:</p>
  
  <p><img src="https://i.stack.imgur.com/er1Mt.png" alt="Yes, I know it&#39;s an ancient version of jetty"></p>
  
  <p>I can see java RMI communications over 1099 when I snoop port 1099 with wireshark (but they are illegible). Evidently, the communications are not satisfactory for Intellij, so I'm wondering if there's something I need to do to Jetty to get it to play nice. Note that changing the Jetty version is not presently an option, so let's not go there :).</p>
  
  <p>I've also tried removing the artifact, disabling make, and trying to just connect the debugger, but it still gives me the same red baloon and error message, so evidently the JNDI (port 1099) part is required.</p>
  
  <p>Does anyone see something I'm doing wrong, or know of something else I should do to get this to work?</p>
  
  <p>(I'm wondering if it is something similar to this: <a href="http://youtrack.jetbrains.com/issue/IDEA-65746" rel="nofollow noreferrer">http://youtrack.jetbrains.com/issue/IDEA-65746</a> jboss issue)</p>
  
  <p><strong>Edit:</strong> Thanks to <a href="https://groups.google.com/forum/?fromgroups=#!topic/liftweb/ixWOc9H9aJ0" rel="nofollow noreferrer">this google groups post</a> I've discovered that it is possible to get the debugger connected if you don't specify Edit Configurations> + > jetty > remote, but instead choose Edit Configurations > + > remote, but debug and deploy is what I'm after so that's only a half solution.</p>