Thursday, December 26, 2013

Problem while deploying ROOT.war on Openshift Tomcat application

I had a problem when I deployed  my war on Tomcat in OpenShift cloud.
It always takes OpenShift's ROOT.war and not the ROOT.war I had copy in the webapps directory.
It's because when you make git push, it runs a mvn command or in my case, I don't want to build my project but only deploy a single war file.
To solve this problem :

- Delete src/ directory
- Delete pom.xml

Thursday, December 19, 2013

Bootstrap add active class to li

In the following example, we use a classic Bootstrap menu.Note that, none li had a class active.We will use after.
    <div class="navbar navbar-default span12" role="navigation">
            <div class="navbar-collapse collapse">
                <ul class="nav navbar-nav">
                    <li><a href="/fjLearning/"><g:message code="menu.home" /></a></li>
                    <li><a href="/fjLearning/page/training"><g:message code="" /></a></li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown"><g:message code="menu.about" /> <b class="caret"></b></a>
                        <ul class="dropdown-menu">
                            <li><a href="/fjLearning/page/about"><g:message code="menu.about.perso" /></a></li>
                            <li class="divider"></li>
                            <li class="dropdown-header"><g:message code="" /></li>
                            <li><a href="/fjLearning/page/under"><g:message code="menu.underTheHood" /></a></li>
                            <li><a href="#">FAQ</a></li>

To make it works you have in each page to add :
    $(document).ready(function() {
        $('a[href="' + this.location.pathname + '"]').parent().addClass('active');

Now, when I clicked on the menu, the link active changes automatically. If you want to see an example, go on my GittHub project :

Here is the usefull files :

Sunday, December 15, 2013

Bootstrap : span doesn't work

I tried this simple Bootstrap row without success :

<div class="row" style="border: 1px solid green">
        <div class="span2" style="border: 1px solid red">Foo!</div>
        <div class="span2" style="border: 1px solid red">Bar!</div>
        <div class="span2" style="border: 1px solid red">Baz!</div>
        <div class="span2" style="border: 1px solid red">Foo!</div>
        <div class="span2" style="border: 1px solid red">Bar!</div>
        <div class="span2" style="border: 1px solid red">Baz!</div>

In fact, it's simple.I used Bootstrap 3.x and not Bootstrap 2.x which contains some change in class names.
For example, span-* became col-md-*.

So the solution, for this example above :

<div class="row" style="border: 1px solid green">
        <div class="col-md-2" style="border: 1px solid red">Foo!</div>
        <div class="col-md-2" style="border: 1px solid red">Bar!</div>
        <div class="col-md-2" style="border: 1px solid red">Baz!</div>
        <div class="col-md-2" style="border: 1px solid red">Foo!</div>
        <div class="col-md-2" style="border: 1px solid red">Bar!</div>
        <div class="col-md-2" style="border: 1px solid red">Baz!</div>

See following link for details :

Thursday, December 12, 2013

Add social buttons with Grails

Here is a simple way to add social button without time'sloading problems.

Example :

            <a target="_blank" title="Twitter" href="<g:createLink action="${params.action}" absolute="true"/>&text=<g:message code="training.title" /> sur <g:createLink action="${params.action}" absolute="true"/>" class="tweet-button" rel="nofollow" onclick=", '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=400,width=700');return false;"><img src="/fjLearning/images/twitter_icon.png" width="32" height="32"/></a>

In this example, we used <g:createLink action="${params.action}" absolute="true"/> to generate full url of your gsp web page.
params.action variable contains current action.

If you want other example (Facebook, Google + ...), you can see that link :

Wednesday, December 11, 2013

Road to Grails 3.0

An interesting video on InfoQ about Grails 2.3 and future Grails 3.0 feature :
Road to Grails 3.0

Friday, December 6, 2013

Grails : full URL of a gsp.

If you need the full URL of a gsp, you can use tag createLink :
<g:createLink action="${params.action}" absolute="true"/>
It will generate something like taht : http://localhost:8080/fjLearning/training

The params.action variable give us the current action.In our case it's training.

More details about tag createLink on

Friday, November 29, 2013

Deploy your grails application freely on the web with OpenShift

If you want to make a web site and deploy it on the cloud, a possible solution is to make a Grails application and then to deploy on Tomcat.
After that, you can deploy it for free on Openshift :

Wednesday, November 27, 2013

Error No default container found with grails

I've found solution about this problem on StackOverFlow :

Grails internationalization testing

I had some problem with internationalization with Grails.
I tried to change the language by adding ?lang=us at the end of my request but without success.
I found a simple solution : just switch the language settings of your browser by adding first the language you want. It will change "Accept language" in the HTTP request.

For example, in Firefox, you have to go in Tools -> Option -> Content -> language then choose the preferred language.
After that, you only have to reload your web page.

Wednesday, November 20, 2013

Coding Dojo

Here is an other web site to learn coding online :
Lot of languages are available !

Monday, November 18, 2013

JMC in Java 7u40

A new tools is available in bin directory of your Java distribution ( 7u40) to manage, monitor, profile and eliminate memory leaks. More info here :

Wednesday, November 13, 2013

codeacademy : a good way to learn html,css,php,javascript or jquery

You search a good way for learning some techno like html,css,php,javascript or jquery, you should look at : Codeacademy

This web site helps you to learn easily by making courses and exercises online.
Courses are divided in severeal small courses and small exercises.
For example, the lesson explains how to set id on html element and you have to modify the html.

Example :

Sunday, November 10, 2013


New google+ page about my blog

Saturday, November 9, 2013

Grails : turn on GZip compression

If you want to improve your web site performance, you should enable GZip compression.

What is GZip compression ?

It's simple : you zip date before sending it over the net :
  1. Server compress data (HTML code, CSS, JavaScript...)
  2. Data go through the net
  3. the navigator uncompress data when it arrives before showing them

It's describe in HTTP/1.1

Is performance really better ?

You can check it here :

Grails et GZip

To enable GZip compression, it's simple.You have to install plugin ui-performance :

grails install-plugin ui-performance

Then restart Grails.

Comments :
  • If you want to be sure that GZip compression is enabled, you can go in "Audits" tabs on Chrome developpement tools.
  • ui-performance plugin do also severeal things like rules of Steve Souders and Yahoo performance team :  

Greyhound, the 2nd fastest land animal

Wednesday, November 6, 2013

Win a free pass for Devoxx France 2014 permits to win a pass for Devoxx France 2014 with a quizz :
Go one

Wednesday, September 25, 2013

Sunday, July 7, 2013

Grails generate-all No domain class found for name

Problem :

I'm try to use "generate-all" command and I had this error message each time I use it : "No domain class found for name User".
I typed this command :

grails generate-all User

I use Grails 2.1.5 so perhaps it works better in last version ;-)

Error :
| No domain class found for name User. Please try again and enter a valid domain
 class name
| Error 2013-06-30 13:51:40,907 [Thread-10] ERROR plugins.DefaultGrailsPlugin  -
 Error configuration scaffolding: Error creating bean with name 'instanceControl
lersApi': Singleton bean creation not allowed while the singletons of this facto
ry are in destruction (Do not request a bean from a BeanFactory in a destroy met
hod implementation!)
Message: Error creating bean with name 'instanceControllersApi': Singleton bean
creation not allowed while the singletons of this factory are in destruction (Do
 not request a bean from a BeanFactory in a destroy method implementation!)
   Line | Method
->> 722 | run in java.lang.Thread


grails generate-all racetrack.User
In fact, my domain class was in a directory named racetrack.
I have the following tree directory : $GRAILS_APPdomain/racetrack/

Saturday, July 6, 2013

Grails automatic timestamp

In your domain class, you can add a field which has automatic timestamp (When creating or when updating).
The date field must have the name dateCreated or lastUpdated.
It's a convention define by Grails.

Example :

class Person {
   Date dateCreated
   Date lastUpdated
If you want to disable this feature, you can make the following :
class Person {
   Date dateCreated
   Date lastUpdated
   static mapping = {
      autoTimestamp false

See also :

Learn Grails with a book

I'm learning Grails.
I choose "Grails getting started" because it's easy to understand and not annoying :-)
I appreciate this book that's why I post this link :

Tuesday, July 2, 2013

Grails : Do you know CRaSH plugin ?


You have the possibility to embeded CRaSH in Grails by installing the CRaSH plugin.
It's very easy :

grails install-plugin crash

Now, you can connect to your Grails application by using CRaSH.
Two steps for that :
  • Find the Java Process PID of your Grails application with :
cd $JAVA_HOME/bin
  • Launch CRaSH
Then you will be able to access to CRaSH command by typing :


Now, you have access to all CRaSH command jdbc,jpa, thread ... and you can make your own !

CRaSH web site :
Grails CRaSH plugin :
Grails :

Sunday, June 30, 2013

Why clojure is the next big thing ?


There is plenty programming languages and it's difficult to choice between them.
Here is an interesting article about Clojure. I don't know if Clojure is the the language of the future but I think this article will help you to get a general idea about it  :

Saturday, June 29, 2013

Where are stored Grails temporary files ?

Grails stores temporary files in .grails directory.

  • On Unix system : $HOME/.grails
  • On windows : c:\Users\myUser\.grails

 You can clean with : grails clean
Here is the official description of clean command :

The clean command deletes all compiled resources from the application. Since Groovy is a compiled language, as with Java, this is sometimes useful to clear old instances of classes and ensure correct compilation. It's also a good idea to run this script before running tests or creating a WAR file to ensure a full compilation occurs.

Friday, June 28, 2013

Koans : learn with unit test !

Recently, I spoke to you about Koans and Groovy. But, I didn't know that Koans exists also for other programming language like JavaScript and Groovy ...

This tips come from this excellent blog :

Thursday, June 27, 2013

How to order field by using scaffold ?

Here is the official definition of Scaffolding :

Scaffolding lets you auto-generate a whole application for a given domain class including:
  • The necessary views
  • Controller actions for create/read/update/delete (CRUD) operations

So if you define for example this domain class :

class User {

String name
String tel
String addr

You are excpecting to have html fields in this order. But it's not necessary the case.It's seems that the default order is alphabetical.
If you want to define field order, you have to add the following to the domain class :

statics constraints = {
  With constraints, you will be able to add validation, constraints ...

Scala choice ?

Here is an interesting interview of Cary Horstmann on the web Oracle web site :

Wednesday, June 26, 2013

Grails : why datas aren't persit ?

By default, under Grails, you are in developpement mode.
So each time, you run your application with grails run-app, you will loose your data.

For example, if you use scaffold, all data you save will be loose after restart :

class RegistrationController {

    def scaffold = true
First time, it's a little bit frustating ...
If you want to see datas each time you run, you have to change databases configuration.
There is an another way to see datas :
 grails prod run-app
 Then persit datas and if you start again, you will see you datas.

AsciiDoc vs Markdown

AscciDoc and Markdown allow you to write text with lightweight markup language for writing for example HTML pages. Theses two languages are popular (for example Markdown used by GitHub).
With it, by using a very easy syntax, you will be able to generate HTML page.
Here is an example for Markdown

What is the best choice ?

I can't answer to that now but if you want a comparison betweem them, there is an interesting Thread on GitHub :

Usefull Links :

Daring Fireball

AsciiDoc Text based document generation

Tuesday, June 25, 2013

Inialize a List in Groovy and Java

I follow the excellent tutorial of and I note that Groovy have a lot of good things that make codes more readable and thinner.

Here is a simple comparaison between Java and Grovvy to initialize a List :

In Java :

        List<String> javaList = new ArrayList<String>();

In Groovy :

        def groovyList = ['King', 'Prince']

More details on

IT trend : Redhat EHL choose MariaDB instead of Mysql !

Here is a small interesting news that shows the actual trend...
Mysql is everywhere ! However, more and more, we hear that there is migration to MariaDB ( a Mysql fork !). The last migration is RedHat !

The first reason is because MaraiDB is really Open Source and not Oracle Open source :-). An other reason should be performance ...

If you want to compare Mysql and MariaDB :

The RedHat choice :


Saturday, June 22, 2013

How to change Grails server port ?

In your web application, edit conf/BuildConfig.groovy file and add the port number like the following :

grails.server.port.http = 8090

For example :
grails.project.dependency.resolution = {
    // inherit Grails' default dependencies
    inherits("global") {
        // specify dependency exclusions here; for example, uncomment this to disable ehcache:
        // excludes 'ehcache'
        grails.server.port.http = 8090
    log "error" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
    checksums true // Whether to verify checksums on resolve
    legacyResolve true // whether to do a secondary resolve on plugin installation, not advised but here for backwards compatibility

This tips come from

Wednesday, June 19, 2013

Saturday, June 8, 2013

Grails instead of Play 1.X ?

Play 1.X becomes old. So, which web framework can I use ?
Play 2 with Scala or Grails. I deciced to learn Grails because it has similarity with Play 1.X.It seems to me Mature and I prefer Groovy syntax.

Here is a good link to learn Grails with Mysql database :

Thursday, May 9, 2013

Maven and Java 7 : Fatal error compiling: invalid target release: 1.7


On a Maven Project I change Java version (1.6 to 1.7) in my pom.xml file and I have the following error :

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:compile (default-compile) on project MetricViewer: Fatal error compiling: invalid target release: 1.7 -> [Help 1]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1]


You have probably Java 1.6 in your classpath.
Do the following to check it :

mvn clean install --debug

  1 Apache Maven 3.0.3 (r1075438; 2011-02-28 11:31:09-0600)
  2 Maven home: /usr/share/maven
  3 Java version: 1.6.0_35, vendor: Apple Inc.
  4 Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

I found this solution at

Saturday, April 27, 2013

CRaSH 1.2.2 release

New version of CRaSH is available.

This version make minor improvement. More informations on!topic/crash-users/p06x34J_Uy8

You should see also

Saturday, March 30, 2013

Friday, March 22, 2013

CRaSH : a good way to test it !

If you don't know CRaSH, it's time to test it !
You can test it online and discover all the potential of this wonderful tool !

Send a POST request on Google App Engine

To send a request, you need to use Url Fetch service.The URL Fetch service uses Google's network infrastructure for efficiency and scaling purposes.Here is the code to send a simple POST request on Google App Engine :

   public void send(String messageToSend, String date, String level, String servers) {

        try {
            String message = URLEncoder.encode(messageToSend, ENCODING);
            Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyUrl, Integer.parseInt(proxyPort)));

            URL url = new URL(urlDest);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection(proxy);

            OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream());
            writer.write("date=" + date);
            writer.write("&level=" + level);
            writer.write("&servers=" + servers);
            writer.write("&msg=" + message);

            if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
      "OK ! message returned:" + connection.getResponseCode());
            } else {
      "KO ! message returned:" + connection.getResponseCode());
        } catch (MalformedURLException e) {
        } catch (IOException e) {

I've made a small java project ( 2 class ;-) )that send a simple POST request : See
More details on

Wednesday, March 20, 2013

Feedback about the creation of an application on Google App Engine

Goal : Create a small alert's application on Google App Engine and evaluate the easiest method.
Here is my small feedback :

Test 1 : Create a small project with GWT


1) Installation
- Netbeans : Not working for me.Installation problem with plugin ...
- Intellij : I didn't find any plugin
- Eclipse : OK and it's easy

2) Create his own application

I want to made a small application but in my mind, GWt is too complex and not quick
Here is an example : see


Quick deploy on Google App Engine facile.

- Test 2 : Create a project with Play 1.2.5 and GAE plugin.


Easy to develop because of framework Play.


- I've some difficulties with my proxy
Here is the Play application with solution

- Play 1.2.5 isn't maintain.See if Yalp will work ...

Monday, March 18, 2013

Play Job monitoring

SiIf you want to monitor Play jobs (1.2.5) easily , you can use CRaSH and with command line, you type the following :
% dashboard | thread ls -n "jobs-thread*"
More information on

Thursday, March 14, 2013

First step with the cloud OpenShift of RedHat

My goal : Deploy an Play 1.2.5 on OpenShift.

For this purpose, I follow that link : planet_jboss

Steps summary:

- Create my application :

I create my application directly on the web site.It was quick and simple.
Moreover, all usefull command to connect with ssh and clone are available.You just have to make copy and paste.

- Gentoo install :

emerge dev-ruby/rubygems
ruby -e 'puts "Welcome to Ruby"
gem install rhc

- Initialisation (as a user)

rhc setup

- Clone of our application's repository

git clone ssh://XXX/~/git/monapp.git/

Then, I follow steps ICI

- Export of the war dans monapp/deployements :

play war -o /home/toto/monapp/deployments/cookies.war
git add deployments/cookies.war*
git push

- Check of the deployement

- Connexion with ssh on the RedHat cloud
- tail -f jbossas-7/logs/server.log


- I try the cloud at my job but I didn't succeed because of proxy and firewall.I also tried to use ssh over
90 but without success.
- At home, no problem : it was easy end fast.

Saturday, March 9, 2013

JavaFx project on GitHub

To learn JavaFx, I've began a small project on GitHub.
I use JavaFx 2 and Maven.Perhaps, It could help you to begin  in your project.

See for more information.

Thursday, February 7, 2013

sbt.ResolveException: download failed: org.slf4j#slf4j-api;1.6.6


 When I ran play run , I have the following error :

[error] (*:update) sbt.ResolveException: download failed: org.slf4j#slf4j-api;1.6.6!slf4j-api.jar
[warn] some of the dependencies were not recompiled properly, so classloader is not avaialable


vi ./project/plugins.sbt

You only have to edit this file and add the last version of play (2.1.0) :

// Comment to get more information during initialization
logLevel := Level.Warn

// The Typesafe repository
resolvers += "Typesafe repository" at ""

// Use the Play sbt plugin for Play projects
addSbtPlugin("play" % "sbt-plugin" % "2.1.0")

Then you can launch play run again

Saturday, January 26, 2013

KnowledgeBlackBelt will definitely shut down.

Bad news ! KnowledgeBlackBelt will definitely shut down on Jan 31st 2013.
Content is available for free ...

play 2.1 : Create yout first projetc with IntelliJ Tips

Create a project with Play is easy :

$ play new my-app 
$ cd my-app 
$ play idea

However, I had some diificulties with how to import in IntelliJ.In the documentation, it says that you have to import a module.But it doesn't work for me.
To succes, I've just done the following :

File --> Open

And now it works every times :-)

Sunday, January 6, 2013

java 8 : Functional Interfaces

In this article, we will try to learn new Java 8 concept : functional interface. It's an entry point for using lambdas and other JAVA 8 features ...

Definition from JSR 335

A functional interface is an interface that has just one abstract method, and thus represents a single function contract. (In some cases, this "single" method may take the form of multiple abstract methods with override-equivalent signatures (8.4.2) inherited from superinterfaces; in this case, the inherited methods logically represent a single method.)
In addition to the usual process of creating an interface instance by declaring and instantiating a class, instances of functional interfaces can be created with lambda expressions, method references, or constructor references.
The function descriptor of a functional interface I is a method type—type parameters, formal parameter types, return types, and thrown types—that can be used to legally override the abstract method(s) of I.

 In short, a functional interface is only one interface with just one abstract method. The goal of Functional Interface is to use JAVA 8 feature like lambdas.

Simple example

Here is a short example :

 package fr.dr.practice;

 * Interface with just one abstract method.
public interface ICode {
    String generate(int codeNumber);

package fr.dr.practice;

 * Created with IntelliJ IDEA.
public class Main {

    public static String generateTmpCode(int newCode) {
        ICode code = new ICode() {
            public String generate(int codeNumber) {
                return "MAIN_" + codeNumber + Math.random();
        return code.generate(newCode);

    public static String generateTmpCodeWithLambda(int newCode) {
        ICode icode = codeNumber -> "MAIN_" + codeNumber + Math.random();
        return icode.generate(newCode);

    public static void main(String[] args) {


More complex examples

The JSR says the following :

In some cases, this "single" method may take the form of multiple abstract methods with override-equivalent signatures (8.4.2) inherited from superinterfaces; in this case, the inherited methods logically represent a single method.

So, you can make the following because equals method is public in Object class :

public interface ICode {

    String generate(int codeNumber);
    boolean equals(Object obj);

But you can't make this because clone method (protected Object clone() throws CloneNotSupportedException {) isn't public in Object class :

public interface ICode {

    String generate(int codeNumber);
    Object clone();

Function descriptor 

The JSR 335 add also a the concept of Functional descriptor.
Here is an example from JSR :

interface X { void m() throws IOException; }
interface Y { void m() throws EOFException; }
interface Z { void m() throws ClassNotFoundException; }
interface XY extends X, Y {}
interface XYZ extends X, Y, Z {}

// XY has descriptor ()->void throws EOFException
// XYZ has descriptor ()->void (throws nothing)


Functional interface permits to use lambda or other JAVA 8 features.It exists yet some functional interface (e.g : java.util.Comparator ). Java 8 has also a new package : java.util.functions which defines new Functional Interface.You could see this good blog for example with it :
This article permits me to learn JAVA 8 feature.If you have comments or if you see errors, please post it ! In next article, we will study lambda feature ...