Friday, April 17, 2015

Friday after-work coding

Woo-hoo, it's Friday, off work, I can code what I want.

I'm using Maven to build my OpenShift application.

My pom.xml:




Tuesday, April 14, 2015

IntelliJ IDEA and Git

Well, I've gotten a basic "Hello, world" Spring Web MVC Application running in JBoss Wildfly 8.2.0.Final set up with the initial Git Repo from OpenShift.

Now, I'm trying to do my first commit.  I've worked with Git through the Git Bash (msysgit), along with TortoiseGit and through Visual Studio / Git integration.

Even cloned, pushed, fetched to/from GitHub through these tools for .NET Projects.

However, this is my first experience using Git through IntelliJ IDEA on a pure Java project.

Initial take: for some reason IntelliJ is *not* picking up my and from the Global Git configuration.

From my Git Bash:

$ git config --list
rebase.autosquash=true Tenn

What I am seeing on the VCS commit window in IntelliJ:

I could (and did) manually type into this ComboBox my name and .  Just seemed strange it did not pick up from my Git config. 

Monday, April 13, 2015

Error running Wildfly 8.2.0.Final: Address localhost:9990 is already in use

Downloaded the latest JBoss Wildfly Final release (8.2.0.Final as of today, 2015-04-13).

Thought I would do some late-night personal coding now that the everyone else has gone to sleep.

Trying to run it through my IDE, immediately get an error:

Error running Wildfly 8.2.0.Final: Address localhost:9990 is already in use

I did some searching, and found the program that is competing with JBoss for port 9990 (which JBoss uses for its management endpoint by default).

C:\java\jdk1.7.0_76>netstat -a -b

  TCP         acer-predator:0        LISTENING

Aha ... NVidia's Network Service.  Now, I could change JBoss's port easy enough, but I like using out-of-box configuration.  I don't want to hack up my JBoss configuration to play nicely with my Windows Environment when I'll be working out of Linux as well ... best to make the Windows Environment work with my development projects.

Went into Windows Services, found NVIDIA Network Service, stopped it, set it to Manual.

Now Everything is actually Awesome! :-)  JBoss Wildfly starts up great!

OpenShift, Git and Maven

This is very interesting, it appears that by creating the OpenShift Application, it created a whole initial code layout (similar to a Maven Archetype), complete with POM file as the first commit in the git repository.

Here is what I saw when viewing the log for the cloned Git repository that OpenShift created:

I've always believed in trying to follow the best practices and standard approaches whenever I come into an environment.

For example, when doing Java Development, I follow the camelCase method naming approach; when doing C# development, I follow the PascalCase method naming approach.

In keeping with this tradition, I'm going to try and use Maven, seeing as how OpenShift coreated a pom.xml on my behalf. 

Sunday, April 12, 2015

OpenShift Client Setup

I just signed up for the free OpenShift account.

OpenShift is RedHat's foray into PaaS.

Since I've used JBoss as my JavaEE Application Server for the past 10 years at work (going all the way back to JBoss AS 4.2.2), it made sense for me to use as a platform for personal development projects.

They gave me 3 free small gears to use.  Ended up using my first one for a JBoss Wildfly 8.2.0.Final cartridge (community created).  I'm sure I'll need to use my second one for the database (debating between MySQL and Postgres).

It was easy to create the server instance.

Next step: gain access.

I followed the instructions for setting up OpenShift rhc Client Tools in a Windows Environment (I run a dual boot Fedora Core 21 / Windows 7).  Normally I do all my development out of Linux except .NET Development, and if/when I really start rolling on an OpenShift-deployed project, I'll probably switch back to Linux.

Step 1 - Install Ruby

Installed the latest Ruby x64 for Windows:

ruby 2.2.1p85 (2015-02-26 revision 49769) [x64-mingw32]

Step 2 - Install Git

Already had Git on my machine.

Step 3: Install and Configure the OpenShift gem

Ran into an error immediately after running rhc setup.

kernel_require.rb:54:in `require': cannot load such file -- dl/import (LoadError)

Upgraded net-ssh to 2.9.3.beta1 like the answer recommended, re-ran rhc setup, and it worked like a champ. 

Now that I'm all set up, next steps for me will include:

  1. Cloning (and understanding) the built-in Git Repository with the OpenShift Application.  I was surprised to read in their documentation that each OpenShift Application has its own Git Repo.  I had expected to create a Repo on GitHub and when I needed to deploy to OpenShift, I thought I would just drop a WAR or EAR file. 
  2. Setting up my Gradle Build. 

Wednesday, July 3, 2013

JavaScript, Backbone.js, node.js, MongoDB

I've been spending a lot of my personal development time looking into JavaScript frameworks.

It's amazing how much the language has grown up.  I still remember doing Web Development in college (back in 1998) for University websites and using JavaScript for client-side form validation.

You know, the tacky alert pop-ups that you hit the user with, one after another, when he/she has not filled in all the fields of an HTML form.  Ugh.

Well, given the long and sordid history of JavaScript, I have been amazed at how it has grown and evolved (AJAX, Prototype, jQuery, Backbone), and recently learned that people are doing server-side development in JavaScript on Node.js.

I will admit, I was a bit skeptical about Node.js when I first heard about it.  My first thought was "that cannot be performant", thinking again back to client-side scripting.

However, as I read more and more about Node.js, I began to think "This isn't your father's JavaScript."  What I did not realize initially was that Node.js runs on Chrome's V8 JavaScript engine, which is written in C++.

I'm digging into it and thinking about building a Web Application using a combination of:

Bootstrap + Backbone (front end) -> Node.js -> Mongoose (OR/M) -> MongoDB (Database).

Wednesday, September 26, 2012

Grails, GORM, lazy loading one-to-one

I spent all yesterday evening trying to figure out a way to lazy load a one-to-one relationship. At first glace, this probably looks like an academic exercise. However, I have a very pragmatic reason for needing to lazy load a one-to-one relationship.

I have Property and PropertyDetail Domain Classes. 

For now, I am storing images in the database.

Long-term, I am going to look at using Amazon S3 for storing images, but for a personal project where I am still learning, it seems like a decent compromise.

class PropertyDetail {

    static constraints = {
        description type: 'text'

    static belongsTo = [property : Property]

    String description
    byte[] imageMain
    byte[] image1
    byte[] image2
    byte[] image3
    byte[] image4
    byte[] image5

I am going to have a list page for Property domain class.

I definitely do not want to take the hit of pulling the PropertyDetail class, not with the images stored in the database.

I hit a wall late evening, when I discovered the following Jira Issue: GRAILS-5077 hasOne mapping is by default eager and cannot be changed to lazy.

However, this is an older JIRA issue, and I did see on the recent Grails 2.1.1 documentation information on doing lazy one-to-one.

My new plan is to:

  1. Try the approach documented for Grails 2.1.1.
  2. Turn on SQL logging
        datasource { 
            logSql = true 

  3. If that does not work, drop back and remap this relationship as a many-to-one.