10

I have a remote server with Java running to which i have SSH access. I am writing an app on the local machine, building it with maven. Is it possible to set the IDE Itellij IDEA to run my project remotely? The idea is : to build the jar, copy it to the server, and debug the process ( or something like that).

It would be nice of you to share the settings i need to setup.

asked Apr 28, 2015 at 10:33

2 Answers 2

15

This is what I usually do to debug my remote app.

  1. Run the server on debug mode

    This can be adding this particular line when you run your application server

    -Xdebug -Xrunjdwp:transport=dt_socket,server=n,suspend=n,address=9999
    

    for JDK above 1.4, you can use this

    -agentlib:jdwp=transport=dt_socket,server=n,suspend=n,address=9999
    

    After that, run your application server

  2. SSH Tunneling

    I'm not 100% sure that you can access to your application's port directly if you're using ssh connection (well, maybe there is a way ;) ). So, first we need to expose the port for debugging that we set on first step by running this command.

    ssh -f [email protected] -L 9999:personal-server.com:9999 -N
    
  3. Setting up the IDE

    You can follow the step that @SSJVegito has said, which basically, is to point the debugger to the port 9999. Open the debug configuration in your Idea, then Change the circled value to 9999. Then, happy debugging :D debug configuration

answered Apr 28, 2015 at 17:09
Sign up to request clarification or add additional context in comments.

1 Comment

I was able to get it working but things like getting thread dump are extremely slow and freeze the application while I wait for them to finish. The application freezing for more than a second is not acceptable for me. Any idea what can I do to fix it?
1

I think it's possible, I was able to do such a thing with a local server I was using to deploy my application. And since you have access to the server, it should work for you as well.

What you need to do in IntelliJ is create a Remote configuration. To do that, open IntelliJ and next to the run button (on the left), you should have your configurations, designated by a down arrow. Click that arrow and click Edit Configurations. A new window should open. Click the + sign in the upper left corner and the select Remote. A new window should appear. We now need to set the host and the port which the server uses for debugging (if you are using tomcat, it is usually 8000; in tomcat, you can locate it by opening the catalina.bat file with a text editor and looking for the JPDA_ADDRESS property, which allows you to change the port). Give your configuration a name and press Apply.

Afterwards, you need to run your configuration in Debug mode. You need to select it from the configuration list and press the Debug button located to the right of the Run button.

More details here:

http://blog.trifork.com/2014/07/14/how-to-remotely-debug-application-running-on-tomcat-from-within-intellij-idea/comment-page-1/

http://eclipse.org/jetty/documentation/current/debugging-with-intellij.html

http://www.javaranch.com/journal/200408/DebuggingServer-sideCode.html

I hope this helps.

answered Apr 28, 2015 at 10:46

2 Comments

I probably misunderstand something, but why do i need the Tomcat to run a simple server side "hello world" console program. I also didn't find any mention of ssh connection to the remote server.
I've used tomcat as an example server. My Tomcat is the server to which you are connected via SSH. However, what I've told you applies for applications which are deployed on that server, e.g. web archives (.war files). I'm not sure that what you are requesting can be done for .jar files (or at least, I've never encountered such a scenario). Either way, this is the way in which you connect to a remote server in order to debug you application from IntelliJ.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.