java.lang.Exception: Method XZY should have no parameters

Did you ever stumbled across the following error during developing test-cases with JUnit and JMockit?

java.lang.Exception: Method XZY should have no parameters

Here is the quick and easy fix for it:
Fix the ordering of the dependencies in your pom.xml.
The dependency for JMockit has to come first!

Funded by the Europian Union

This article was published in the course of a
resarch-project,
that is funded by the European Union and the federal state Northrhine-Wetphalia.


Europäische Union: Investitionen in unsere Zukunft - Europäischer Fonds für regionale Entwicklung
EFRE.NRW 2014-2020: Invesitionen in Wachstum und Beschäftigung

Integrating A Maven-Backend- With A Nodjs/Grunt-Fronted-Project

Frontend-Development With Nodjs and Grunt

As I already wrote in a previous article, frontend-development is mostly done with Nodjs and Grunt nowadays.
As I am planing to base the frontend of my next Spring-Application on Bootstrap, I was looking for a way to integrate my backend, which is build using Spring and Thymeleaf and managed with Maven, with a frontend, which is based on Bootstrap and, hence, build with Nodjs and Grunt.

Integrate The Frontend-Build Into The Maven-Build-Process

As I found out, one can integrate a npm-based build into a maven project with the help of the frontend-maven-plugin.
This plugin automates the managment of Nodjs and its libraries and ensures that the version of Node and NPM being run is the same in every build environment.
As a backend-developer, you do not have to install any of the frontend-tools manualy.
Because of that, this plugin is ideal to integrate a separately developed frontend into a maven-build, without bothering the backend-developers with details of the frontend-build-process.

Seperate The Frontend-Project From The Maven-Based Backend-Project

The drawback with this approach is, that the backend- and the frontend-project are tightly coupled.
You can configure the frontend-maven-plugin to use a separate subdirectory as working-directory (for example src/main/frontend) and utilize this to separate the frontend-project in its own repository (for example by using the submodule-functions of git).
But the grunt-tasks, that you call in the frontend-project through the frontend-maven-plugin, must be defined in that project.

Since I am planing to integrate a ‐ slightly modified ‐ version of Bootstrap as frontend into my project, that would mean that I have to mess around with the configuration of the Bootstrap-project a lot.
But that is not a very good idea, because it hinders upgrades of the Bootstrap-base, because merge-conflicts became more and more likely.

So, I decided to program a special Gruntfile.js, that resides in the base-folder of my Maven-project and lets me redefine and call tasks of a separated frontend-project in a subdirectory.

Redefine And Call Tasks Of An Included Gruntfile From A Sub-Project

As it turned out, there are several npm-plugins for managing and building sub-projects (like grunt-subgrunt or grunt-recurse) or including existing Gruntfiles from sub-projects (like grunt-load-gruntfile), but none of them lets you redefine tasks of the subproject before calling them.

I programmed a simple Gruntfile, that lets you do exactly this:


module.exports = function(grunt) {

  grunt.loadNpmTasks('grunt-newer');

  grunt.registerTask('frontend','Build HTML & CSS for Frontend', function() {
    var
    done = this.async(),
    path = './src/main/frontend';

    grunt.util.spawn({
      cmd: 'npm',
      args: ['install'],
      opts: { cwd: path, stdio: 'inherit' }
    }, function (err, result, code) {
      if (err || code > 0) {
        grunt.fail.warn('Failed installing node modules in "' + path + '".');
      }
      else {
        grunt.log.ok('Installed node modules in "' + path + '".');
      }

      process.chdir(path);
      require(path + '/Gruntfile.js')(grunt);
      grunt.task.run('newer:copy');
      grunt.task.run('newer:less');
      grunt.task.run('newer:svgstore');

      done();
    });
  });


  grunt.registerTask('default', [ 'frontend' ]);

};

This Gruntfile loads the npm-taks grunt-newer.
Then, it registers a grunt-task called frontend, that loads the dependencies of the specified sub-project, read in its Gruntfile and runs redefined versions of the tasks copy, less and svgstore, which are defined in the sub-project.
The sub-project itself does not register grunt-newer itself.
This is done in this parent-project, to demonstrate how to register additional grunt-plugins and redefine tasks of the sub-project without touching it at all.

The separated frontend-project can be used by the frontend-team to develop the temlates, needed by the backend-developers, without any knowledge of the maven-project.
The frontend-project is then included into the backend, which is managed by maven, and can be used by the backend-developers without the need to know anything about the techniques that were used to develop the templates.

The whole example can be browsed at juplo.de/gitweb or cloned with:


git clone http://juplo.de/git/examples/maven-grunt-integration

Be sure to checkout the tag 2.0.0 for the corresponding version after the cloning, in case i add more commits to demonstrate other stuff.
Also, you have to init and clone the submodule after checkout:


git submodule init
git submodule update

If you run mvn jetty:run, you will notice, that the frontend-maven-plugin will automatically download Nodejs into a the folder node of the parent-project.
Afterwards, the dependencies of the parent-project are downloaded in the folder node_modules of the parent-project and the dpendencies of the sub-project are downloaded in the folder src/main/frontend/node_modules and the sub-project is build automatically in the folder src/main/frontend/dist, which is included into the directory-tree that is served by the jetty-maven-plugin.

The sub-project is fully usable standalone to drive the development of the frontend separately.
You can read more about it in this previous article.

Conclusion

In this article, I showed how to integrate a separately developed frontend-project into a backend-project managed by Maven.
This enables you to separate the development of the layout and the logic of a classic ROCA-project nearly totally.

hibernate4-maven-plugin 1.1.0 released!

Today we released the version 1.1.0 of hibernate4-maven-plugin to Central!

The main work in this release were modification to the process of configuration-gathering.
The plugin now also is looking for a hibernate.cfg.xml on the classpath or a persistence-unit specified in a META-INF/persistence.xml.

With this enhancement, the plugin is now able to deal with all examples from the official
Hibernate Getting Started Guide.

All configuration infos found are merged together with the same default precedences applied by hibernate.
So, the overall order, in which possible configuration-sources are checked is now (each later source might overwrite settings of a previous source):

  1. hibernate.properties
  2. hibernate.cfg.xml
  3. persistence.xml
  4. maven properties
  5. plugin configuration

Because the possible new configuration-sources might change the expected behavior of the plugin, we lifted the version to 1.1.

This release also fixes a bug, that occured on some platforms, if the path to the project includes one or more space characters.

Release notes:


commit 94e6b2e93fe107e75c9d20aa1eb3126e78a5ed0a
Author: Kai Moritz
Date: Sat May 16 14:14:44 2015 +0200

Added script to check outcome of the hibernate-tutorials

commit b3f8db2fdd9eddbaac002f94068dd1b4e6aef9a8
Author: Kai Moritz
Date: Tue May 5 12:43:15 2015 +0200

Configured hibernate-tutorials to use the plugin

commit 4b6fc12d443b0594310e5922e6ad763891d5d8fe
Author: Kai Moritz
Date: Tue May 5 12:21:39 2015 +0200

Fixed the settings in the pom's of the tutorials

commit 70bd20689badc18bed866b3847565e1278433503
Author: Kai Moritz
Date: Tue May 5 11:49:30 2015 +0200

Added tutorials of the hibernate-release 4.3.9.Final as integration-tests

commit 7e3e9b90d61b077e48b59fc0eb63059886c68cf5
Author: Kai Moritz
Date: Sat May 16 11:04:36 2015 +0200

JPA-jdbc-properties are used, if appropriate hibernate-properties are missing

commit c573877a186bec734915fdb3658db312e66a9083
Author: Kai Moritz
Date: Thu May 14 23:43:13 2015 +0200

Hibernate configuration is gathered from class-path by default

commit 2a85cb05542795f9cd2eed448f212f92842a85e8
Author: Kai Moritz
Date: Wed May 13 09:44:18 2015 +0200

Found no way to check, that mapped classes were found

commit 038ccf9c60be6c77e2ba9c2d2a2a0d261ce02ccb
Author: Kai Moritz
Date: Tue May 12 22:13:23 2015 +0200

Upgraded scannotation from 1.0.3 to 1.0.4

This fixes the bug that occures on some platforms, if the path contains a
space. Created a fork of scannotation to bring the latest bug-fixes from SVN
to maven central...

commit c43094689043d7da04df6ca55529d0f0c089d820
Author: Kai Moritz
Date: Sun May 10 19:06:27 2015 +0200

Added javadoc-jar to deployed artifact

commit 524cb8c971de87c21d0d9f0e04edf6bd30f77acc
Author: Kai Moritz
Date: Sat May 9 23:48:39 2015 +0200

Be sure to relase all resources (closing db-connections!)

commit 1e5cca792c49d60e20d7355eb97b13d591d80af6
Author: Kai Moritz
Date: Sat May 9 22:07:31 2015 +0200

Settings in a hibernate.cfg.xml are read

commit 9156c5f6414b676d34eb0c934e70604ba822d09a
Author: Kai Moritz
Date: Tue May 5 23:42:40 2015 +0200

Catched NPE, if hibernate-dialect is not set

commit 62859b260a47e70870e795304756bba2750392e3
Author: Kai Moritz
Date: Sun May 3 18:53:24 2015 +0200

Upgraded oss-type, maven-plugin-api and build/report-plugins

commit c1b3b60be4ad2c5c78cb1e3706019dfceb390f89
Author: Kai Moritz
Date: Sun May 3 18:53:04 2015 +0200

Upgraded hibernate to 4.3.9.Final

commit 038ccf9c60be6c77e2ba9c2d2a2a0d261ce02ccb
Author: Kai Moritz
Date: Tue May 12 22:13:23 2015 +0200

Upgraded scannotation from 1.0.3 to 1.0.4

This fixes the bug that occures on some platforms, if the path contains a
space. Created a fork of scannotation to bring the latest bug-fixes from SVN
to maven central...

commit c43094689043d7da04df6ca55529d0f0c089d820
Author: Kai Moritz
Date: Sun May 10 19:06:27 2015 +0200

Added javadoc-jar to deployed artifact

commit 524cb8c971de87c21d0d9f0e04edf6bd30f77acc
Author: Kai Moritz
Date: Sat May 9 23:48:39 2015 +0200

Be sure to relase all resources (closing db-connections!)

commit 1e5cca792c49d60e20d7355eb97b13d591d80af6
Author: Kai Moritz
Date: Sat May 9 22:07:31 2015 +0200

Settings in a hibernate.cfg.xml are read

commit 9156c5f6414b676d34eb0c934e70604ba822d09a
Author: Kai Moritz
Date: Tue May 5 23:42:40 2015 +0200

Catched NPE, if hibernate-dialect is not set

commit 62859b260a47e70870e795304756bba2750392e3
Author: Kai Moritz
Date: Sun May 3 18:53:24 2015 +0200

Upgraded oss-type, maven-plugin-api and build/report-plugins

commit c1b3b60be4ad2c5c78cb1e3706019dfceb390f89
Author: Kai Moritz
Date: Sun May 3 18:53:04 2015 +0200

Upgraded hibernate to 4.3.9.Final

commit 038ccf9c60be6c77e2ba9c2d2a2a0d261ce02ccb
Author: Kai Moritz
Date: Tue May 12 22:13:23 2015 +0200

Upgraded scannotation from 1.0.3 to 1.0.4

This fixes the bug that occures on some platforms, if the path contains a
space. Created a fork of scannotation to bring the latest bug-fixes from SVN
to maven central...

commit c43094689043d7da04df6ca55529d0f0c089d820
Author: Kai Moritz
Date: Sun May 10 19:06:27 2015 +0200

Added javadoc-jar to deployed artifact

commit 524cb8c971de87c21d0d9f0e04edf6bd30f77acc
Author: Kai Moritz
Date: Sat May 9 23:48:39 2015 +0200

Be sure to relase all resources (closing db-connections!)

commit 1e5cca792c49d60e20d7355eb97b13d591d80af6
Author: Kai Moritz
Date: Sat May 9 22:07:31 2015 +0200

Settings in a hibernate.cfg.xml are read

commit 9156c5f6414b676d34eb0c934e70604ba822d09a
Author: Kai Moritz
Date: Tue May 5 23:42:40 2015 +0200

Catched NPE, if hibernate-dialect is not set

commit 62859b260a47e70870e795304756bba2750392e3
Author: Kai Moritz
Date: Sun May 3 18:53:24 2015 +0200

Upgraded oss-type, maven-plugin-api and build/report-plugins

commit c1b3b60be4ad2c5c78cb1e3706019dfceb390f89
Author: Kai Moritz
Date: Sun May 3 18:53:04 2015 +0200

Upgraded hibernate to 4.3.9.Final

commit 248ff3220acc8a2c11281959a1496adc024dd4df
Author: Kai Moritz
Date: Sun May 3 18:09:12 2015 +0200

Renamed nex release to 1.1.0

commit 2031d4cfdb8b2d16e4f2c7bbb5c03a15b4f64b21
Author: Kai Moritz
Date: Sun May 3 16:48:43 2015 +0200

Generation of tables and rows for auditing is now default

commit 42465d2a5e4a5adc44fbaf79104ce8cc25ecd8fd
Author: Kai Moritz
Date: Sun May 3 16:20:58 2015 +0200

Fixed mojo to scan for properties in persistence.xml

commit d5a4326bf1fe2045a7b2183cfd3d8fdb30fcb406
Author: Kai Moritz
Date: Sun May 3 14:51:12 2015 +0200

Added an integration-test, that depends on properties from a persistence.xml

commit 5da1114d419ae10f94a83ad56cea9856a39f00b6
Author: Kai Moritz
Date: Sun May 3 14:51:46 2015 +0200

Switched to usage of a ServiceRegistry

commit fed9fc9e4e053c8b61895e78d1fbe045fadf7348
Author: Kai Moritz
Date: Sun May 3 11:42:54 2015 +0200

Integration-Test for envers really generates the SQL

commit fee05864d61145a06ee870fbffd3bff1e95af08c
Author: Kai Moritz
Date: Sun Mar 15 16:56:22 2015 +0100

Extended integration-test "hib-test" to check for package-level annotations

commit 7518f2a7e8a3d900c194dbe61609efa34ef047bd
Author: Kai Moritz
Date: Sun Mar 15 15:42:01 2015 +0100

Added support for m2e

Thanks to Andreas Khutz

hibernate4-maven-plugin 1.0.5 released!

Today we released the version 1.0.5 of hibernate4-maven-plugin to Central!

This release mainly fixes a NullPointerException-bug, that was introduced in 1.0.4.
The NPE was triggered, if a hibernate.properties-file is present and the dialect is specified in that file and not in the plugin configuration.
Thanks to Paulo Pires and and everflux, for pointing me at that bug.

But there are also some minor improvements to talk about:

  • Package level annotations are now supported (Thanks to Joachim Van der Auwera for that)
  • Hibernate Core was upgraded to 4.3.7.Final
  • Hibernate Envers was upgraded to 4.3.7.Final
  • Hibernate Validator was upgrades to 5.1.3.Final

The upgrade of Hibernate Validator is a big step, because 5.x supports Bean Validation 1.1 (JSR 349).
See the FAQ of hibernate-validator for more details on this.

Because Hibernate Validator 5 requires the Unified Expression Language (EL) in version 2.2 or later, a dependency to javax.el-api:3.0.0 was added.
That does the trick for the integration-tests included in the source code of the plugin.
But, because I am not using Hibernate Validator in any of my own projects, at the moment, the upgrade may rise some backward compatibility errors, that I am not aware of.
If you stumble across any problems, please let me know!

Release notes:


commit ec30af2068f2d12a9acf65474ca1a4cdc1aa7122
Author: Kai Moritz
Date: Tue Nov 11 15:28:12 2014 +0100

[maven-release-plugin] prepare for next development iteration

commit 18840e3c775584744199d8323eb681b73b98e9c4
Author: Kai Moritz
Date: Tue Nov 11 15:27:57 2014 +0100

[maven-release-plugin] prepare release hibernate4-maven-plugin-1.0.5

commit b95416ef16bbaafecb3d40888fe97e70cdd75c77
Author: Kai Moritz
Date: Tue Nov 11 15:10:32 2014 +0100

Upgraded hibernate-validator from 4.3.2.Final to 5.1.3.Final

Hibernate Validator 5 requires the Unified Expression Language (EL) in
version 2.2 or later. Therefore, a dependency to javax.el-api:3.0.0 was
added. (Without that, the compilation of some integration-tests fails!)

commit ad979a8a82a7701a891a59a183ea4be66672145b
Author: Kai Moritz
Date: Tue Nov 11 14:32:42 2014 +0100

Upgraded hibernate-core, hibernate-envers, hibernate-validator and maven-core

* Upgraded hibernate-core from 4.3.1.Final to 4.3.7.Final
* Upgraded hibernate-envers from 4.3.1.Final to 4.3.7.Final
* Upgraded hibernate-validator from 4.3.1.Final to 4.3.2.Final
* Upgraded maven-core from 3.2.1 to 3.2.3

commit 347236c3cea0f204cefd860c605d9f086e674e8b
Author: Kai Moritz
Date: Tue Nov 11 14:29:23 2014 +0100

Added FAQ-entry for problem with whitespaces in the path under Windows

commit 473c3ef285c19e0f0b85643b67bbd77e06c0b926
Author: Kai Moritz
Date: Tue Oct 28 23:37:45 2014 +0100

Explained how to suppress dependency-scanning in documentation

Also added a test-case to be sure, that dependency-scanning is skipped, if
the parameter "dependencyScanning" is set to "none".

commit 74c0dd783b84c90e116f3e7f1c8d6109845ba71f
Author: Kai Moritz
Date: Mon Oct 27 09:04:48 2014 +0100

Fixed NullPointerException, when dialect is specified in properties-file

Also added an integration test-case, that proofed, that the error was
solved.

commit d27f7af23c82167e873ce143e50ce9d9a65f5e61
Author: Kai Moritz
Date: Sun Oct 26 11:16:00 2014 +0100

Renamed an integration-test to test for whitespaces in the filename

commit 426d18e689b89f33bf71601becfa465a00067b10
Author: Kai Moritz
Date: Sat Oct 25 17:29:41 2014 +0200

Added patch by Joachim Van der Auwera to support package level annotations

commit 3a3aeaabdb1841faf5e1bf8d220230597fb22931
Author: Kai Moritz
Date: Sat Oct 25 16:52:34 2014 +0200

Integrated integration test provided by Claus Graf (clausgraf@gmail.com)

commit 3dd832edbd50b1499ea6d53e4bcd0ad4c79640ed
Author: Kai Moritz
Date: Mon Jun 2 10:31:13 2014 +0200

[maven-release-plugin] prepare for next development iteration

Running aspectj-maven-plugin with the current Version 1.8.1 of AspectJ

Lately, I stumbled over a syntactically valid class, that can not be compiled by the aspectj-maven-plugin, even so it is a valid Java-7.0 class.

Using the current version (Version 1.8.1) of AspectJ solves this issue.
But unfortunatly, there is no new version of the aspectj-maven-plugin available, that uses this new version of AspectJ.
The last version of the aspectj-maven-plugin was released to Maven Central on December the 4th 2013 and this versions is bundeled with the version 1.7.2 of AspectJ.

The simple solution is, to bring the aspectj-maven-plugin to use the current version of AspectJ.
This can be done, by overwriting its dependency to the bundled aspectj.
This definition of the plugin does the trick:


<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>aspectj-maven-plugin</artifactId>
  <version>1.6</version>
  <configuration>
    <complianceLevel>1.7</complianceLevel>
    <aspectLibraries>
      <aspectLibrary>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aspects</artifactId>
      </aspectLibrary>
    </aspectLibraries>
  </configuration>
  <executions>
    <execution>
      <goals>
        <goal>compile</goal>
      </goals>
    </execution>
  </executions>
  <dependencies>
    <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjtools</artifactId>
      <version>1.8.1</version>
    </dependency>
  </dependencies>
</plugin>

The crucial part is the explicit dependency, the rest depends on your project and might have to be adjusted accordingly:


  <dependencies>
    <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjtools</artifactId>
      <version>1.8.1</version>
    </dependency>
  </dependencies>

I hope, that helps, folks!

aspectj-maven-plugin can not compile valid Java-7.0-Code

I stumbled over a valid construction, that can not be compiled by the aspectj-maven-plugin:


class Outer
{
  void outer(Inner inner)
  {
  }

  class Inner
  {
    Outer outer;

    void inner()
    {
      outer.outer(this);
    }
  }
}

This code might look very useless.
Originally, it Inner was a Thread, that wants to signal its enclosing class, that it has finished some work.
I just striped down all other code, that was not needed, to trigger the error.

If you put the class Outer in a maven-project and configure the aspectj-maven-plugin to weave this class with compliance-level 1.6, you will get the following error:


[ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.6:compile (default-cli) on project shouter: Compiler errors:
[ERROR] error at outer.inner(this);
[ERROR] 
[ERROR] /home/kai/juplo/shouter/src/main/java/Outer.java:16:0::0 The method inner(Outer.Inner) is undefined for the type Outer
[ERROR] error at queue.done(this, System.currentTimeMillis() - start);
[ERROR] 

The normal compilation works, because the class is syntactically correct Java-7.0-Code.
But the AspectJ-Compiler (Version 1.7.4) bundeled with the aspectj-maven-pluign will fail!

Fortunately, I found out, how to use the aspectj-maven-plugin with AspectJ 1.8.3.

So, if you have a similar problem, read on…

hibernate4-maven-plugin 1.0.4 released!

We finally did it.
Today we released the version 1.0.4 of hibernate4-maven-plugin to Central!

This release mainly is a library-upgrade to version 4.3.1.Final of hibernate.
It also includes some bug-fixes provided by the community.
Please see the release notes for details.

It took us quiet some time, to release this version and we are sorry for that.
But with a growing number of users, we are becoming more anxious to break some special use-cases.
Because of that, we started to add some integration-tests, to avoid that hassle, and that took us some time…

If you have some special small-sized (example) use-cases for the plugin, we would appreciate it, if you would provide them to us, so we can add them es additional integration-tests.

Release notes:


commit f3dabc0e6e3676244986b5bbffdb67d427c8383c
Author: Kai Moritz
Date: Mon Jun 2 10:31:12 2014 +0200

[maven-release-plugin] prepare release hibernate4-maven-plugin-1.0.4

commit 856dd31c9b90708e841163c91261a865f9efd224
Author: Kai Moritz
Date: Mon Jun 2 10:12:24 2014 +0200

Updated documentation

commit 64900890db2575b7a28790c5e4d5f45083ee94b3
Author: Kai Moritz
Date: Tue Apr 29 20:43:15 2014 +0200

Switched documentation to xhtml, to be able to integrate google-pretty-print

commit bd78c276663790bf7a3f121db85a0d62c64ce38c
Author: Kai Moritz
Date: Tue Apr 29 19:42:41 2014 +0200

Fixed bug in site-configuration

commit 1628bcf6c9290a729352215ee22e5b48fa628c4c
Author: Kai Moritz
Date: Tue Apr 29 18:07:44 2014 +0200

Verifying generated SQL in integration-test hibernate4-maven-plugin-envers-sample

commit 25079f13c0eda6807d5aee67086a21ddde313213
Author: Kai Moritz
Date: Tue Apr 29 18:01:10 2014 +0200

Added integration-test provided by Erik-Berndt Scheper

commit 69458703cddc2aea1f67e06db43bce6950c6f3cb
Author: Kai Moritz
Date: Tue Apr 29 17:52:17 2014 +0200

Verifying generated SQL in integration-test schemaexport-example

commit a53a2ad438038084200a8449c557a41159e409dc
Author: Kai Moritz
Date: Tue Apr 29 17:46:05 2014 +0200

Added integration-test provided by Guido Wimmel

commit f18f820198878cddcea8b98c2a5e0c9843b923d2
Author: Kai Moritz
Date: Tue Apr 29 09:43:06 2014 +0200

Verifying generated SQL in integration-test hib-test

commit 4bb462610138332087d808a62c84a0c9776b24cc
Author: Kai Moritz
Date: Tue Apr 29 08:58:33 2014 +0200

Added integration-test provided by Joel Johnson

commit c5c4c7a4007bc2bd58b850150adb78f8518788da
Author: Kai Moritz
Date: Tue Apr 29 08:43:28 2014 +0200

Prepared POM for integration-tests via invoker-maven-plugin

commit d8647fedfe936f49476a5c1f095d51a9f5703d3d
Author: Kai Moritz
Date: Tue Apr 29 08:41:50 2014 +0200

Upgraded Version of maven from 3.0.4 to 3.2.1

commit 1979c6349fc2a9e0fe3f028fa1cc76557b32031c
Author: Frank Schimmel
Date: Wed Feb 12 15:16:18 2014 +0100

Properly support constraints expressed by bean validation (jsr303) annotations.

* Access public method of package-visible TypeSafeActivator class without reflection.
* Fix arguments to call of TypeSafeActivator.applyRelationalConstraints().
* Use hibernate version 4.3.1.Final for all components.
* Minor refactorings in exception handling.

commit c3a16dc3704517d53501914bb8a0f95f856585f4
Author: Kai Moritz
Date: Fri Jan 17 09:05:05 2014 +0100

Added last contributors to the POM

commit 5fba40e135677130cbe0ff3c59f6055228293d92
Author: Mark Robinson
Date: Fri Jan 17 08:53:47 2014 +0100

Generated schema now corresponds to hibernate validators set on the beans

commit aedcc19cfb89a8b387399a978afab1166be816e3
Author: Kai Moritz
Date: Thu Jan 16 18:33:32 2014 +0100

Upgrade to Hibernate 4.3.0.Final

commit 734356ab74d2896ec8d7530af0d2fa60ff58001f
Author: Kai Moritz
Date: Thu Jan 16 18:23:12 2014 +0100

Improved documentation of the dependency-scanning on the pitfalls-page

commit f2955fc974239cbb266922c04e8e11101d7e9dd9
Author: Joel Johnson
Date: Thu Dec 26 14:33:51 2013 -0700

Text cleanup, spelling, etc.

commit 727d1a35bb213589270b097d04d5a1f480bffef6
Author: Joel Johnson
Date: Thu Dec 26 14:02:29 2013 -0700

Make output file handling more robust

* Ensure output file directory path exists
* Anchor relative paths in build directory

commit eeb182205a51c4507e61e1862af184341e65dbd3
Author: Joel Johnson
Date: Thu Dec 26 13:53:37 2013 -0700

Check that md5 path is file and has content

commit 64c0a52bdd82142a4c8caef18ab0671a74fdc6c1
Author: Joel Johnson
Date: Thu Dec 26 11:25:34 2013 -0700

Use more descriptive filename for schema md5

commit ba2e48a347a839be63cbce4b7ca2469a600748c6
Author: Joel Johnson
Date: Thu Dec 26 11:20:24 2013 -0700

Offer explicit disable option

Use an explicit disable property, but still default it to test state

commit e44434257040745e66e0596b262dd0227b085729
Author: Kai Moritz
Date: Fri Oct 18 01:55:11 2013 +0200

[maven-release-plugin] prepare for next development iteration

Combining jetty-maven-plugin and wro4j-maven-plugin for Dynamic Reloading of LESS-Resources

Ever searched for a simple configuration, that lets you use your jetty-maven-plugin as you are used to, while working with LESS to simplify your stylesheets?

You cannot do both, use the Client-side mode of LESS to ease development and use the lesscss-maven-plugin to automatically compile the LESS-sources into CSS for production. That does not work, because your stylesheets must be linked in different ways if you are switching between the client-side mode – which is best for development – and the pre-compiled mode – which is best for production. For the client-side mode you need something like:


<link rel="stylesheet/less" type="text/css" href="styles.less" />
<script src="less.js" type="text/javascript"></script>

While, for the pre-compiled mode, you want to link to your stylesheets as usual, with:


<link rel="stylesheet" type="text/css" href="styles.css" />

While looking for a solution to this dilemma, I stumbled accross wro4j. Originally intended, to speed up page-delivery by combining and minimizing multiple resources into one through the use of a servlet-filter, this tool also comes with a maven-plugin, that let you do the same offline, while compiling your webapp.

The idea is, to use the wro4j-maven-plugin to compile and combine your LESS-sources into CSS for production and to use the wro4j filter, to dynamically deliver the compiled CSS while developing. This way, you do not have to alter your HTML-code, when switching between development and production, because you always link to the CSS-files.

So, lets get dirty!

Step 1: Configure wro4j

First, we configure wro4j, like as we want to use it to speed up our page. The details are explained and linked on wro4j’s Getting-Started-Page. In short, we just need two files: wro.xml and wro.properties.

wro.xml

wro.xml tells wro4j, which resources should be combined and how the result should be named. I am using the following configuration to generate all LESS-Sources beneath base/ into one CSS-file called base.css:


<groups xmlns="http://www.isdc.ro/wro">
  <group name="base">
    <css>/less/base/*.less</css>
  </group>

wro4j looks for /less/base/*.less inside the root of the web-context, which is equal to src/main/webapp in a normal maven-project. There are other ways to specifie the resources, which enable you to store them elswhere. But this approach works best for our goal, because the path is understandable for both: the wro4j servlet-filter, we are configuring now for our development-environment, and the wro4j-maven-plugin, that we will configure later for build-time compilation.

wro.properties

wro.properties in short tells wro4j, how or if it should convert the combined sources and how it should behave. I am using the following configuration to tell wro4j, that it should convert *.less-sources into CSS and do that on every request:


managerFactoryClassName=ro.isdc.wro.manager.factory.ConfigurableWroManagerFactory
preProcessors=cssUrlRewriting,lessCssImport
postProcessors=less4j
disableCache=true

First of all we specify the ConfigurableWroManagerFactory, because otherwise, wro4j would not pick up our pre- and post-processor-configuration. This is a little bit confusing, because wro4j is already reading the wro.properties-file – otherwise wro4j would never detect the managerFactoryClassName-directive – and you might think: “Why? He is already interpreting our configuration!” But belive me, he is not! You can read more about that in wro4j’s documentation. The disableCache=true is also crucial, because otherwise, we would not see the changes take effect when developing with jetty-maven-plugin later on. The pre-processors lessCssImport and cssUrlRewriting merge together all our LESS-resources under /less/base/*.less and do some URL-rewriting, in case you have specified paths to images, fonts or other resources inside your LESS-code, to reflect that the resulting CSS is found under /css/base.css and not /css/base/YOURFILE.css like the LESS-resources.

You can do much more with your resources here, for example minimizing. Also, there are countless configuration options to fine-tune the behaviour of wro4j. But for our goal, we are now only intrested in the compilation of our LESS-sources.

Step 2: Configure the wro4j servlet-filter

Configuring the filter in the web.xml is easy. It is explained in wro4j’s installation-insctuctions. But the trick is, that we do not want to configure that filter for the production-version of our webapp, because we want to compile the resources offline, when the webapp is build. To acchieve this, we can use the <overrideDescriptor>-Parameter of the jetty-maven-plugin.

<overrideDescriptor>

This parameter lets you specify additional configuration options for the web.xml of your webapp. I am using the following configuration for my jetty-maven-plugin:


<plugin>
  <groupId>org.eclipse.jetty</groupId>
  <artifactId>jetty-maven-plugin</artifactId>
  <configuration>
    <webApp>
      <overrideDescriptor>${project.basedir}/src/test/resources/jetty-web.xml</overrideDescriptor>
    </webApp>
  </configuration>
  <dependencies>
    <dependency>
      <groupId>ro.isdc.wro4j</groupId>
      <artifactId>wro4j-core</artifactId>
      <version>${wro4j.version}</version>
    </dependency>
    <dependency>
      <groupId>ro.isdc.wro4j</groupId>
      <artifactId>wro4j-extensions</artifactId>
      <version>${wro4j.version}</version>
      <exclusions>
        <exclusion>
          <groupId>javax.servlet</groupId>
          <artifactId>servlet-api</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.commons</groupId>
          <artifactId>commons-lang3</artifactId>
        </exclusion>
        <exclusion>
          <groupId>commons-io</groupId>
          <artifactId>commons-io</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.springframework</groupId>
          <artifactId>spring-web</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.google.code.gson</groupId>
          <artifactId>gson</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.google.javascript</groupId>
          <artifactId>closure-compiler</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.github.lltyk</groupId>
          <artifactId>dojo-shrinksafe</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.jruby</groupId>
          <artifactId>jruby-core</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.jruby</groupId>
          <artifactId>jruby-stdlib</artifactId>
        </exclusion>
        <exclusion>
          <groupId>me.n4u.sass</groupId>
          <artifactId>sass-gems</artifactId>
        </exclusion>
        <exclusion>
          <groupId>nz.co.edmi</groupId>
          <artifactId>bourbon-gem-jar</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.codehaus.gmaven.runtime</groupId>
          <artifactId>gmaven-runtime-1.7</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.webjars</groupId>
          <artifactId>jshint</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.webjars</groupId>
          <artifactId>emberjs</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.webjars</groupId>
          <artifactId>handlebars</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.webjars</groupId>
          <artifactId>coffee-script</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.webjars</groupId>
          <artifactId>jslint</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.webjars</groupId>
          <artifactId>json2</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.webjars</groupId>
          <artifactId>jquery</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
  </dependencies>
</plugin>

The dependencies to wro4j-core and wro4j-extensions are needed by jetty, to be able to enable the filter defined below. Unfortunatly, one of the transitive dependencies of wro4j-extensions triggers an uggly error when running the jetty-maven-plugin. Therefore, all unneeded dependencies of wro4j-extensions are excluded, as a workaround for this error/bug.

jetty-web.xml

And my jetty-web.xml looks like this:


<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  version="2.5">
  <filter>
    <filter-name>wro</filter-name>
    <filter-class>ro.isdc.wro.http.WroFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>wro</filter-name>
    <url-pattern>*.css</url-pattern>
  </filter-mapping>
</web-app>

The filter processes any URI’s that end with .css. This way, the wro4j servlet-filter makes base.css available under any path, because for exampl /base.css, /css/base.css and /foo/bar/base.css all end with .css.

This is all, that is needed to develop with dynamically reloadable compiled LESS-resources. Just fire up your browser and browse to /what/you/like/base.css. (But do not forget to put some LESS-files in src/main/webapp/less/base/ first!)

Step 3: Install wro4j-maven-plugin

All that is left over to configure now, is the build-process. If you would build and deploy your webapp now, the CSS-file base.css would not be generated and the link to your stylesheet, that already works in our jetty-maven-plugin environment would point to a 404. Hence, we need to set up the wro4j-maven-plugin. I am using this configuration:


<plugin>
  <groupId>ro.isdc.wro4j</groupId>
  <artifactId>wro4j-maven-plugin</artifactId>
  <version>${wro4j.version}</version>
  <configuration>
    <wroManagerFactory>ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory</wroManagerFactory>
    <cssDestinationFolder>${project.build.directory}/${project.build.finalName}/css/</cssDestinationFolder>
  </configuration>
  <executions>
    <execution>
      <phase>prepare-package</phase>
      <goals>
        <goal>run</goal>
      </goals>
    </execution>
  </executions>
</plugin>

I connected the run-goal with the package-phase, because the statically compiled CSS-file is needed only in the final war. The ConfigurableWroManagerFactory tells wro4j, that it should look up further configuration options in our wro.properties-file, where we tell wro4j, that it should compile our LESS-resources. The <cssDestinationFolder>-tag tells wro4j, where it should put the generated CSS-file. You can adjust that to suite your needs.

That’s it: now the same CSS-file, which is created on the fly by the wro4j servlet-filter when using mvn jetty:run and, thus, enables dynamic reloading of our LESS-resources, is generated during the build-process by the wro4j-maven-plugin.

Cleanup and further considerations

lesscss-maven-plugin

If you already compile your LESS-resources with the lesscss-maven-plugin, you can stick with it and skip step 3. But I strongly recommend giving wro4j-maven-plugin a try, because it is a much more powerfull tool, that can speed up your final webapp even more.

Clean up your mess

With a configuration like the above one, your LESS-resources and wro4j-configuration-files will be packed into your production-war. That might be confusing later, because neither wro4j nor LESS is used in the final war. You can add the following to your pom.xml to exclude these files from your war for the sake of clarity:


<plugin>
  <artifactId>maven-war-plugin</artifactId>
  <configuration>
    <warSourceExcludes>
      WEB-INF/wro.*,
      less/**
    </warSourceExcludes>
  </configuration>
</plugin>

What’s next?

We only scrached the surface, of what can be done with wro4j. Based on this configuration, you can easily enable additional features to fine-tune your final build for maximum speed. You really should take a look at the list of available Processors!

hibernate4-maven-plugin 1.0.3 released!

Today we released the version 1.0.3 of hibernate4-maven-plugin to Central.

Scanning dependencies

This release of the plugin now supports scanning of dependencies. By default all dependencies in the scope compile are scanned for annotated classes. Thanks to Guido Wimmel, who pointed out, that this was really missing and supported the implementation with a little test-project for this use-case. Learn more…

Support for Hibernate Envers

Another new feature of this release is support for Hibernate Envers – Easy Entity Auditing. Thanks a lot to Victor Tatai, how implemented this, and Erik-Berndt Scheper, who helped integrating it and who supported the testin with a little test-project, that demonstrates the new feature. You can visit it at bitbucket as a starting point for your own experiments with this technique.

Less bugs!

Many thanks also to Stephen Johnson and Eduard Szente, who pointed out bugs and helped eleminating them…

Get your hands on – on central!

hibernate4-maven-plugin 1.0.3 is available in the Central Maven Repository.

Release notes:


commit adb20bc4da63d4cec663ca68648db0f808e3d181
Author: Kai Moritz
Date: Fri Oct 18 01:52:27 2013 +0200

Added missing documentation for skip-configuration

commit 99a7eaddd1301df0d151f01791e3d177297670aa
Author: Kai Moritz
Date: Fri Oct 18 00:38:29 2013 +0200

Added @since-Annotation to configuration-parameters

commit 221d977368ee1897377f80bfcdd50dcbcd1d4b83
Author: Kai Moritz
Date: Wed Oct 16 01:18:53 2013 +0200

The plugin now scans for annotated classes in dependencies too

commit ef1233a6095a475d9cdded754381267c5d1e336f
Author: Kai Moritz
Date: Wed Oct 9 21:37:58 2013 +0200

Project-Documentation now uses the own skin juplo-skin

commit 84e8517be79d88d7e2bec2688a8f965f591394bf
Author: Kai Moritz
Date: Wed Oct 9 21:30:28 2013 +0200

Reworked APT-Documentation: page-titles were missing

commit f27134cdec6c38b4c8300efb0bb34fc8ed381033
Author: Kai Moritz
Date: Wed Oct 9 21:29:30 2013 +0200

maven-site-plugin auf Version 3.3 aktualisiert

commit d38b2386641c7ca00f54d69cb3f576c20b0cdccc
Author: Kai Moritz
Date: Wed Sep 18 23:59:13 2013 +0200

Reverted to old behaviour: export is skipped, when maven.test.skip=true

commit 7d935b61a3d80260b9cacf959984e14708c3a96b
Author: Kai Moritz
Date: Wed Sep 18 18:15:38 2013 +0200

No configuration for hibernate.dialect might be a valid configuration too

commit caa492b70dc1daeaef436748db38df1c19554943
Author: Kai Moritz
Date: Wed Sep 18 18:14:54 2013 +0200

Improved log-messages

commit 2b1147d5e99c764c1f6816f4d4f000abe260097c
Author: Kai Moritz
Date: Wed Sep 18 18:10:32 2013 +0200

Variable "envers" should not be put into hibernate.properties

"hibernate.exoprt.envers" is no Hibernate-Configuration-Parameter.
Hence, it should not be put into the hibernate.properties-file.

commit 0a52dca3dd6729b8b6a43cc3ef3b69eb22755b0a
Author: Erik-Berndt Scheper
Date: Tue Sep 10 16:18:47 2013 +0200

Rename envers property to hibernate.export.envers

commit 0fb85d6754939b2f30ca4fc18823c5f7da1add31
Author: Erik-Berndt Scheper
Date: Tue Sep 10 08:20:23 2013 +0200

Ignore IntelliJ project files

commit e88830c968c1aabc5c32df8a061a8b446c26505c
Author: Victor Tatai
Date: Mon Feb 25 16:23:29 2013 -0300

Adding envers support (contribution from Victor Tatai)

commit e59ac1191dda44d69dfb8f3afd0770a0253a785c
Author: Kai Moritz
Date: Tue Sep 10 20:46:55 2013 +0200

Added Link to old Version 1.0.2 in documentation

commit 97a45d03e1144d30b90f2f566517be22aca39358
Author: Kai Moritz
Date: Tue Sep 10 20:29:15 2013 +0200

Execution is only skipped, if explicitly told so

commit 8022611f93ad6f86534ddf3568766f88acf863f3
Author: Kai Moritz
Date: Sun Sep 8 00:25:51 2013 +0200

Upgrade to Scannotation 1.0.3

commit 9ab53380a87c4a1624654f654158a701cfeb0cae
Author: Kai Moritz
Date: Sun Sep 8 00:25:02 2013 +0200

Upgrade to Hibernate 4.2.5.Final

commit 5715c7e29252ed230389cfce9c1a0376fec82813
Author: Kai Moritz
Date: Sat Aug 31 09:01:43 2013 +0200

Fixed failure when target/classes does not exist when runnin mvn test phase

Thanks to Stephen Johnson

Details from the original email:
---------
The following patch stops builds failing when target/classes (or no main java exists), and target/test-classes and src/tests exist.

So for example calling

mvn test -> invokes compiler:compile and if you have export bound to process-classes phase in executions it will fail. Maybe better to give info and carry on. Say for example they want to leave the executions in place that deal with process-classes and also process-test-classes but they do not want it to fail if there is no java to annotate in src/classes. The other way would be to comment out the executions bound to process-classes. What about export being bound to process-class by default? Could this also cause issues?

In either case I think the plugin code did checks for src/classes directory existing, in which case even call "mvn test" would fail as src/classes would not exist as no java existed in src/main only in src/test. Have a look through the patch and see if its of any use.

commit 9414e11c9ffb27e195193f5fa53c203c6297c7a4
Author: Kai Moritz
Date: Sat Aug 31 11:28:51 2013 +0200

Improved log-messages

commit da0b3041b8fbcba6175d05a2561b38c365111ed8
Author: Kai Moritz
Date: Sat Aug 31 08:51:03 2013 +0200

Fixed NPE when using nested classes in entities with @EmbeddedId/@Embeddable

Patch supplied by Eduard Szente

Details:
----------------
Hi,

when using your plugin for schema export the presence of nested classes
in entities (e.g. when using @EmbeddedId/@Embeddable and defining the Id
within the target entity class)
yields to NPEs.

public class Entity {

@EmbeddedId
private Id id;

@Embeddable
public static class Id implements Serializable {
....
}

}

Entity.Id.class.getSimplename == "Id", while the compiled class is named
"Entity$Id.class"

Patch appended.

Best regards,
Eduard

Log out from wrong Account with maven-appengine-plugin

Do you work with the maven-appengine-plugin and several google-accounts? If you do, or if you ever were logged in to the wrong google-account while executing mvn appengine:update, like me yesterday, you surely wondering, how to logout from maven-appengine-plugin.

maven-appengine-plugin somehow miracolously stores your credentials for you, when you attemp to upload an app for the first time. This comes in very handy, if you work with just one google-account. But it might get a “pain-in-the-ass”, if you work with several accounts. Because, if you once logged in into an account, there is no way (I mean: no goal of the maven-appengine-plugin) to log out, in order to change the account!

The solution: clear the credentials, that the maven-appengine-plugin stored on your behalf

Only after hard googling, i found a solution to this problem in a blog-post: maven-appengine-plugin stores its oauth2-credentials in the file .appcfg_oauth2_tokens_java in your home directory (on Linux – sorry Windows-folks, you have to figure out yourself, where the plugin stores the credentials on Windows).

Just delete the file .appcfg_oauth2_tokens_java and your logged out! The next time you call mvn appengine:upload you will be asked again to accept the request and, hence, can switch accounts. If you are not using oauth2, just look for .appcfg*-files in your home directory. I am sure, you will find another file with stored credentials, that you can delet to logout, like Radomir, who deleted .appcfg_cookiesy to log out.