Skip to main content

Remote Debugging A Java Process Using IntelliJ


This is a brief post on something that is rather very important. Your company probably handed you a macbook or laptop and have a Linux VM hosted somewhere, that you will do all your development on. And now the circus begins.

You like to stay on your laptop since you get all the nice IDEs and Code diffing tools and what not. But, your code only runs on the VM, rightfully so in the highly SOA (Service Oriented Architecture, basically meaning everything is REST and has nagios alerts).

So, here's how to get the best of both worlds.

Pre-requisite: Use a tool like unison or Bittorrent sync or roll your own scripts to rsync your local repo on laptop with a directory on your VM.

End state would be
  • You git clone or svn checkout on VM
  • Syncing gets it down to your laptop
  • From there on you make code changes on your IDE and syncing reflects them on VM
Most of all, it means that intellij can look for the source code for the classes you debug, on your repo on your laptop. Now, onto the actual setting up of debugging itself. 

  1. In IntelliJ, go to run > edit configurations. Click on the + , pick remote. IntelliJ automatically tells you what to use to launch your remote JVM. 



          A useful note on the options 
  • suspend=y/n , controls whether the JVM should wait for the debugger to attach before starting up. So, if you have trouble starting up your application, use suspend=y to troubleshoot

From here on, 

1. Setup whatever breakpoints you want to in your project.
2. Launch your application on your VM, with the suggested params
3. (Optional) Setup port forwarding if needed
Sometimes, your VM may not allow incoming connections at a random port that Intellij picks out for you. you can either change the Intellij port or 

    A) Enter "localhost" as the hostname in your debug configuration
    B) ssh -L <debugport>:<vm.hostname>:<debugport> <vm.hostname> 
         eg: ssh -L 5005:vm.mycompany.com:5000 vm.mycompany.com


4. In IntelliJ, hit "Debug" on your debug configuration ..

Happy debugging! 




Comments

  1. Thanks for sharing, nice post!
    - Máy đưa võng hay vong em be tu dong đang chiếm được tc người tiêu dùng bởi tính tiện dụng của dung cu dua vong tu dong, những lợi ích mà đưa võng tự động mang lại là vô củng thiết thực. Với may dua vong hay thiet bi dua vong tu dong bạn sẽ không còn phải lo lắng quá nhiều về giấc ngủ của bé, với máy đưa võng bạn có tg làm nhiều việc khác. Với sản phẩm tốt, An Thái Sơn là địa chỉ bán may dua vong tu dong gia re uy tín!

    Chia sẽ các bạn bí quyết làm thế nào để cho bé đi ngủ sớm hay những món ăn giảm cân cho trẻ béo phì, giúp trẻ nhanh biết nói hiệu quả, cách trị chứng mất ngủ ở trẻ em hiệu quả hay mách mẹ bí quyết cải thiện làn da cho bé hiệu quả nhất, chia sẻ bí quyết giúp bé ngủ ngon giấc hay tìm hiểu về đông trùng hạ thảo và những cách chế biến đông trùng hạ thảo nguyên con, chia sẻ các mẹ nguyên nhân và cách chữa trị bệnh rụng tóc ở trẻ em hiệu quả, những cách chống nắng cho bé hiệu quả trong những ngày hè hay thực phẩm giúp giải độc gan cho bạn, thực phẩm thiên nhiên giúp nhanh liền sẹo hiệu quả, cách phòng trị bệnh viêm khớp ở trẻ em an toàn, những thực phẩm bổ não cho trẻ giúp cải thiện trí nhớ, những thực phẩm không nên ăn khi thiếu máu não bạn nên lưu ý, chia sẻ thực phẩm cho người bị rối loạn tiền đình hay người bị bệnh mất ngủ nên ăn gì hoặc món ăn chữa bệnh mất ngủ cực hiệu quả!
    Những thực phẩm giúp đẹp da tại http://nhungthucphamgiupda.blogspot.com/
    Thực phẩm giúp bạn trẻ đẹp tại http://thucphamgiuptre.blogspot.com/
    Thực phẩm làm tăng tại http://thucphamlamtang.blogspot.com/

    ReplyDelete

Post a Comment

Popular posts from this blog

Learning Spark Streaming #1

I have been doing a lot of Spark in the past few months, and of late, have taken a keen interest in Spark Streaming . In a series of posts, I intend to cover a lot of details about Spark streaming and even other stream processing systems in general, either presenting technical arguments/critiques, with any micro benchmarks as needed. Some high level description of Spark Streaming (as of 1.4),  most of which you can find in the programming guide .  At a high level, Spark streaming is simply a spark job run on very small increments of input data (i.e micro batch), every 't' seconds, where t can be as low as 1 second. As with any stream processing system, there are three big aspects to the framework itself. Ingesting the data streams : This is accomplished via DStreams, which you can think of effectively as a thin wrapper around an input source such as Kafka/HDFS which knows how to read the next N entries from the input. The receiver based approach is a little compl

Setting up Hadoop/YARN/Spark/Hive on Mac OSX El Capitan

If you are like me, who loves to have everything you are developing against working locally in a mini-integration environment, read on Here, we attempt to get some pretty heavy-weight stuff working locally on your mac, namely Hadoop (Hadoop2/HDFS) YARN (So you can submit MR jobs) Spark (We will illustrate with Spark Shell, but should work on YARN mode as well) Hive (So we can create some tables and play with it)  We will use the latest stable Cloudera distribution, and work off the jars. Most of the methodology is borrowed from here , we just link the four pieces together nicely in this blog.  Download Stuff First off all, make sure you have Java 7/8 installed, with JAVA_HOME variable setup to point to the correct location. You have to download the CDH tarballs for Hadoop, Zookeeper, Hive from the tarball page (CDH 5.4.x page ) and untar them under a folder (refered to as CDH_HOME going forward) as hadoop, zookeeper $ ls $HOME /bin/cdh/5.4.7 hadoop

Enabling SSL in MAMP

Open /Applications/MAMP/conf/apache/httpd.conf, Add the line LoadModule ssl_module modules/mod_ssl.so          or uncomment this out if already in the conf file Also add lines to listen on 80, if not there already Listen 80   ServerName localhost:80 Open /Applications/MAMP/conf/apache/ssl.conf. Remove all lines as well as . Find the line defining SSLCertificateFile and SSLCertificateKeyFile, set it to SSLCertificateFile /Applications/MAMP/conf/apache/ssl/server.crt SSLCertificateKeyFile /Applications/MAMP/conf/apache/ssl/server.key Create a new folder /Applications/MAMP/conf/apache/ssl. Drop into the terminal and navigate to the new folder cd /Applications/MAMP/conf/apache/ssl Create a private key, giving a password openssl genrsa -des3 -out server.key 1024 Remove the password cp server.key server-pw.key openssl rsa -in server-pw.key -out server.key Create a certificate signing request, pressing return for defa