Saturday, March 12, 2016

Grails 3 : ORM Mapping Invalid: Specified config option


I have the following error at startup of my GRAILS 3.1.1 application :

ERROR org.grails.orm.hibernate.cfg.HibernateMappingBuilder - ORM Mapping Invalid: Specified config option [name] does not exist for class [toolprod.Machine]!

The consequence was that it can't create the table Machine.

Here is my domain class which had the error :

 class Machine {  
   /**  
    * Name of the web server.  
    */  
   String name  
   /**  
    * IP address.  
    */  
   String ipAddress  
   /**  
    * Application list in this machine.  
    */  
   Set<App> apps = []  
   /**  
    * Servers list.  
    */  
   Set<Server> servers = []  
   static hasMany = [apps : App, servers : Server]  
   static mapping = {  
     sort "name"  
   }  
   static constraints = {  
     name()  
     ipAddress(nullable: true)  
   }  


   
To solve this issue, I set a default value for name    :

   static constraints = {  
     name(nullable: false)  
     ipAddress(nullable: true)  
   }  

Saturday, March 5, 2016

Netbeans change the .gradle directory

To solve this problem, I set the system environment variable GRADLE_USER_HOME to an other directory like the following :

    variable name : GRADLE_USER_HOME
    value of variable : E:\repos\gradle

Then in Netbeans It works ( perhaps you have to make some clean, close and open project to refresh it )

Hope this help !

Saturday, October 3, 2015

Grails 3 : add a bootstrap plugin to your application


I started to learn Grails 3 by using Netbeans 8.Today, I wanted to add bootstrap to my Grails 3 project.I decided to use a bootstrap plugin.The ways to do it is a little different than in Grails 2 ...

First, you have to search your plugin.There are located on Bintray.Here is the web page I used to configure the bootstrap plugin for my web application : https://bintray.com/kensiprell/gradle-plugins/bootstrap-framework/view#read


Configure build.gradle


You have to put dependencies in build.gradle :

buildscript {
    ext {
         //bootstrapFramework = [
         //    version             : "3.3.5",
         //    cssPath             : "grails-app/assets/stylesheets",
         //    jsPath              : "grails-app/assets/javascripts",
         //    useIndividualJs     : false,
         //    useLess             : false,
         //    invalidVersionFails : false,
         //    fontAwesome : [
         //       install             : false
         //       version             : "4.3.0",
         //       useLess             : false
         //       invalidVersionFails : false
         //    ]
         //]
    }
    repositories {
        jcenter()
    }
    dependencies {
        classpath "com.siprell.plugins:bootstrap-framework:1.0.3"
    }
}


apply plugin: "com.siprell.plugins.bootstrap-framework"


main.gsp


Then just add the require dependencies jquery, bootstrap in your GSP.
Here is an example with a classic navbar :


<html lang="en" class="no-js">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title><g:layoutTitle default="Grails"/></title>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <asset:javascript src="jquery-2.1.3.js"/>
        <asset:javascript src="bootstrap-all.js"/>
        <asset:stylesheet src="bootstrap-all.css"/>
        <asset:stylesheet src="font-awesome-all.css"/>
        <g:layoutHead/>
    </head>
    <body>
    <nav class="navbar navbar-default">
                <div class="container-fluid">
                  <!-- Brand and toggle get grouped for better mobile display -->
                  <div class="navbar-header">
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                      <span class="sr-only">Toggle navigation</span>
                      <span class="icon-bar"></span>
                      <span class="icon-bar"></span>
                      <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" href="#">Brand</a>
                  </div>

                  <!-- Collect the nav links, forms, and other content for toggling -->
                  <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                    <ul class="nav navbar-nav">
                      <li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li>
                      <li><a href="#">Link</a></li>
                      <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
                        <ul class="dropdown-menu">
                          <li><a href="#">Action</a></li>
                          <li><a href="#">Another action</a></li>
                          <li><a href="#">Something else here</a></li>
                          <li role="separator" class="divider"></li>
                          <li><a href="#">Separated link</a></li>
                          <li role="separator" class="divider"></li>
                          <li><a href="#">One more separated link</a></li>
                        </ul>
                      </li>
                    </ul>
                    <form class="navbar-form navbar-left" role="search">
                      <div class="form-group">
                        <input type="text" class="form-control" placeholder="Search">
                      </div>
                      <button type="submit" class="btn btn-default">Submit</button>
                    </form>
                    <ul class="nav navbar-nav navbar-right">
                      <li><a href="#">Link</a></li>
                      <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
                        <ul class="dropdown-menu">
                          <li><a href="#">Action</a></li>
                          <li><a href="#">Another action</a></li>
                          <li><a href="#">Something else here</a></li>
                          <li role="separator" class="divider"></li>
                          <li><a href="#">Separated link</a></li>
                        </ul>
                      </li>
                    </ul>
                  </div><!-- /.navbar-collapse -->
                </div><!-- /.container-fluid -->
            </nav>
        <g:layoutBody/>
    </body>

   

Running Gradle task


In NetBeans, I run the clean and assemble Gradle task to download and install your plugin.You have to go in project tab and made right clic then choose task ( clean or assemble ).It will download and install the plugin.Then restart your application.


   
   
   
   

Grails 3 and Netbeans 8.0.2 : warning about Gradle 2.3 compatibility


I had a warning in Netbeans IDE 8.0.2 about Gradle 2.3 compatibility.I followed the following steps to clear this warning. In files tab, I did a right clik on my project.I choose properties and Gradle project Categories.Then I changed the Gradle home to my Gradle 2.7 directory like the following :






And the annoying warning disappeared !

Saturday, September 26, 2015

Eclipse plugin :no menu in Extension when right clicks


I'm looking at eclipse plugin and I met a problem in extension view : I can't access to the extension menu when I did right click.

I have also the following warning in Extensions View : No schema found for the “org.eclipse.ui.menus” extension point

To solves it,  I add Eclipse RCP Target Components ( see http://stackoverflow.com/questions/8366303/no-schema-found-for-the-org-eclipse-ui-menus-extension-point )

  1. In Eclipse, go to Help > Install New Software... 
  2. Update site: http://download.eclipse.org/eclipse/updates/4.5
  3. Choose "Eclipse RCP Target Components" and press Next to install them

Now the menu appears :




Eclipse IDE for Java Developers
Version: Mars Release (4.5.0)














Sunday, September 20, 2015

Grails 3 and IDE support


I'm looking at support of grails 3 by the IDE.
To now, here is an overview :
  • Eclipse : none support, plug-in disappeared from STS.
  • Intellij : appears to be support but you to pay licensing ...
  • Netbeans : begins of support
The good point is Netbeans 8.0.2 recognizes Grails 3 project.So, i was able to create a new Grails 3 project.You can launch you application and there is also syntax highlights in GSP.
However, it's just the beginning and it needs some works.But, you can begin to practice with Grails 3.

https://stackoverflow.com/questions/29441503/grails-3-0-support-in-netbeans/32425071#32425071

One comment, under Eclipse, you can import Grails project as a Gradle project like said in documentation.But, I didn't find how to have syntax highlights in GSP.

Friday, September 18, 2015

Upgrade Grails 2.5.0 to 2.5.1

I successfully upgrade Grails to the version 2.5.1It's quite simple.You only have to follow the release note about plugins update.
I met only one problem.I had this warning : Script 'Upgrade' not found.

To solve that issue, you have to select 3 (SetGrailsVersion) ant it will make the update.

|Running pre-compiled script
|Script 'Upgrade' not found, did you mean:
   1) MigrateDocs
   2) IntegrateWith
   3) SetGrailsVersion
   4) InstallDependency
   5) DependencyReport
Please make a selection or enter Q to quit: 3


With this update, I solved the following error : http://stackoverflow.com/questions/32562678/grails-plugin-error-class-path-resource-cannot-be-resolved