Latest news

JavaRebel 1.2.1 and Spring Plugin 1.0-M2 Released

We are very proud to present not one, but two simultaneous releases....

JavaRebel used to develop LinkedIn

LinkedIn, Corp. has purchased JavaRebel licenses for all its Java engineers to use in the well-known social networking website dev...

JavaRebel 1.2: Now With Full Spring Support

The latest stable release of the JavaRebel code reloading agent includes a plugin for Spring that reloads Spring configuration on-...

Archive for the ‘blog’ Category

Improving Java Development — An Open Letter to the Java Community

Tuesday, February 5th, 2008

Dear Java Community,

For some time we at ZeroTurnaround have been working on decreasing development turnaround time. Our flagship product, JavaRebel, has more or less solved the problem of reloading all changes made to Java code on-the-fly. However, this is not enough.

Java frameworks use configuration files, annotations and other methods to configure themselves. This is where JavaRebel loses its effect as configuration is always cached somewhere and usually not reloaded until the application is redeployed. This can be overcome by tighter integration with these frameworks.

With the release of JavaRebel 1.1 M1 we finally have full support for annotation reloading. We have also released an open source SDK that can be included in any open source project. The SDK will trigger registered listeners when the classes are reloaded allowing custom handling to occur. The integration is then just a matter of reloading configuration in development mode.

Using the annotation reloading and the SDK we have so far succeeded in integrating with Google Guice and Stripes Framework. Now almost all changes made to the applications using those frameworks are reloaded instantly. In addition to that Ignacio Coloma grabbed the SDK almost before its release and integrated the Loom web framework during the weekend. All three integrations took less than a day’s work.

It is our belief that providing such integration will greatly benefit the whole of the Java community. It is not unlikely that one day JavaRebel-like functionality will make it to the JVM and the users will be able to benefit from the integration without using a third-party product. Until then we invite you to help us define an open API for the class reloading and implement the integration for the framework you like, use or develop.

If you are a developer or a user of a Java framework of some sort and you would like to see the on-the-fly reloading in that framework happen you need to step up and make some noise in the community. We will continue investing into integration with frameworks, but we are limited by the frameworks that we know or our clients demand.

To facilitate the exchange of ideas and information we have setup a community mailing list and a Google Code project. Both framework developers and users are welcome to join and discuss what can be done to further improve Java development turnaround time.

To support this vision we are now giving free JavaRebel licenses to all open source developers.

Cheers,
ZeroTurnaround Team

JavaRebel 1.1 M1 Released

Tuesday, January 29th, 2008

A first milestone of the development branch is available. The following features are included:

  • Improved reflection support. Now added/removed methods and fields in the reloaded classes will always be reflected correctly in the Java Reflection API. At the moment this does not include constructors.
  • Annotation reloading Annotations on classes, methods and fields will be updated when the class is reloaded. At the moment this does not include annotations on constructors and method parameters.
  • JavaRebel SDK For integrating custom frameworks with JavaRebel and getting the next step in turnaround time check out the SDK at our Google Code project.

Developing in Exploded Format

Monday, January 28th, 2008

We have had quite many support requests on how to use JavaRebel in different configurations. Either users have one Eclipse project from which they deploy three applications or the other way around, generating one project from multiple projects. Standard approaches (at one point copying or zipping into one archive and deploying) are quite slow in these circumstances and only provide a way to distribute the application and do not concentrate on how to make the developers’ work hours more productive.

In this article we will look at different configurations and see how to configure projects so that we do not spend too much time on building and deploying but developing the applications.

Sample Configuration

We will be developing a web application named WebApp and an accompanying library called OurLib. The WebApp depends on OurLib and we want to take advantage of exploded format in development.

Folder structure

WebApp/

  • src/ - Source files with top level package com
  • bin/ - Eclipse build folder
  • lib/ - Buildtime & runtime libraries
  • tests/ - Tests’ source files
  • etc/ - Configuration files
  • dist/WebApp.war - Distributable artefact generated by build cycle.
  • dist/WebApp/ - Distributable artefact before packing generated by build cycle.

It is better to use a more logical folder structure for web applications. One that has an application folder that can be deployed straight to a container. Then it is easier to separate buildtime and runtime dependencies and limits the need of constructing a special distributable folder during build. In this article will use the given structure though.

OurLib/

  • src/ - Source files with top level package org
  • bin/ - Eclipse build folder
  • lib/ - Buildtime & runtime libraries
  • etc/ - Configuration files
  • dist/OurLib.jar - Distributable artefact

Configuration

We will be deploying the WebApp to a Tomcat web container and Weblogic Server 9.2 . OurLib has to be accessible from the WebApp . We will be using Eclipse for development, Apache Ant as a standard building tool and the developers will be using either Linux or Windows (NTFS filesystem) environment. Eclipse is configured to build files automatically (from the Eclipse menu Project » Build Automatically is checked).

Build Automatically Checkbox

Typical Building

OurLib has a build.xml with target dist. It will produce a single JAR file in the dist folder. The target compiles the source files with the necessary flags, attaches the configuration files and archives into a JAR file.

WebApp has a build.xml with target dist. It will produce a single archive, in this case a WAR file. Consisting of the compiled class files, configuration files, static pages and so forth.

The OurLib.jar ends up in dist/WebApp/WEB-INF/lib either by WebApp’s dist target (has configured the OurLib location) or by OurLib dist target.

The WebApp.war ends up deployed in both application servers. This can be achieved manually (in WebLogic it is dozen of clicks) or automatically through the WebApp build script.

Developers perspective

On every deployment the following tasks happen:

  • Source files are built
    • Longer approach but universal: javac task is invoked to compile the source files
    • Usually quicker: IDE’s output folder is used
  • Built files are aggregated into an archive
    • Involves copying of files
    • Files are zipped into a single archive
  • WAR archive is deployed
    • Archive is copied to the container’s folder
    • Archive is unpacked to a temporary folder
    • Deployment of the temporary folder.

As we can see there is just too much overhead from doing repetitive tasks that we can avoid. I did not include the steps that need to be taken to build the OurLib project or deployment to the other container too. We are compiling code twice, we are packing and unpacking an archive, we are copying files from one location to another, we are losing the session in the web application. Hopefully the deployment cycle is done through the build script. We would otherwise be clicking our way through endless dialogs to make the container understand how certain we are about the redeployment.

How long does it take? Depends on the size of the application. Probably from 30 seconds to some tens of minutes. Even 30 seconds stack up to a lot.

Exploded format

We can lose copying, packing, unpacking from the cycle in different ways. The main difference will be that we will start deploying an application as a folder instead of a WAR archive. To redeploy, one has to touch web.xml or hit Redeploy/Reload in the respected web interface.

With Weblogic deploying in exploded format is done the same way as deploying an archive. Instead of the WAR file you specify a folder. Weblogic will highlight a folder deployable if it has the WAR or EAR folder structure.

With Tomcat it is done by copying the folder to TOMCAT_HOME/webapps.

Application configuration

We need to produce the deployable folder from our project. The structure must be as follows:

  • WEB-INF/
      classes/ - compiled class files
      lib/ - runtime libraries
  • web.xml

This can be achieved by making the build script create the folder structure, copy runtime libraries, compile source files and copy configuration files. The folder can then be deployed to a container. We could have structured the project to include such a folder
and keep the runtime libraries and configuration in such a folder structure already. This time we did not.

Next we will look at some examples of how we can configure the project so that seeing changes made to the source files will not require other operations than just hitting refresh in the browser.

Example

Eclipse is building class files to folder bin. We use dist/WebApp as the folder we deploy to Tomcat or Weblogic. We will use an ANT target that will makes the folder structure of the application (copying the class files from the IDE output location, lib files and configuration files to dist/WebApp respective folders). The very same target can be later used to zip the folder into a WAR file.

On every deploy we save the time of zipping and unzipping our project and depending on the configuration even the compiling. To deploy the application we click reload/redeploy in the application server.

Example With a Twist

We use a set of symlinks to completely lose the copying part and even invoking ANT. We will symlink the IDE’s output folder to dist/WebApp/WEB-INF/classes. The libraries will end up in dist/WebApp/WEB-INF/lib. Either the whole folder or just a subset of the libraries.

Now we have a configuration that requires no copying or invoking ANT. If we need to see the output in the browser we just have to redeploy the application. Now we are only losing the session in the application.

Example Without Redeploy

We will add JavaRebel to the equation and lose the redeployment part. As we are deploying everything as class files we can configure the server to use JavaRebel. See the installation documents for different containers.

Now we have a configuration that requires only a refresh in the browser to see any results.

What about OurLib?

OurLib can be deployed without zipping it into a JAR archive. The easiest way is to just symlink the IDE’s output folder to the WebApp’s deployment folder’s WEB-INF/classes. As we are probably already using a symlink for the WEB-INF/classes we have to make it a bit more granular. So for the WebApp we actually symlink, lets say, the toplevel package. So Webapp’s bin/com gets symlinked to dist/WebApp/WEB-INF/classes/com and OurLib’s bin/org gets symlinked to dist/WebApp/WEB-INF/classes/org.

Symlinks Under Windows

Now if we want to see changes made to the library that we are using in our WebApp we just make a change, save the file (Eclipse is compiling in the background) and hit refresh in the browser.

Summary

Achieving shorter turnaround requires the developers to know the tools available to them. Projects use very different folder structures, build scripts and have different type of dependencies. Still developers can make their life easier with a set of tools and a bit of imagination.

Eclipse

Compiling can be done in the background and the resulted class files can be used for deployment. This is a real time saver.

Custom builders can be defined that run before or after every build. They can be made to copy some deltas or touch configuration files or actually everything. Here is how you create a project builder Ant buildfile.

Different source folder can have different output folders. E.g. the project has different folders for source files and unit tests. They can be compiled into different folders. Project properties » Java Build Path » Source Tab » Allow output folders for source folders checkbox.

Multiple Output Folders

Symbolic Links under Linux & Windows

Projects’ location and structure differ from the deployment counterparts. They can even be in a 1-n relationship. This is where symbolic links come into play. One can link directories or files to other places on the filesystem thus keeping the data in one place but available to different applications. Creating and managing links differ for operating systems, they are even named differently. See Similar Concepts from Wikipedia symlink article for more information. Mind that symbolic links are not something that only Linux users have, Windows has them too (comfortable and secure managing of them requires a freeware application though).

JavaRebel

Developers don’t have to restart a container or redeploy an application to see their code change in action. Make a change, compile the code and JavaRebel will pickup the changes. See the screencast for more information.

JavaRebel 1.0.2 Released

Thursday, January 24th, 2008

Another minor release with some fixes. Grab it from downloads.

JSPWeaver 1.0 released

Tuesday, January 22nd, 2008

JSPWeaver interprets the JSP markup on-the-fly instead of producing and compiling Java code. This reduces JSP reload times in development from tens of seconds to milliseconds.

The final release incorporates performance and stability improvements. JSPWeaver now supports the full JSP standard including common syntax, XML syntax and Java scriplets and is completely container-agnostic.

Installing JSPWeaver is as easy as dropping a JAR into WEB-INF/lib and registering the servlet in web.xml. Download it from ZeroTurnaround and give it a try.

Disclaimer: JSPWeaver is commercial software with a free trial for 21 days and developer seat cost at 49$.

GlassFish problems, take 2

Wednesday, December 19th, 2007

It looks like our problems with GlassFish have just began. Whereas the installation issues found a quick solution, we almost immediately ran into a year old problem, reported by the guys from YourKit. The issue is with with loading the “ServerLogManager” class (see also this forum post).

A quick foray into the JDK source shows that log managers are loaded from the system classloader and then from the Thread context classloader. Of course in case of GlassFish the manager is not in the system classpath, but instead found via the context classloader. However the context classloader is set only after GlassFish initialization begins, so any agents that need to access Java API before that are left in the void (both YourKit Profiler and JavaRebel feature instrumentation agents, which are initialized before the actual application begins execution).

To be fair this is a definite failing in the JDK log manager resolution logic. Since log managers are determined using a system property it is dangerous to assume that their resolution is in any particular context (which context classloader obviously implies). GlassFish just happened to hit this case, since very few others use a custom log manager for the JDK logging. The only reasonable fix I can see here is lifting the ServerLogManager to the system classpath and decoupling it from the child classloaders.

For those who can’t wait until it’s fixed it seems that adding “-Drebel.disable_update=true” to the jvm-options also fixes the problem for JavaRebel (it disables the update notification, which is apparently the only thing in JavaRebel that utilizes JDK logging).

Article: Life outside the IDE

Tuesday, December 18th, 2007

Writen by one of the first JavaRebel users, Nathan Hamblen, this JavaWorld article talks about building applications with a text editor, Buildr, Jetty and JavaRebel. Bringing examples from Wicket and Scala applications it is worth a read whether you plan to develop without an IDE or not.

JavaRebel 1.0.1 Released

Monday, December 17th, 2007

JavaRebel 1.0.1 includes support for GlassFish v2 or later and some minor fixes to reflection support.

Glassfish Installation from Hell

Thursday, December 13th, 2007

Disclaimer: Since some of you took this personally I want to make a few things clear. This is not an attack on GlassFish or its community. This is just a recap of my personal experience with installing it and the resulting frustration. This could be avoided in the future with a couple of simple fixes.

I just had the weirdest installation experience ever. We are trying to get JavaRebel to work with Glassfish and for that, of course, we need at the very least to install it.

After downloading the JAR I assumed that it will be the usual self-extracting installation package, like the one JDK comes with. When I ran the JAR it displayed a license agreement dialog and vanished with no message of any kind. I assumed that perhaps it’s not a self-installing JAR after all and needs to be unziped manually. Inside the JAR I found a single “glassfish.class” over 50 MB large. After some thought I found out that it unzipped itself in the current directory (which just happened to be my “download” dir with about a hundred other folders). Finally I could start using Glassfish!

Quickly it turned out I was wrong. There was no kind of executables or scripts of any kind that I could start the server with. Of course the first thought was that the extraction process did not finish (remember the lack of message or progress bar). After reiterating through the same process twice I googled for “glassfish quick start” (there was no installation guide with the distribution that I could find). Although it didn’t really talk about installation, it mentioned in passing that I should have ran “ant -f setup.xml” at some point. Turned out this was what extracted all of the scripts and everything else.

So the real question I want to ask is why can’t I just get a ZIP, unzip it and run?

UPDATE: although GlassFish now runs fine when I tried to deploy the Java EE tutorial sample applications it turned out that’s nearly impossible without NetBeans (all build scripts are bound to the .nbproject or somesuch). Is there no end to this torment? I understand that Sun favors NetBeans, but why tie everything to it?

UPDATE 2: Toomas got GlassFish running before me and support is included in the JavaRebel 1.0.1 release. Enjoy!

Cartoon: Story of a Java Rebel

Thursday, December 6th, 2007

In addition to the final release we are proud to present the first ZeroTurnaround animated short. It tells a story of an enthusiastic Java programmer who found JavaRebel and how it changed him forever. And you may just know that guy :)

We would also like to apologize to the DZone community, which saw the said short mislabeled as pure entertainment. Yes, this is a promotional animation and it should have been labeled as such and we are very sorry for doing just the opposite. Regrettably DZone does not provide a way to change title or description after submission.