Category Archives: Java

Atlassian tools for $10 bucks!

Don’t know if you saw this or not, but Atlassian has released a new version of their bug tracking tool JIRA and on top of that, they’re selling each of their products for $10 bucks (so called ‘starter‘ licenses).

I didn’t realize this until now, but they also have an agile project management tool called ‘GreenHopper‘ (which looks a lot like Mingle to me – in fact it looks like ThoughtWorks and Atlassian are duking it out product to product).

The best part is that for $10, you get 10 licenses!

I’ve used JIRA quite a bit and its not bad. I really don’t like any defect tracking software (most of them have a lot of noise for little information). However, JIRA ties in nicely with their build server Bamboo and that is huge. Being able to say what defects went into what build without manually tracking build numbers, subversion revision numbers, release numbers, etc provides a lot of value. It automatically answers the question “what’s in the latest build?”

If they’ve integrated GreenHopper in the same fashion, that would also be huge help.

In general, I’m more of a fan of whiteboards, index cards and information radiators. But, if you have a distributed team, Atlassian’s product suite for 10 bucks is definitely worth evaluating.

Spring 3.0 – Interesting after all…

Spring 3.0 RC1 is out!

I’d initially thought Spring 3.0 was a bit of a “yawn”. The previous posts on it left me underwhelmed (and… to be honest my interest in new technologies has been elsewhere.

However, Juergen’s latest post has me a bit intrigued.

Yeah there’s support for JEE6, Portlet 2.0, full Java 5 support and their “Spring expression language”. Blah…blah… Still awake? Yeah… me neither.

But, its significant additions to the annotations for “declarative model validation” and advanced binding for Spring MVC (again through annotations) that are really interesting to me.

The guys at Spring can do a better job of explaining than I can so see here and here.

This looks really interesting and provided there are a bunch of standard validation and formatting annotations included with Spring 3.0, it would be immediately useful on my projects. A clear and consistent place to put validations and formatting details where they make the most sense.

I know some people might think that placing that information (especially the formatters) into your model is a violation of separations of concern. But, I don’t see it that way. The formatting is still handled by a separate class (the annotation) and in any app there would have to be some mapping between the model and how its formatted for the screen. I see these annotations as an elegant solution (if Java can be elegant ;-)).

Have you looked at Spring 3.0 yet? If so, what are your thoughts?

Java is fading…

Earlier this year came the news that Oracle was buying Sun. And now this?

After today’s news, it sure looks like its going to happen sooner than later. What next? IBM sells off its application servers and Rational software to Microsoft?

Java has already grown rather stagnant. There’s little innovation or exciting things happening in the Java world these days. The few interesting things that are out there, don’t seem to get any attention (can you say GWT?). Most of the “thought leaders” that I followed into the Java world, have moved on. I can’t substantiate it, but I wouldn’t be surprised at all to find that most of the non-corporate sponsored open source projects commit levels are a fraction of what they used to be three years ago.

One of the unique things about the Java community was that although Sun owned Java, they really weren’t a software company. Yeah… there’s Solaris, but they didn’t even know what to do with that outside of running it on their servers. Sun took an engineering interest in Java, but never did figure out how to really make money from it. That left Java fairly open. Lots of freedom for small companies to make a dent.

Yes, the big guys were there playing the Java space – IBM, Oracle, etc, but… they didn’t own it.

One thing Oracle knows how to do is make money off of software. Have you ever tried to buy a license for Oracle? Hold on to your wallet – tight! Although I’m sure Java will always be free, look for Oracle to use Java as leverage to pull you into its fold.

Furthermore, beyond the core DB server, I have yet to work with any software written by them that’s even remotely usable. Working with Oracle still brings back memories of the “Certified Novell Engineer” and the Encyclopedia Brintannica volume of books that came along with it just so you could figure out how to get two computers to talk to one another (if you’re old enough to remember those days. πŸ˜‰ ).

I just can’t see how this is good for Java in the long term.

Now SpringFramework… er… SpringSource, original antithesis to the Java Corporate community, is being purchased by a very odd suitor. What’s the point of this? More and more I feel the Spring Framework is becoming that what it was originally designed to combat – complexity in Java. When it takes a 800 page book to cover the material, its no longer simple.

Don’t get me wrong – I still like using the SpringFramework, and given that I’ve been working with it since pre-1.0 days, the complexity has been manageable. Starting from scratch is a fairly daunting task. I also believe has one of the best, most consistent APIs I’ve worked with.

Its possible that Oracle won’t change Java and its possible that VMWare won’t change Spring. Its also possible that Duke Nukem Forever will ship, but it ain’t likely. πŸ˜‰

With all this change happening and the rising interest in other languages – Java two years from now will be much different and quieter place.

What do you think?

Merging with Subversion and IntelliJ IDEA 8.1.x

A few days ago I created a branch in Subversion to work on some refactoring ideas I had. I wasn’t sure it would ever see the light of day (and I’m still not ;-)), but I wanted a “sandbox” to play in.

Today I wanted to update my branch with the changes the other developers were making in the “trunk”. In theory this should be straightforward, in practice, well… that’s another story.

The documentation for how to do branch merging with IDEA is lacking in many ways (unfortunately this is true for a lot of IDEA features :-(). There is just the most basic description of how the dialog works, but no help for the actual process of merging your code from another branch.

First, make sure the local, working copy of the project is current with no changes to it. You want to be in a “clean” state so that the only changes to your working copies are the changes made during the merge process itself.

Next, choose the Version Control/Integrate Project… option from the menu. In the dialog that appears set the “Source 1” path to the branch you’re working on. Select the revision # where the branch started (hopefully there’s a helpful note when the branch was created ;-)).

“Source 2” should be set to the path of the “trunk” with “HEAD” as the revision(remember, we’re merging the trunk’s changes into our working copy of the branch).

Next uncheck “Use Ancestry”, I’m not sure what this does, but when checked I tend to get a bunch of files reported as “different” that really aren’t during the merge process

If you want to see what files are effected by the merge without actually doing it, check the “Try merge, but make no changes” option.

Click “OK” and let it fly!

After a bit, you’ll get a report in the “Version Control” tool window that describes the files that were changed.

If at this point things look really screwed up, or you don’t understand what Subversion/IDEA did – you can “Revert” all your changes and go back to the way things were before the merge attempt.

The last step in this scenario is to commit the merge changes into your branch.

You should now be current with the changes from the trunk in your branch.

Quick Eclipse Tips

So… these days I’m bouncing back and forth between Eclipse and IntelliJ IDEA. I prefer IDEA, but my client prefers Eclipse. * sigh *

One of the things that I really missed in Eclipse was IntelliJ’s convenient “navigate to implementation” feature.

When I’m developing interface-based-design (especially when using Spring) I’m constantly wanting to jump to the implementation of an interface, but the normal way of navigating in Eclipse only takes me to the interface (holding down control while clicking on the method you want to navigate too). There are no “gutter” indicators like IDEA has.

Finally, I discovered Eclipse’s shortcut for going to an implementation: Ctrl-T!!

It may even be better than IntelliJ’s implementation… maybe.

With your cursor on the method anywhere in your code (where its declared or where its used) hit “Ctrl-T” and Eclipse will display a popup with all the classes that implement that method. Very slick!

At first I thought I was probably the only guy who didn’t know about this shortcut, but it was news to at least two of my colleagues as well… so I thought I’d share!

Also, while I’m thinking of it: Ctrl-O is another shortcut that I’m using a lot these days. It brings up a list of all the methods in the current class that can be filtered as you type.

Websphere support lacking in IntelliJ

If you’ve been following my blog, you’ve probably noticed that I’m becoming an IntelliJ IDEA fan. I’m finding that I enjoy using it more than using Eclipse.

As I mentioned in a previous post, we use Tomcat for most of our interactive development and Websphere for actual production. IntelliJ has really good support for hot-syncing web applications with Tomcat.

Given that their documentation states they support Websphere, I expected the same support as Tomcat has. Unfortunately, that isn’t the case.

On the plus side, IntelliJ does support deploying to Websphere. This actually works very well. I believe they are using Websphere’s supplied scripts for remotely deploying EAR files to Websphere. It also allows you to easily attach to Websphere and debug your code. However, it does not support hot-sycning. To do development with Websphere and IntelliJ, it requires a full build-package-deploy cycle. Even for simple JSP changes!

I was really disappointed by this and there’s nothing in IDEA’s sparse documentation to indicate the difference in the functionality. I contacted JetBrains about it. They responded really quickly (as they always do!) and understood the shortcoming. They discussed the possibility of adding into a IDEA updated, but I suspect the number of developers using IDEA with Websphere is pretty small.

Only “enlightened” πŸ˜‰ developers who are in an environment that allows flexibility in IDE choice would be candidates for IDEA + Websphere. I mean.. really… how many Websphere shops are going to allow you to install anything non-standard let alone a non-IBM endorsed IDE.

Fortunately, I’m able to use Tomcat instead of Websphere 90% of the time and can get the benefits of IntelliJ’s hot-sync. Now I’m just crossing my fingers that we don’t have to add something that binds us to running in Websphere only….

Websphere Gotchas

My current project targets deployments to Websphere 6.1. Since we’re only using the servlet container we do all of our interactive development with Apache’s Tomcat.

Since we’re using it only as a servlet container, and both products are spec compliant, we shouldn’t have any issues, right? You know where this is going… πŸ˜‰

We’ve run into three relatively minor issues using Websphere and all of them have workarounds.

Websphere caches WEB.XML
The WEB.XML configuration file that lives inside your WAR’s WEB-INF folder is cached somewhere else in Websphere’s labyrinth of folders. This becomes a gotcha when doing “hot deployment” during development and copying the changed files to the exploded WAR. Websphere will correctly refresh/redeploy changes made to most other files, but not WEB.XML. The only way that I’ve found to get your changes to WEB.XML recognized is to redeploy the application via Websphere Admin console.

Problems with Spring Security

This gotcha (and the next one) really bug me because it appears the folks at IBM don’t understand the rules for versioning software. Everyone is running Websphere 6.1.0 on our team. The developer that implemented Spring Security for our app had it working flawlessly.

However, when I ran our application it didn’t. I kept getting Error 404: SRVE0190E: File not found: /j_spring_security_check shown in the browser. It also didn’t work on our shared development server. After a couple of hours of thinking is was my problem, we discovered that the other developer hadn’t applied a couple of service packs to Websphere. Though the version was the same, the service pack was a couple of revisions different and IBM made some changes to how the Servlet Filtering works. I guess IBM felt they were being too compatible.. πŸ˜‰

To fix the problem, you need to set a custom Web Container property inside the Admin Console for Websphere. Set com.ibm.ws.webcontainer.invokefilterscompatibility=true and then Spring Security should work appropriately. For more info see this.

Websphere’s transaction manager

Not only did they change filtering behavior in a service pack, but they also added a new Transaction Manager. I originally setup our application to use Spring’s org.springframework.transaction.jta.JtaTransactionManager.

On Websphere, I wanted to use JNDI based datasources, but I could not get the JTA transaction manager to work. Fortunately it is documented on Spring’s site here in section 9.8.1. The solution is to use the Websphere specific WebSphereUowTransactionManager.

Again, IBM added significant new features to a service pack(not even a point release).

This last gotcha, caught me again, because although it worked for me, my coworker (the guy who developed the security features) kept getting errors. After fretting about for awhile, I figured out that my colleague hadn’t updated his local Websphere to the latest service pack and the WebSphereUowTransactionManager class wasn’t available. Ugh…

IntelliJ Idea 8.1 is out!

Just in case your RSS reader isn’t pointed at JetBrains’s site. IntelliJ 8.1 has been released.

I downloaded it right away (of course) and fired it up. It promptly crashed and I was about to get really peeved when I noticed if offered to blame an iBATIS plugin that I’d installed. Once I removed that from my configuration it fired up like a champ.

I haven’t done much with it yet, but it did seem to load a little faster. I’m looking forward to the improved Oracle SQL syntax (their SQL support is very slick). Also, I’m really hoping they support Websphere, but I suspect they still don’t…

MoreUnit

I try to practice TDD as much as possible (even though that can be really hard sometimes, but that’s another post…). One of the things I’m constantly doing it toggling between my class and the code that tests it.

IntelliJ IDEA had this nice plugin that created unit tests for you based on the class you were currently working in and would toggle you back and forth between the two in the IDE. Unfortunately, it doesn’t work with version 8.0 and seems to be inactive.

Since I’m jumping between Eclipse and IDEA these days I thought I look for something similar for Eclipse. I found it with MoreUnit.

OK… the name doesn’t do much for me (stop your snickering!! πŸ˜‰ ), but the plugin works as advertised and I’ve found it really useful. Using “Ctrl-J” you can toggle between your test and your class. If it can’t find your test it’ll offer to create one for you. It annotates your classes in the Package Explorer if there are tests for them and it’ll even go so far as to place a marker in the editor’s gutter to indicate if a method has a test for it.

Not all of that is useful to me per se. But… given that I tend to give my classes longish names, the editor tabs in Eclipse crop off the “Test” in the class name. I frequently end up with two tabs with the same name. Being able to toggle between them quickly is one of those “little things” that makes my day.

Little things in Spring

I’ve worked with Spring quite a bit, but its a huge and ever growing framework. Recently I found a couple of little things that are handy, but don’t seem to get much attention.

First there’s the ServletRequestUtils class. It contains a nice collection of methods for getting values from HTTP request parameters.

Here’s a simple example

public ModelAndView displayInvoice(HttpServletRequest request, HttpServletResponse response) throws Exception {
   String invoiceNumber = ServletRequestUtils.getRequiredStringParameter(request, "invoiceNumber");
   // do something interesting....
}

This code will throw a MissingServletRequestParameterException if “invoiceNumber” isn’t supplied with the request.

Its not that it takes a lot of code to write this kind of logic yourself, but its nice to avoid having to write it on every project. The only thing that its missing IMHO is that when you call getRequiredStringParameter its perfectly OK with returning a blank value. I’d prefer that it throw an exception in this scenario.

Secondly, there are some nice utility methods for unit testing Spring MVC controllers. Its mentioned in the appendix in the excellent Spring in Action book. He refers to the old-school JUnit 3.8 code that requires you to derive your tests from AbstractModelAndViewTests. However, in Spring 2.5 they have a nice JUnit 4.x helper class. It provides direct support for testing the view and model ensuring your controller is meeting its obligations.

Again, its not like you couldn’t write this stuff yourself, but its nice not to have too. I had a dozen tests written for my controllers that were filled with extra code that this helper class eliminated.