What to do when Gradle raises unexpected NoClassDefFoundException

I have just lost an hour thanks to some obscure bug in Gradle caching mechanism. If all of the sudden, Gradle raises Frankenstein errors at you like $ gradle clean build :buildSrc:compileJava UP-TO-DATE :buildSrc:compileGroovy Note: /Users/manu/projects/notbackedup/git/core/buildSrc/src/main/groovy/org/hibernate/gradle/testing/database/DatabaseMatrixPlugin.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. >>> a serious error occurred: hudson/util/DBAllocation >>> stacktrace: java.lang.NoClassDefFoundError: hudson/util/DBAllocation at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2427) at java.lang.Class.getDeclaredMethods(Class.java:1791) at org.codehaus.groovy.vmplugin.v5.Java5.configureClassNode(Java5.java:318) at org.codehaus.groovy.ast.ClassNode.lazyClassInit(ClassNode.java:263) at … [...]

Script to hot switch JDK versions in Mac OS X terminals

Personal note. Here is a script that lets you switch your JDK version in a terminal window. It also has auto completion. Put the script in a file and add source filename in ~/.profile or ~/.bash_profile and you will be able to call setjdk and use autocompletion (with <tab>) from the command line. emmanuel@computer $ setjdk 1.<tab> emmanuel@computer $ setjdk 1.5 Original … [...]

IntelliJ's Live Template

If you remember, I like to write my getters this way (long story here) public String getName() { return this.name; } public void setName(String name) { this.name = name; } private String name; I have been doing it manually for a while but it turns out IntelliJ has a super nice feature for that: Live Templating which allows … [...]

Getter / Setter generation in Java

Eclipse or IntelliJ typically generate getters and setters this way: public class Month { private String name; public String getName() { return name; } public void setName(String name) { … [...]

Book review: Dependency Injection by Dhanji Prasanna

Over the last few days, I have been reading Dependency Injection by Dhanji Prasanna published by Manning. I must admit, this is a much easier task than writing Hibernate Search in Action ;) Summary first: very easy to read, a gold mine of knowledge and tips on a subject that is essential to the life … [...]

Lies, damned lies, and statistics: EE edition

I came across some figures regarding downloads of Glassfish and JBoss AS that really puzzled me. Basically Glassfish was downloaded 700.000 times a month (end of ’08) while JBoss AS was only downloaded around 115.000 times a month at the same. My first reaction was “Well done to you, Sun!” and then I realized … [...]

Java generics end of mystery

Remember my puzzlement in front of http://blog.emmanuelbernard.com/2009/04/java-generics-mystery.html? I usually try to make sense of the unknown type by looking at what should be allowed when two incompatible types are used as the unknown type, and then using the generic type using the unknown type as a reference to a known type to see … [...]

Java generics mystery

Here is a puzzle for Generics gurus.Can somebody explain why Set<Address> addresses = new HashSet<Address>();Set<?> things = addresses;compiles but Set<ConstraintValidator<Address>> validatedAddresses =     new HashSet<ConstraintValidator<Address>>();Set<ConstraintValidator<?>> validatedThings =    validatedAddresses;does not compile?More specifically, the assignment on the second line breaks. [...]

Oracle is buying Sun: best quotes of the day

Alex Miller: “Next version of Java will be Java SE 7.0.0.0.17832″Emmanuel Bernard: “The day an Oracle swallows the Sun and in front the Business Machine. No kidding it’s a Titans fight.”Max Andersen: Thinking when Orsun will introduce a String in Java that says null == “”Alexis MP: “Checking my blog posts tagged with “oracle”. … [...]

Les Cast Codeurs Podcast is born

I have just started a new podcast with a few French open source activists. All about Java, all in French. If you know French, read on ; otherwise, well… learn :) Les Cast Codeurs Podcast est dans les bacs!Le podcast en français dans le code sur Java par Emmanuel Bernard (JBoss, Hibernate), Guillaume Laforge (SpringSource, … [...]