Devoxx 2014 Notes

I just love devoxx. Perfect place without working yet breathing in and out software.Was again excellent this year, full of tech and fun.

Innovative

Wristbands.Loved them.Devoxx organisers just built this great mechanism to facilitate lunch and other stuff collecting and voting for sessions via these wristbands.Integrated NFC module,waterproof.All software built in-house. It is being used at least for 3 years.You don’t ever need to take it off,so no ‘check where the badge is’..

Devoxx Hunt.Excellent gamification. They ordered hundreds of again NFC module devices (from China) and distributed the to all over the city of Antwerp and the venue.Via you mobile app,you could collect those beacons,as you get physically close to them, unlock achievements and win free tickets to next devoxx.Software was built on Java 9 according to what one of the devs said.Great work. Appreciate this innovative spirit of Devoxx crew.

Voxxed.com :Server-side replacement,it looks like.A web site where you can quickly get updated about what is going on in Java world.

Hottest Technologies

Docker was one of the most popular technologies shined on us.Other starts of the devoxx were Openshift,Angular.js,Polymer, Websockets,Raspberry Pi(Of course),Java 8 Lambdas and JavaEE Microservices.

-So many simultaneous conferences,hard to choose..It is handy that devoxxians will have 1 year free Parleys subscription and will be able to watch other sessions on the web.

-There were lots of non-techie sessions this year. Session about creativity by Denise Jacobs was remarkable. There was also a whole stream about startups. A guy told about his really painful experience as a contract developer where he did not get any payment. Company he worked for owed him around 20 grand euros.I don’t remember the exact amount but it was something in this range.So he was really determined to get it through following legal procedures.After 1.5 year,he ended up having already spent another 20K and still could not even get in front of a judge.For that he needed some more time and more money.And the judge is as you can imagine a 60+ with no understanding of any technical stuff whatsoever.So his clear message was ‘if you can not get your many,just write it off! Forget about it and move on with your life.’ Pretty upsetting story.

Advertisement

Node-Angular and Nosql App Part 2

We are adding full text searching functionality to our application.This tutorial assumes that you already completed part 1.Please refer to here for part 1.

Unfortunately,Couchbase does not have full text search feature as of version 2.2.0. So,it is advised to integrate Couchbase with elasticsearch to provide this.

Elastic search is a search analysis tool and a key value store which is getting more and more popular.

Here are the steps:

    1. Install Elasticsearch version 0.90.5 since this is the one compatible with Couchbase 2.2.0.Installation available here.
    2. Install Couchbase Elasticsearch plugin version(assuming you have Couchbase 2.2.0 installed) 1.2.0 following instructions here.Be careful with the version numbers since it does not work but with compatible version.Below is the version compatibility matrix:couchbaselabs-elasticsearch-transport-couchbase · GitHub
    3. Verify that you can see administration console of elasticsearch upon starting on http://localhost:9200/_plugin/head/ .
    4. Install the Couchbase template using  curl -XPUT http://localhost:9200/_template/couchbase -d @plugins/transport-couchbase/couchbase_template.json
    5. Create an index guardian on elasticsearch admin console http://localhost:9200/_plugin/head/
    6. elasticsearch-head
    7. Configure Couchbase to replicate data to elasticsearch:
      1. Navigate to the Couchbase Server admin interface.
      2. Select the Replications tab.
      3. Press the button labeled “Create Cluster Reference”
      4. Choose a name for your ElasticSearch cluster
      5. In the IP/Hostname and field provide an address and port of one of the nodes in your ES cluster (127.0.0.1:9091)
      6. Enter the Username and Password corresponding to your “couchbase.username” and “couchbase.password” settings in ElasticSearch. Refer to bullet no 2 for this.
      7. Press the “Save” buttonCouchbase Console (2.2.0)
      8. Press the button labeled “Create Replication”
      9. Select “guardian” bucket from source cluster
      10. Next select the cluster you defined in previous step
      11. Click advanced settings and set XDCR Protocol to version 1.
      12. Press the button labeled “Replicate”CouchbaseReplicate
      13. Verify on elasticsearch admin console that replication took place.
        elasticsearch-data
    8. Now that you completed the installation and configuration,it is time to run the code and try it out. Go to github and download the code available at https://github.com/selmantayyar/guardian-news-content/tree/version2 . This is the same github repository as the part one but on a different branch.To avoid installing couchnode again,just override your current local code copy with this.If this is the first time you are running this code,follow the instructions on readme file.Otherwise just type node app.js and enjoy it.Guardian Newspaper Football Content
    9. But how does the searching work?Application does a REST call to elastic search server sending the keyword.A very simple post request,which makes elastic search really easy to use.By the way,a very nice introduction to elasticsearch is here.
   $scope.searchNews = function () {
 console.log('scope keyword: '+$scope.form.keyword);
 var queryStr={
 'query': {
 'query_string': {
 'query': $scope.form.keyword,
 'fields': ["trailText"]
 }
 }
 };
 $http.post('http://localhost:9200/guardian/_search', queryStr).
 success(function(data) {
 console.log(data);
 searchResultService.setSearchresult(data);
 $location.url('/readNews');
 });
 }; 

Results & Analysis

To sum up, noticing that Couchbase(as of version 2.2.0) does not have any full text search feature is a bit disappointing.You need to install elasticsearch,replicate the data to it and handle all the data transfer issues,indexing issues(updating data sometimes could require indexes and mappings to be updated ..etc) and other potential issues.This is an additional operational burden. Couchbase is really good for storing data and retrieving it by key or by some other indexes.It is also easier to manage replicas.However, i still would expect full text search functionality here.

Node-Angular and Nosql App

I have created a simple web application using Node.js(Expres) on server-side.DB is Couchbase and using client as Angular.js

Basically,it is displaying data stored on couchbase using different views(queries if we speak in relational db terms).Data comes from The Guardian Open Data Platform via another app that i wrote.It is bringing various articles from Guardian website using the API that is served.By the way,i highly recommend anyone to have a look at The Guardian Open Data Platform.

Guardian Newspaper Football Content

It is using express web application framework for server side operations.REST services are defined and connecting to and querying couchbase is implemented inside.Getting and querying data from a nosql db -including map-reduce functions- is showcased here.

<br /><%%KEEPWHITESPACE%%>  var db = new couchbase.Connection( config, function( err ) {<br /><%%KEEPWHITESPACE%%>    if(err) {<br /><%%KEEPWHITESPACE%%>      console.error("Failed to connect to cluster: " + err);<br /><%%KEEPWHITESPACE%%>      process.exit(1);<br /><%%KEEPWHITESPACE%%>    }<br /><br /><%%KEEPWHITESPACE%%>    console.log('Couchbase Connected');<br /><%%KEEPWHITESPACE%%>  });<br /><br /><%%KEEPWHITESPACE%%>  var params = { limit:1000, reduce:false};<br /><%%KEEPWHITESPACE%%>  params.key =category;<br /><%%KEEPWHITESPACE%%>    db.view( "dev_news", "news_by_section", params).query(function(err, results) {<br /><br /><%%KEEPWHITESPACE%%>      res.json({<br /><%%KEEPWHITESPACE%%>        posts: results<br /><%%KEEPWHITESPACE%%>      });<br /><%%KEEPWHITESPACE%%>    });<br /><br />

On client-side Angular.js is used as MVC javascript framework.For templating, Jade is in place.

All in all,two things to install and run as well as source code of course available in Github:

  1. Data populator using The Guardian Open Data platform:https://github.com/selmantayyar/GuardianRestClient
  2. Actual web application:https://github.com/selmantayyar/guardian-news-content

README files have clear instructions for installation.

Please let me know if you face any issues.

Next step is to do content base search using ElasticSearch.

Monsieur Joseph-Marie Jacquard

Image

The guy who invented Jacquard Loom,which i think a very underrated invention founding basis of binary concept.This is when history of computing began!

He was a french weaver on 19th century.To make weaving more efficient,he used punch cards(card having small wholes or not on its surface).A pin of the loom hits the card,if it is punched,it operates with its hook,otherwise it does nothing.So technically,he programmed the loom to produce the desired output.

This was the start of the way up to the Mainframe,which resulted in IBM giving credit to him.

Installing Couchenode on Windows 7

What a nightmare!

First,straight parts:

Installing node-gyp

npm install -g node-gyp

Installing Python

Install version  2.7.3  here. Newer versions do not work.

Installing Libcouchbase

Download C client library from here.Extract it under C:/couchbase. lib folder should be placed right under this directory.

Now,the fun part:

Installing Visual Studio

We need this for C/C++ compiler.Anybody can find a better solution,be my guest.Since this was painful,i am writing down step-by step instructions.

You need to install Visual Studio 2010.Not a newer version!

If you have any Visual C++ 2010 copies on your machine,remove them. Uninstall any Visual Studio or SDK from your machine,including the ones installed by other programs.

Download and install Visual Studio C++ 2010 Express from here,then SDK 7.1 from here and then Visual C++ Compiler Update from here.Please follow this order.Otherwise if you type on your command line:

npm install couchbase

you could get the very fancy error:

“error MSB8007: The Platform for project ‘couchbase_impl.vcxproj’ is invalid.
Platform=’x64′. You may be seeing this message because you are trying to build a project without a solution file,……blablabla  “

Once you are done with this,run the install command again.

npm install couchbase

You would see the error below:

c:\program files (x86)\microsoft visual studio 10.0\vc\include\intrin.h(26): fatal error C1083: Cannot open include file: ‘ammintrin.h’: No such file or directory

To overcome this,install Microsoft Visual Studio 2010 Service Pack 1 from here.

Finally,

npm install couchbase

should work.

Sorry to expose so much Microsoft stuff to you.

Book Review: Beginning Java EE 7 (Antonio Goncalves)

Recently i read “Beginning Java EE 7”, book from Java User Group Leader and Java Champion Antonio Goncalves.

This book  is a very neat introduction to JavaEE 7 getting into details in course of each chapter and putting everything together in a hands-on experience at the end.It is starting with an historical intro to JavaEE and then going through all components of it in a quite structured way.

It is a quite thick book(500 pages) divided into 15 chapters.Each chapter picks an essential component of JavaEE and gets into details using a bottom-up approach.Starting with a general introduction to JavaEE7,book goes all the way through Context and Dependency Injection,Bean Validation,Java Persistence API and ORM in first 6 chapters.Next 3 chapters cover EJB’s in every sense includingTransactions,Callbacks,Security Services.Chapter 10 and Chapter 11 are about front-end:JSF and Navigation.The 12th chapter of the book is about XML and JSON processing and what JavaEE 7 brought in.Chapter 13 is named “messaging” and leaves no open questions about JMS  and Message Driven Beans. As to the last two chapters;they  are dedicated to Web Services (SOAP and REST).

Image

What i liked most about this book is the way it follows through each chapter. It starts with very simple and clear definition.Then it gives us some historical background of that component along with an overview of related Java Specification.Then we get introduced to what is new about that component in Java EE 7.And only after these steps we dig into broader details and start feeling the joy of coding.Personally i like this kind of well-planned and structured approach hence i enjoyed this book a lot.Moreover, it is a very contentful reference book.

One improvement could be to compare JavaEE with the current frameworks in place (like Spring) in much more detail.Since open source frameworks on Enterprise Java are arguably prevalent in the industry,it would be nice to have to see differences and JavaEE’s advantages over them.

All in all,i certainly recommend Antonio Goncalves’ book to all Java/JavaEE developers.It is definitely worth reading and if you are not into reading a few hundred pages,worth using as a reference book.

IE not going along very well with bind function

This is actually rather a note to myself.

I am doing some client-side these days. JQuery,datatables,Backbone,Underscore etc..

I was using $.getJSON like below which works perfectly on firefox:

$.getJSON(“/api/sar/?_=” + Math.random() + “&” + query, function(data) {

//do some stuff here

}.bind(this));

However,it didn’t work on IE.Plus, no error message as you can imagine.I did lots of research and just before starting banging my head against walls,i found that there is an incompatibility between IE and jquery bind method. I don’t think it is valid for all cases but that’s why i found out thanks to this entry in stackoverflow.

As a quick solution,JQUERY spec recommends to use $.proxy function when binding this value of the function.So the code makes both browsers happy is:

 $.getJSON(“/api/sar/?_=” + Math.random() + “&” + query,  $.proxy(function(data) {

   // do some stuff here

     },this));

 

Book Review:Learning Android

Last week i’ve read the book  Learning Android by Marko Gargenta.

It is a really very “neat” one,probably most suitable one to start with Android development. It is like a big tutorial walking you through the whole process of development a twitter-like app starting from environment set-up till a complete application where you can read and post tweets. Neither a reference book nor providing an in-depth look to android stack components,however it is supplying theoretical basis and putting you in action for a very rapid development experience.
The book starts with an overview of Android stack and the summarizes main building blocks;activities,intents,services,broadcast receivers and content providers. Right after this relatively short introduction,it dives into development and you grasp insightful understanding of main blocks and UI artifacts on the fly as you develop.Application code is satisfactorily detailed -even line by line in some cases- so you do not miss anything and end up having no questions by the end of each chapter.Moreover,lots of hints and tips take place to make better use of Eclipse IDE and to avoid some chronical exceptions. I also should add that it is fairly easy to read since structured very well into chapters and each chapter boiled down to sections in a concise manner.Even it includes a considerable amount of code (listing) it is a joy to read it.

As to downsides, as i said,it is more like a tutorial enriched by conceptual side knowledge.But not sure if this is a true disadvantage if you would like to make a  fast start to Android application development.

All in all,i definitely recommend this book to beginners.It is really a great feeling to have an application up and running already  just after you finished the first book you read about Android,if you are a beginner.If you already develop Android Apps and need some more low level structured and more detailed one or a  reference book, this might not be the best choice.

JSR Watch

New year’s activity review  of  Java Community Process is published.

There are currently 70 JSRs active. According to the report, 27 of them were aimed at J2ME, 20 of   them target J2SE and 15 of them target JavaEE.

As to the new ones, 6 new JSRs  come to the field at 2009,only one of which was realized by Sun : JSR 322: Java EE Connector Architecture 1.6

If we take a lokk at spec leads; Sun stands ahead as usual with 27 JSRs. The others are:Nokia (11), Oracle (8), Motorola (5), and IBM (4)