Fixing Maven 3.0.3′s dependency-resolution performance-regression
TL; DR; version: Maven 3.0.3 has a performance-regression while resolving dependencies. This is because it uses version 1.11 of aether. The problem has been fixed in version 1.12 of aether, but a version of maven with this library is not available. I built maven from source with the 1.12 version of aether, so use maven-3.0.3-with-aether-1.12.zip if you have the same problem.
The whole story: At work we use Maven to build our project. Over the last few months, we started noticing a disparity in build times between different developers even though the hardware they were using was similar to each other (Core i7′s with 6 Gb RAM). Initially we suspected that it might have to do with SSD performance-degradation. Some of us were using SSD’s that didn’t support TRIM and others didn’t have TRIM enabled. I was one of the few with the former problem. I secure-erased my drive but still saw no performance benefits. I even got a new drive and even with that I didn’t see much of an improvement either.
We finally realized that the build-time disparity was related to the version of maven some developers were using. On maven 3.0b1, build times are much faster compared to 3.0.3. In 3.0.3 there is a performance regression when maven tries to build the dependency graph. For example, using 3.0b1 our project built in 3 minutes and 30 seconds, whereas using 3.0.3, the build times were upwards of 9 minutes. Long build-times take away from the amount of productive coding-time a developer has.
I was determined to find the reason for this performance regression and did some investigation by looking at the source for 3.0b1 and 3.0.3. In 3.0b1, maven uses its own code to resolve dependencies and build the dependency graph, whereas in 3.0.3 it uses the aether library. For more background information on the matter, take a look at this post on the maven developer’s mailing list and this JIRA issue.
Long story short, to get better build times, maven needs to use version 1.12 of aether. I downloaded the maven source and edited the pom.xml file to use version 1.12 of aether. I then built maven from source and got a deployable version that uses the newer aether library. When I tested it out, the build times were comparable to 3.0b1.
I initially thought that version 3.0.4 of maven would include version 1.12 of aether. But it turns out that there were licensing changes and so the maven developers are discussing whether to include it. In the meantime, you can use this version of maven that I built from source, which includes version 1.12 of aether. It’s a zip file and you can install it like you would normally install maven.
Popularity: 3% [?]
Generating API Documentation from XML using XSLT
I work at Infusionsoft, and we offer our customers API access. Visibility and access to the various tables and their fields is controlled by an XML file on our end. Naturally, our customers require user-friendly documentation that tells them what tables and fields they can access and in what manner. Previously, a former developer had written a maven goal that would generate the API documentation from the XML file. Unfortunately this was something that he did on his own and the code wasn’t in our subversion repository. When that developer left, we decided to take a look at the code to see if we could continue generating the documentation using the maven goal. We determined that the original solution though helpful, involved a lot of work in Java simply to generate API documentation. This was when I suggested using XSLT as it would be a remarkably lightweight solution and it is also perfectly suited to this task. My colleagues agreed and so I decided to go ahead with the task. There was one slight problem though. I had very little experience with XSLT! But how hard could it be? I love learning new things anyway!
Read more »
Popularity: 5% [?]
Implementing JSONP in Spring MVC 3.0.x
In Spring 3, it’s very easy to get a view to return JSON. However, there is no built-in mechanism to return JSONP. I was able to find a pretty good tutorial That uses Spring’s DelegatingFilterProxy. I implemented this solution and I got it to work, but I didn’t like the fact that I had to create a separate filter and a bunch of other classes just for that. I also wanted to use a specific extension (.jsonp) for JSONP just to make it more explicit. Spring uses MappingJacksonJsonView to return JSON. I figured that I could extend this view and have it return JSONP instead of JSON.
Read more »
Popularity: 14% [?]
How a Wired article sent the price of Bitcoins skyrocketing
Disclaimer: I am not an economist and I do not claim to have more than a freshman level understanding of it either. Economics was not my favorite subject and I often find it perplexing. What follows is only based on observation; I may not have considered all variables (mainly due to my ignorance of them). Either way, I thought what happened was pretty interesting. If there are any errors in my assumptions or observations, please feel free to correct me.
Bitcoins are a digital currency. Bitcoins aren’t issued by a bank or a central authority. Instead they are generated by computers when they solve complex problems (for more details, go here and here). I haven’t really read all the details about bitcoin exchange rates and how the bitcoin economy works, but at the very least I know that it does follow the law of supply and demand. So when demand increases and there is a fixed supply, the price will increase (bitcoins are constantly being generated, but it appears that demand is outstripping the rate of generation).
About two weeks ago is when I first decided I would try and get some bitcoins of my own. I decided I would try to generate them and assumed I would have some pretty soon (but I obviously didn’t know the details; it’s a little bit like winning the lottery). So I joined a mining pool online at bitcoinplus. I’ve around .04 bitcoins right now (not much). This was obviously taking too long so I thought about looking into buying some bitcoins. I checked the price over a period of days, it was hovering around $8/bc. I didn’t buy any and decided to check up on it later. A few days later (on the 3rd), I checked again, and this time the price had jumped to a little over $14/bc! What caused this spike? A day later, the price spiked again. This time to about $19/bc! I wasn’t sure what was causing the spike because the price had been more or less stable for the last few weeks.
That’s when I came across this Wired article that my friend sent me. It’s about an underground website (that is also anonymous) that lets you buy any drug. The drugs are priced in bitcoins. It would seem that there are a lot of people interested in buying these drugs and therefore these people require bitcoins. I’m theorizing that this is what led to the increased demand for bitcoins and hence the spike in bitcoin prices.
The Wired article was posted on the 1st of June. You can clearly see from the following charts how the price of bitcoins jumped on that one day (it’s about a jump of 30% on the 1st). The biggest spike was on the 4th; essentially a price increase of approximately 350% in just four days! Since the 4th, the price seems to be slowly coming down. Currently it’s sitting at around a little over $18/bc. I’ll probably keep a watch on the price of bitcoins over the next few days to see what happens. I’m assuming that the demand will die down and therefore the prices should eventually come down as well. Looking into this has actually ignited some interest in me to learn a little bit more about bitcoins and the bitcoin economy.
Normally you hear of currency values and stock prices rising on falling based on events in the world (positive or negative). It’s amazing to see how one little thing can change the prices of commodities. In particular, I found this (bitcoin) example particularly interesting because it’s a relatively insulated economy (i.e., it doesn’t seem to be affected by factors in the traditional market).
tl;dr version: Bitcoin prices were hovering around $8/bc. They jumped to $19/bc when Wired magazine posted an article about an underground market where you can buy illegal drugs using bitcoins.
Update: I was looking at closing prices and so it was showing only prices from the end-of-day. Here’s a chart that includes yesterday’s data. The closing price was a little over $30/bc. That’s an almost 700% increase since the 1st!
Popularity: 6% [?]
Ghost in the Machine
Yes, I know this is not a very original title, but it’s all I could think of. I’m a skeptical person (being an engineer and all) and although I love reading and listening to ghost stories, I’ve always thought that there is a scientific explanation for supernatural stories that I’ve heard. I don’t believe in ghosts either. If there is no explanation, I just chalk it up to coincidence or observer bias.
That’s what I thought until I experienced the following. Even though I still think that the vast majority of ghost stories and supernatural occurrences have real-world explanations, I am willing to concede that there may be things out there that cannot be explained. Now on to my story.
Read more »
Popularity: 3% [?]
Integrating Regula with Spring 3.0.x MVC
A little less than a year ago, I released Regula, an annotation-based form-validation written in Javascript. The source and documentation are available on GitHub. I started working on the integration on and off throughout most of last year. At the end of the year, I had a pretty good integration going, where you could annotate fields with Hibernate Validator annotations, and the corresponding Regula validation-code would be generated on the client side. Of course, I wasn’t done yet because what I had was simply a demo project and I had to figure out a good way to distribute the whole thing; I was able to finish up the packaging and distribution today. With minimal setup, you should be able to get started with Regula and Spring. You don’t need to go through this post to figure out how to use the integration. This post is mostly about how I accomplished the integration (I don’t go into all the details; just the important bits). As far as actually using it, I will make a blog post about it later.
The source for the integration is also hosted on GitHub. My approach towards translating validation constraints from the server-side to the client-side was two-fold: gather validation constraints from the object and represent it in a canonical form. Using the canonical form, generate Javascript code that uses Regula for validation. To do this, I created a service that examines a domain object and gathers all information regarding its properties and validation constraints. The service returns this information in a canonical form, that I then inserted into the model. On the client-side, I had a tag that used the canonical form and outputted Javascript that uses the Regula framework. Initially, I was calling the service explicitly from an action in the controller. Later, in an effort to make the integration less-invasive and more seamless, I used an aspect-oriented approach with interceptors. In fact, that’s where I’d like to start.
Read more »
Popularity: 5% [?]
Packaging and distributing taglibs in a JAR
This is more of a “note to self” than a “how to”.
If you’re trying to distribute tag files in a JAR, you need to put them under /META-INF/tags. You then need to create a TLD file that you also put under /META-INF/tags. If you have tags or functions that you created in Java, and want to distribute them alongside the tag files, you need to reference them in the TLD and package them in the same JAR (goes without saying).
If you want to do the same thing in maven, the location for the tag files and the tld file is different; you need to put them in src/main/resources/META-INF/tags. Then you can run mvn package and maven will create a JAR with your tags.
Read more »
Popularity: 5% [?]






