Thursday, July 19, 2012

Order of Annotated Controllers When Matching @RenderMapping and @ActionMapping

ConfigurationJDK 7, Spring 3.1.1.RELEASE and Hibernate 4.1.3.Final. Multiple annotated controllers.

When you invoke a Render or Action mapping, it might happen the default mapping is picked up instead of the correct one.
This happens when the controller with the default mapping is first in the list.

DEBUG [http-8080-1] (AbstractMapBasedHandlerMapping.java:74) - Key [view] -> handler [{org.springframework.web.portlet.mvc.annotation.DefaultAnnotationHandlerMapping$RenderMappingPredicate@2e19e=my.package.controller.DefaultController@12a8bad, ...

It's probably a bug or I don't understand the purpose yet.
This can be fixed by forcing Spring to put the controller with the default mapping last. First you scan all others and separately the default one:

    <context:component-scan base-package="it.italiangrid.liferay.doclibadmin.controller" use-default-filters="true">
        <context:exclude-filter type="regex" expression="EmiDocumentController"/>
    </context:component-scan>
    
    <context:component-scan base-package="it.italiangrid.liferay.doclibadmin.controller" use-default-filters="true">
        <context:include-filter type="regex" expression="EmiDocumentController"/>
    </context:component-scan>

Update I found out that if you use @RequestMapping instead of @RenderMapping and @ActionMapping in all methods of the controller with the default action, the problem seems to disappear.
You can use render and action mapping annotations in all other controllers.

References

Thursday, July 12, 2012

Gnome 3: Add a Custom Item to Favorites

Install and run alacarte. This tool allows you to manage the applications you see in the window Activities --> Applications. Those shown there are a subset of the ones available.

  1. Create a new one in Alacarte with New Item in an existing or new menu.
  2. Check the Show checkbox.
  3. Go to Activities --> Applications and right click on the icon to add to the Favorites side bar.

Tuesday, July 10, 2012

Fedora 17: Disable Jetty

From this Fedora 17 announcement:


If you have updated from Fedora 16 and you had jetty installed, it was 
automatically enabled to start on reboot. If you are are not using jetty for 
serving web content, but it was installed as a dependency, please run the 
following command as root user:

# systemctl disable jetty.service

This will stop jetty from running automatically on system reboot. If you also 
want to stop the currently running jetty you can run following:

# systemctl stop jetty.service