The battle against redeployments reaches the clouds

    The author of this article is our friend and user of the Jelastic platform - Anton Arkhipov. Anton currently holds the position of JRebel product manager at ZeroTurnaround , and is also a co-founder of the devclub.eu and JUG.ee developer community .
    The English version of the article can be read here .

    imageYou may not have heard of a product like JRebel. So, JRebel is a tool designed to eliminate the problem of redeploying an application during development, and to save your time. It updates the application immediately after making any changes to the class structure, resource files, and framework configuration files. It should be noted that this tool is very popular among Java developers. And not in vain, because using JRebel, the developer gets rid of the need to reassemble and deploy the application. At the same time, it saves an average of 10.5 minutes per hour of coding, according to the latest report on JavaEE productivity. This is more than 5 weeks of work every year - which means more than 1 monthly salary of each developer in the team.

    Most recently releasedJRebel 5.0 . The main feature of this release is the JRebel Remoting function , which allows you to use JRebel in cases when the application is running in the cloud.
    With this feature, it will be very simple to develop and test Java applications in the clouds. Let's look at how to install and configure JRebel on the Jelastic cloud platform.

    Install JRebel on Jelastic

    First, you need to create an environment that you will use to host your application. Let's take Tomcat as the application server, which is the most widely used server according to Developer Productivity Report 2012 .

    image

    After creating the environment, you can proceed to install the JRebel agent. To do this, download jrebel.jar . And do not forget about the license file, which should be located in the {user.home} /. Jrebel folder .

    image

    Jelastic introduced support for JVM custom properties a few months ago, and we will use this feature to configure JRebel. To do this, we need to make some changes to the variables.conf file .

    image

    Besides-javaagent parameter in order to ensure the work of JRebel Remoting, we need a JRebel remoting plugin . We connect it using a special JVM argument:

    -Drebel.remoting_plugin = true

    Now we can view the JRebel logs to make sure that the installation of this tool was successful. Remember to save all changes and restart Tomcat to apply the new configuration settings.

    Note! The installation procedures for JRebel for Jetty and Tomcat are practically the same. But GlassFish uses domain.xml or admin panel instead of variables.conf .

    Application configuration

    JRebel Remoting requires two config files to work: rebel.xml and rebel-remote.xml . JRebel requires a rebel.xml configuration file so that class loaders can see the changes made to the project files directly.

    Rebel-remote.xml is required for remote work. This is a very simple configuration file containing two parameters, the module ID and the URL at which the application is available.
    Both configuration files can be generated using the JRebel plugin for Eclipse, which is available in the Eclipse Marketplace .

    image

    JRebel Remoting in action

    When both files are generated, you can collect the project in a war archive and deploy it to the Jelastic environment.

    image

    Let's make changes to the project to test how JRebel works.

    image

    For example, change the first page (welcome.jsp). Let's write instead of “Welcome” - “Welcome to Jelastic!” and call the “Sync Now” method provided by the JRebel IDE plugin to update our application.

    image

    After that, the following message appears in the IDE console:

    Manually triggered JRebel remoting synchronization.
    Scheduling JRebel Remoting synchronization for projects: petclinic
    Starting manual synchronization for project: petclinic
    Parsing configuration for /Users/anton/work-src/petclinic
    Directory target/classes/ will be used for uploading
    Directory src/main/webapp/ will be used for uploading

    JRebel-Remoting uploaded changes successfully, have fun!

    As a rule, it takes about a second to upload changes to the server, but this, of course, depends on the connection. After completing synchronization, refresh the page - and voila!

    image

    JRebel Remoting is currently supported by the IDE plugin, which is available for Eclipse, plugins for IntelliJ and NetBeans will be available soon.
    FROMJRebel 5.0 and Jelastic have the opportunity to work both locally and remotely without the extra time spent on redeployment. Try and share your opinion in the comments on this post. We will be very grateful.

    Also popular now: