In today's video, I'm going to show you how to configure JRebel with your Apache Tomcat server. In the first part, I will cover how to set up your project with JRebel. And in the second part, I will cover how to set up JRebel on your Apache Tomcat server.

If you need background information on Tomcat first, check out our What Is Apache Tomcat? blog.

Step 0: Download JRebel Plugin

Before you start with the configuration, please make sure that you have downloaded our JRebel plugin for your IDE. The plugin is available for all major IDEs. In case you are using Intellij, as I do, just open the Preference window, then go to the plugins, and under Marketplace, just search for JRebel. Once shown, hit the Install button, and that's it.

Step 1: Project Configuration

Let's now start with the first step, and that is project configuration. JRebel needs to know where are your sources, and it uses the configuration file called Rebel.xml for this. The file can be easily generated by the IDE plugin. In your project explorer, just right click on your project name, select JRebel, and then enable JRebel. 

As you can see, the configuration file is generated. This file needs to be in your artifact file, so make sure to rebuild and redeploy the application now.

Step 2: Start Tomcat With JRebel Agent

The second step is to start Tomcat with the JRebel agent attached. If you added the Tomcat server to your IDE and start the application with an IDE, as well, just simply use one of the two new buttons to start the Tomcat with JRebel in normal mode or in debug mode. The buttons can be found here. This will attach the agent automatically. You can verify that the server has JRebel enabled by checking the very beginning of the server output. If the JRebel is enabled, we can check that, you should see a JRebel banner with the version printed out and also with other information. 

Step 2A: Modify Startup Script

Okay. If the Tomcat server is running outside the IDE, you need to modify the startup script. Open up the JRebel configuration window in IDE by clicking on Help, on JRebel configuration, and then under JRebel, clink on JRebel startup. At this place, you can find instructions on how to set up JRebel for your specific environment. In this case, let's select that I run locally from command line, and my target environment is actually Tomcat.

The instructions are here. You can directly attach the agent argument to your startup file, or you can follow the instructions here. Let's now follow the instructions. So the first step is to create a file in the Tomcat folder and then put their following content. I'm going to copy out the content first. And now, as you can see, I'm in the folder with the startup scripts, which is Apache-Tomcat/bin. In this folder, I need to create a file here. The file is called, but you can use any name. Once the file is created, we need to open the file.

I'm going to put the configuration from my clipboard here, and save the file. Because I'm running the Unix system, I also need to allow to execute the file like this. So the file now should be executable. 

Wrapping Up

Well, all is set. Now you can just start the server with the newly created script. The server is starting. And you can see that the JRebel agent is attached, because the banner with the version and other information is printed out into the terminal window. So that is how you set up JRebel with your Tomcat server. Thank you for watching.

Additional Resources

Looking for additional resources for JRebel and Tomcat? Please be sure to visit our documentation page for a detailed, text-based walkthrough.

Want to try JRebel on your project? Try it free for 10 days with a JRebel trial. Click the button below to get started.

Try JRebel Free