@cervenkap: so the fix is working to the extent that the Maven process is switched to a usable Java 6 JRE, but the attempt to configure it for JDK 5 development is not working. Please do some investigation and file a separate JIRA report “blocking” this one:
1. Run Maven with -X and confirm that maven.compiler.fork=true and maven.compiler.executable=…/jdk5/bin/javac, and that the effective mojo configuration for compiler:compile shows fork and executable parameters correctly set, and check the logged command line which runs javac which should be using the JDK 5 version. (Can also check Surefire configuration: jvm should be …/jdk5/bin/java.)
2. Check a current version of the Compiler plugin (2.0.2 is quite old), as well as checking Maven 3.x rather than 2.2.1, to see if these versions are triggering your issue.
3. If running the build on the master, try on a slave, or vice-versa.
(If your build which worked on JDK 5 is failing on JDK 6, I assume this means you are implementing one of the JDBC interfaces to which methods were added, or something along those lines, since normally JDK upgrades are compatible for compilation.)
A pull request would be great, though with a clear diagnosis of what is going amiss in your environment a fix is probably easy to write.
(BTW: <optimize>true</optimize> is essentially useless for modern JDKs.)