Sunday, August 31, 2014

Upgrading Grails 2.3.6

Today, I decided to upgrade my Grails web site.
Now, I use Grails 2.3.6 and I decided to test severeal solution to upgrade my web site.
One note about how I upgrade my Grails version.I used "Change Grails SDK" feature of Grails plugin in IntelliJ.It simple and you can go back easily !

Grails 2.3.6 with JDK 1.8_05


This upgrade wasn't successful.Grails 2.3.6 doesn't work with JDK 1.8.
I rode forum and it seems normal.

I had the following message : Java HotSpot(TM) Server VM warning: ignoring option PermSize=256m; support was removed in 8.0 

opt/drieu/jdk1.8.0_05/bin/java -Dgrails.home=/opt/drieu/grails-2.3.6 -Dbase.dir=/home/drieu/workspaces/toolprod -Dtools.jar=/opt/drieu/jdk1.8.0_05/lib/tools.jar -Dgroovy.starter.conf=/opt/drieu/grails-2.3.6/conf/groovy-starter.conf -Xmx768M -Xms768M -XX:MaxPermSize=256m -XX:PermSize=256m -javaagent:/opt/drieu/grails-2.3.6/lib/org.springsource.springloaded/springloaded-core/jars/springloaded-core-1.1.4.jar -noverify -Dspringloaded=profile=grails -Didea.launcher.port=7532 -Didea.launcher.bin.path=/opt/drieu/intellij/idea-IU-12.1.6/bin -Dfile.encoding=UTF-8 -classpath /opt/drieu/grails-2.3.6/lib/org.codehaus.groovy/groovy-all/jars/groovy-all-2.1.9.jar:/opt/drieu/grails-2.3.6/dist/grails-bootstrap-2.3.6.jar:/opt/drieu/intellij/idea-IU-12.1.6/lib/idea_rt.jar com.intellij.rt.execution.application.AppMain org.codehaus.groovy.grails.cli.support.GrailsStarter --main org.codehaus.groovy.grails.cli.GrailsScriptRunner --conf /opt/drieu/grails-2.3.6/conf/groovy-starter.conf run-app
Java HotSpot(TM) Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
Java HotSpot(TM) Server VM warning: ignoring option PermSize=256m; support was removed in 8.0
| Loading Grails 2.3.6
| Configuring classpath
| Configuring classpath.
| Environment set to development
| Environment set to development.
| Environment set to development..
| Environment set to development...
| Environment set to development....
| Environment set to development.....
| Packaging Grails application
| Packaging Grails application.
| Packaging Grails application..
| Packaging Grails application...
| Packaging Grails application....
| Packaging Grails application.....
| Running Grails application
Java HotSpot(TM) Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[ERROR] 2014-08-30 19:29:07,296 ScaffoldingGrailsPlugin - Error configuration scaffolding: startup failed:
script1409426946353650946897.groovy: -1: Repetitive method name/signature for method 'java.lang.Object withFormat(groovy.lang.Closure)' in class 'toolprod.ServerController'.
 @ line -1, column -1.
script1409426946353650946897.groovy: -1: Repetitive method name/signature for method 'java.lang.Object withFormat(groovy.lang.Closure)' in class 'toolprod.ServerController'.
 @ line -1, column -1.
2 errors
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
script1409426946353650946897.groovy: -1: Repetitive method name/signature for method 'java.lang.Object withFormat(groovy.lang.Closure)' in class 'toolprod.ServerController'.
 @ line -1, column -1.
script1409426946353650946897.groovy: -1: Repetitive method name/signature for method 'java.lang.Object withFormat(groovy.lang.Closure)' in class 'toolprod.ServerController'.
 @ line -1, column -1.
2 errors
    at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:309)
    at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1065)
    at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:572)
    at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:550)
    at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:527)
    at ScaffoldingGrailsPlugin.createScaffoldedInstance(ScaffoldingGrailsPlugin.groovy:183)
    at ScaffoldingGrailsPlugin.configureScaffoldingController(ScaffoldingGrailsPlugin.groovy:138)
    at ScaffoldingGrailsPlugin.configureScaffolding(ScaffoldingGrailsPlugin.groovy:113)
    at ScaffoldingGrailsPlugin$_closure2.doCall(ScaffoldingGrailsPlugin.groovy:88)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
[INFO ] 2014-08-30 19:29:07,523 conf.BootStrap - ENVIRONNEMENT : DEVELOPMENT
[INFO ] 2014-08-30 19:29:07,523 conf.BootStrap - Nothing to load at startup ...
| Server running. Browse to http://localhost:8080/toolprod


Grails 2.3.6 to 2.4.3


I also test the following use case.I upgraded to 2.4.3 my web site.
However,  I had compilation error :


Grails 2.4.3 with jdk7

me/drieu/workspaces/toolprod/target/work/plugins/scaffolding-2.0.1/src/java/org/codehaus/groovy/grails/scaffolding/view/ScaffoldingViewResolver.java:42: error: no interface expected here
public class ScaffoldingViewResolver extends GrailsViewResolver {
                                             ^
/home/drieu/workspaces/toolprod/target/work/plugins/scaffolding-2.0.1/src/java/org/codehaus/groovy/grails/scaffolding/view/ScaffoldedGroovyPageView.java:87: error: method createResponseWriter in class GroovyPageView cannot be applied to given types;
            out = createResponseWriter(response);
                  ^
  required: GrailsWebRequest,HttpServletResponse
  found: HttpServletResponse
  reason: actual and formal argument lists differ in length
/home/drieu/workspaces/toolprod/target/work/plugins/scaffolding-2.0.1/src/java/org/codehaus/groovy/grails/scaffolding/view/ScaffoldedGroovyPageView.java:75: error: method does not override or implement a method from a supertype
    @Override
    ^
/home/drieu/workspaces/toolprod/target/work/plugins/scaffolding-2.0.1/src/java/org/codehaus/groovy/grails/scaffolding/view/ScaffoldingViewResolver.java:88: error: cannot find symbol
        return super.createFallbackView(viewName);
               ^
  symbol:   variable super
  location: class ScaffoldingViewResolver
/home/drieu/workspaces/toolprod/target/work/plugins/scaffolding-2.0.1/src/java/org/codehaus/groovy/grails/scaffolding/view/ScaffoldingViewResolver.java:58: error: method does not override or implement a method from a supertype
    @Override
    ^
/home/drieu/workspaces/toolprod/target/work/plugins/scaffolding-2.0.1/src/java/org/codehaus/groovy/grails/scaffolding/view/ScaffoldingViewResolver.java:97: error: cannot find symbol
        view.setApplicationContext(getApplicationContext());
                                   ^
  symbol:   method getApplicationContext()
  location: class ScaffoldingViewResolver
/home/drieu/workspaces/toolprod/target/work/plugins/scaffolding-2.0.1/src/java/org/codehaus/groovy/grails/scaffolding/view/ScaffoldingViewResolver.java:98: error: cannot find symbol
        view.setServletContext(getServletContext());
                               ^
  symbol:   method getServletContext()
  location: class ScaffoldingViewResolver
/home/drieu/workspaces/toolprod/target/work/plugins/scaffolding-2.0.1/src/java/org/codehaus/groovy/grails/scaffolding/view/ScaffoldingViewResolver.java:99: error: cannot find symbol
        view.setTemplateEngine(templateEngine);
                               ^
  symbol:   variable templateEngine
  location: class ScaffoldingViewResolver
8 errors


1 error

Process finished with exit code 1


The right choice


It isn't a suprise but the right choice is to update Grails 2.3.6 to 2.3.11.
It 's easy and it works ;-)

Monday, August 25, 2014

Web Component


This paper is a synthesis about I heared and rode about Web Components.
To make this article, I used mainly InfoQ video of Julien Vey and html5rocks web site.

Web Components is W3C standard which is at DRAFT status.So, you will have to wait before it arrived. However, it is possible to use because main actors of the web (Mozilla, Google ...) started to work on this specification.


What is a Web Component ?


Here is a good definition I found on article of Julien Vey d'InfoQ :
Web Components permit developpers to create HTML tags which are reusable and customizable.For example, here is a tag <my-own-tag> : 
<element name="my-own-tag">
 <template>
   html tag here
 </template>
 <script>
   // JavaScript
 </script>
</element

Note : When it will be implemented and approved by W3C, it will be possible to reuse a component on all web navigator !

Why look at Web Component now ?


- It is a web standard of W3C.
- Main actor of web began to implement it.
- It will change way of working in web developpement because components will be reusable on all navigators.

Web navigators and Web Components


A good summary of specification and implementation is avaible here : are we component yet ?
Now, there is a lot web navigators that doesn't support Web Component.However, it exists emulation for Web Component : polyfills.Polyfills permits to start using Web Component.

Here are some project :
  • x-tags : x-tags is a Mozilla JavaScript library which works on all Web Navigators.
  • Polylemer  is a Google library ( there is a talk on Google I/O )
  • UI library for Dart : web-ui
  • toolkitchen

Web Components 


Templates


Here is an example of template :

 <template id="">
 </template>

Template is simply a reusable peace of code.You have to note that Web Component are parsed but not executed and picture aren't load in memory.

Shadow DOM


Shadow DOM permits to make encapsulation without iframes. So we will mask implementation of a tag.

For example :

In the source we have our tag :

<div id="mondiv"></div>


When we will show the HTML web page, we will have :

<div id="mondiv">
<h2>mon contenu</h2>
</div>

The content are fill at execution.
To instanciate this shadow DOM, you can :


  • Use JavaScript

For example :

var shadow = ....
shadow.innerHtml="<h2>mon contenu</h2>"


  • Use Insertion point

We define a div with our content :

<div id="host">
</div>

This tag will permit to show our content :

<content></content>


Custom element


A Custom element will contain all we saw before :

<element name="moncomposant" extends="button" constructor="moncomposant>
     <template>
    </template>
    <scritp>....</script>
</element>

In my web page :

<link rel="component" href="moncomposant">
<moncomposant></moncomposant>

Other things


In this paper, I didn't address mutation observer and model driven view which permit to make databinding and evaluate performance...

More infos


http://www.html5rocks.com
http://www.infoq.com/fr/presentations/web-components
http://www.infoq.com/fr/news/2013/06/webcomponents