0

I have a JRebel+Tomcat server run via IntelliJ on my Work (*NIX) machine, and occasionally I'd love to have JRebel update Classes/Resources when I'm at my home (*NIX) machine remotely connected via SSH.

e.g.

home $ ssh work
work $ cd workspace/foo/bar/baz
work $ hey-jrebel-go-update-classes

I handle this today by VNC'ing into my work machine, then in IntelliJ executing "Update Classes and Resources" on my running Tomcat instance, then log back out.

It's rather silly since I'm already SSH'd in. Is there a way to kick off this process via command-line?

inanutshellus
  • 9,683
  • 9
  • 53
  • 71

2 Answers2

1

JRebel features Remoting facility, which can be used to sync the changes via HTTP to the remote machine. For that, you should enable JRebel on remote Tomcat (via -javaagent:jrebel.jar) and enable JRebel remote plugin that create an HTTP endpoint for negotiating with the IDE plugin. -Drebel.remoting_plugin=true will do.

For more information you can check the tutorial for setting up Remoting with IntelliJ IDEA and Tomcat.

Otherwise, without remoting enabled, you can deploy the app with the rebel.xml config file which will point to the location where the exploded application is and JRebel will make Tomcat to load the resources from that specific location, so you could just synchronize from IntelliJ to that remote location via SSH. JRebel will then work as usual - monitoring the changes in the specified location and reloading the classes/resources as soon as they are being used in the application.

Anton Arhipov
  • 6,479
  • 1
  • 35
  • 43
  • I modified my answer to be clearer. IntelliJ/Tomcat/JRebel are running together on my Work machine, and I'm at home, SSH'd in. The current setup does utilize a rebel.xml but the class changes don't propagate automatically. Perhaps it's a rebel.xml configuration setting I'm not seeing. – inanutshellus Apr 23 '14 at 19:10
  • In that case, it would be the best to enable JRebel logging on the Work machine, and check if JRebel is actually monitoring anything. You can send the log file to JRebel support and they will help you out with that. – Anton Arhipov Apr 24 '14 at 05:11
  • It seems like JRebel is doing the right thing currently. Meaning, when in IntelliJ, I explicitly tell it to update Tomcat (ctrl/cmd-f10)--it doesn't just deploy every time I save a file. So with that being the case, since I'm in a bash terminal session, not in the MacOS GUI, I don't know how to tell JRebel "ok, /now/ go update". – inanutshellus Apr 25 '14 at 02:49
  • There's no such functionality, _to tell_ to JRebel to update the resources. JRebel applies the changes lazily, according to Java semantics. Meaning, as soon as the class is being used inside the application, JRebel will check the timestamp of the class in the location where it was loaded from. In case of remoting, you tell, "please, synchronize" and the IDE plugin only copies the files to the remote host into correct directory, that's it. The rest is up to the agent, to figure out that the resource is updated. – Anton Arhipov Apr 25 '14 at 10:15
  • I've finally figured out what I'm doing wrong -- JRebel simply doesn't support the way we have our ORM wired, so I'm having to actually restart the server rather than "update classes". – inanutshellus Apr 26 '14 at 19:40
0

I'm not completely following what you are attempting to do. But if I follow, you basically want to issue a command to a remote server via SSH and, ideally, launch it from within IntelliJ IDEA. You could either:

  1. Use the Terminal window (Tools > Open Terminal), start an ssh connection, and then issue the command manually.
  2. Create an External Tool definition that uses plink (or an equivalent) to execute the ssh command to your remote server. You can create an External Tool Definition in Settings > [IDE Settings] > External Tools. See the screenshot below for an example. The definition (or its group if using groups to add structure to your definitions) will appear on the Tool menu. You can also map a shortcut to it via Settings > [IDE Settings] > Keymap > External Tools. For a multiple command sequence, you can either
    • write a local script that does it and use the External Tool definition to launch the script
    • write a remote script and use the plink in an External Tool Definition to run it
    • put the commands to run in a local file and use plink -m {file} to run them.

enter image description here

Javaru
  • 30,412
  • 11
  • 93
  • 70