Tuesday, July 28, 2015

Maven Resources Filtering

I can never remember what its called. So I better make a blog post of it:


Basically allows us to copy strings from the POM, to any text based resources (e.g. XML, .properties files).

Thursday, July 16, 2015

Configuring Glassfish with Virtual servers behind nginx

I recently had to configure a virtual server on Glassfish behind nginx. I had to configure the virtual server to serve up a default application. Furthermore, I had to configure nginx to only accept HTTPS (SSL) requests to this virtual server.

I recorded quite a bit what I did. So I added in some fancy Powerpoint slides and uploaded the result to Youtube here.

The summary of steps I list here:

1. Install Glassfish and Nginx

(self explanatory)

2. Create a virtual server

To do this we do the following:

  1. Create a thread pool
  2. Create HTTP protocol (ignore the default virtual server setting for now)
  3. Create listener (ignore the default virtual server setting for now)
  4. Create virtual server
  5. Edit the listener (step #3) and protocol (step #2)

3. Create a self signed certificate

For development purposes, we create a self signed certificate. Of course for an actual production site, you'd need to buy it from a provider.

sudo openssl req -x509 -nodes -days 36500 -newkey rsa:2048 -keyout /Users/gerard/my_domain.key -out /Users/gerard/my_domain.crt

The above command will prompt for a common name. We then type the domain name that the certificate will be tied to.

4. Configure nginx

We tell Nginx to listen on the standard SSL port and to use the certificate for those connections.

server {
    listen       443 ssl;
        server_name  cas.gerardsetho.net;
        access_log  var/log/nginx/cas.access.log;

    ssl_certificate      /Users/gerard/my_domain.crt;
    ssl_certificate_key  /Users/gerard/my_domain.key;

    location / {
        proxy_pass http://localhost:28090;


Wednesday, May 6, 2015

Macports' select command

I've been searching everywhere online and I can't find any information on Macports' "select" command. So here I list down what I personally need. I hope that helps anyone else reading this.

In OS X, after installing, say python34 via Macports, "python" still points to Yosemite's built-in Python:

$ which python

To have "python" point to the new python34, we use Macports' "select" command:

$ sudo port select --set python python34
Selecting 'python34' for 'python' succeeded. 'python34' is now active.

$ which python

$ ls -l /opt/local/bin/python
lrwxr-xr-x  1 root  admin  24 May  6 16:47 /opt/local/bin/python -> /opt/local/bin/python3.4

Perfect. Now "python" points to /opt/local/bin/python, which points to /opt/local/bin/python3.4.

To have "python" link back to Yosemite's default installation:

sudo port select --set python none
Selecting 'none' for 'python' succeeded. 'none' is now active.

$ which python


Monday, March 9, 2015

Compiler version error

I get the below error once in a while. And its frequent enough to annoy me and to warrant a note on it.
Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: java.lang.UnsupportedClassVersionError: WEB9032: Class com.xxxx.yyyyy.MainController has unsupported major or minor version numbers, which are greater than those found in the Java Runtime Environment version 1.6.xxxx. Please see server.log for more details.

This is mainly caused by compiling some of my classes using the a different version Java compiler. This happens sometimes when I create a new Intellij IDEA project for the same source code and I forget to set the Java SDK correctly.

To prevent this, simply force Maven to use the correct compiler version. Then nothing can possibly go wrong.


Monday, November 3, 2014

Kendo + Angular + IE9 = a big mess

Using Kendo UI and Angular JS and getting it to work in IE9 is just a huge pain.

The newest form of this torture comes in trying to get ng-disabled to work with Kendo's Combobox. Here is the Plunker.

It works fine in any browser except IE9 (I haven't tried IE10 or 11).

Basically consists of:

  1. A checkbox. This checkbox will modify a boolean "isComboDisabled". 
  2. A word, either "true" or "false", depending on the boolean "isComboDisabled". 
  3. A Kendo Combobox, with the ng-disabled attribute bound to the boolean "isComboDisabled".
In Safari, as expected, when I:
  1. check the checkbox, 
  2. the word says "true", 
  3. and the Combobox is disabled.

In IE9, when I:

  1. check the checkbox, 
  2. the word says "true", 
  3. and the Combobox is remains enabled.
It appears that AngularJS is doing its job; the binding works fine. But somewhere between Kendo and AngularJS, ng-disabled of a Kendo Combobox doesn't bind. This also happens for a Kendo Dropdown List.

The workaround is u-ge-ly. The Plunker is here
  1. I watch for changes to the boolean.
  2. And I call Kendo's enable() function directly.
Days like this, I long for the Adobe Flash era...