Evaluating EclipseLink 1.1

As I’m using the ubiquitous Hibernate 3.3 as the JPA 1.0 provider for Spincloud, I decided to try out another one. I had tried OpenJPA (spawned from Kodo JDO) when they only supported build-time bytecode enhancement and it was a pain to make it work. It worked all right but boy what a pain. There’s now an agent to provide on-the-fly enhancement but I’ll take transparent enhancement anytime.
I’ve heard about EclipseLink before. The project started when Oracle donated the respectable TopLink project to the Eclipse foundation. If the solid reputation behind TopLink was a good enough argument for me to try it, the announcement that it will be the JPA 2.0 reference implementation convinced me that I should try it out.
My goal is to evaluate if EclipseLink is production-ready. I’m applying a complex set of evaluation criteria (joking): if it can run Spincloud then it is (I was inspired by Seifer’s interview on Infoq about Ruby VMs; when asked what was the criteria for qualifying if a Ruby VM is production ready, he answered: if it runs Rails).

I have the following JPA requirements:
– column mappings, one-to-one, one-to-many
– supports BLOB fields
– supports NamedQueries and NamedNativeQueries
– support for object cache and query cache
– deployment/operational nice to have: ease of maintaining compatibility with both EclipseLink and Hibernate in the source code and runtime. Ideally I should plug-in any JPA provider without changing a single line of code. This was not attainable as I’ll explain below.

I started by downloading the binaries. I’m using Maven to bring the jars so I’ve followed the instructions here. I only changed the version since I wanted to use v1.1.0:

  <dependency>
    <groupId>org.eclipse.persistence</groupId>
    <artifactId>eclipselink</artifactId>
    <version>1.1.0</version>
    <scope>provided</scope>
  </dependency>

There’s a single jar file called eclipselink-1.1.0.jar downloaded which is a nice change from the multitude of Hibernate jars I was accustomed with.
Continue reading “Evaluating EclipseLink 1.1”

Choosing a Java hosting provider

TL;DR: Go for a VPS. I now use Digitalocean, they’re awesome.

Selecting a web hosting provider is a tough job for any web developer that wants to put a Java/JEE web application online. The choice is much simpler when it comes to publishing a PHP web site and there are a load of cheap (and sometimes quite reliable) PHP hosting providers to choose from with LAMP being the de facto standard in the web hosting world. But when it comes to Java hosting providers the picture becomes blurrier. The common thing that all these environments need is a Java container. The most popular choice is Tomcat but there are providers that use Resin, Weblogic or Websphere (the latter two are full fledged JEE containers).
With the raise of lightweight J2EE servers started by the Spring folks, a little revolution began in the Java world: running enterprise-grade JEE webapps without the need for an EJB container; a servlet container is enough. Tomcat should fill the bill for just about any Java web application that doesn’t use EJBs. The advantage that comes from running a servlet container is the smaller footprint compared with an EJB container. This is critical when it comes to selecting hosting environments since you’re paying for resources (especially RAM) that have to be sized to accommodate the memory requirements of the web application.

Self hosting: Home-based dedicated server (near $0)
homepcYou can use your home internet connection and a PC where the web container runs and deploys your web application. There is an obvious advantage since the server is physically located close to the development team: complete control and physical access to the machine. The other big plus is the price: you’re already paying for the internet connection and chances are you already have a PC that can be transformed into a server. And chances are that you already have a development environment that can be the basis of the production deployment. Here are the shortcomings:- Bandwidth limitations: the webserver where the webapp lives will upload content to the web browsers that access the application. The upload bandwidth is smaller than the download bandwidth and will result in longer load times for web clients.
– Some internet providers cap the internet traffic so you may run beyond the limit.
– You may violate contractual obligations you agreed with your Internet provider by running your own web server.
– The internet connection is not reliable: provider’s downtime directly translates in downtime for your webapp.
Continue reading “Choosing a Java hosting provider”

Upgrading to Spring 3.0

In the spirit of beta I’m upgrading spincloud.com to Spring 3.0. I’m using version 2.5.6 currently but it’s missing REST support and I had to use Carbonfive’s REST library which worked like a charm. Now it’s time to get back under Spring’s fold and use their built-in REST support. Spring 3 opens the door to a lot of new features so I’m eager to try it.

I’m using Maven2 to get the jars and Ant to build the project. To fetch Spring 3.0 binaries, you have to add the following repository if you don’t have it:

<repository>
  <id>SpringSource Enterprise Bundle Repositorys</id>
  <url>http://repository.springsource.com/maven/bundles/milestone</url>
</repository>

and the spring packages that you need since the packaging has changed from 2.5.x. Instead of a single spring.jar file, now there is one per feature so you have to sort out what jars to include in the project. I ended up with the following:

  <properties>
      <spring.version>3.0.0.M2</spring.version>
  </properties>
  <dependencies>
   ...
  <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>org.springframework.core</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>org.springframework.web</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>org.springframework.transaction</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>org.springframework.orm</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>org.springframework.jdbc</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>org.springframework.web.servlet</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>org.springframework.context</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>org.springframework.aop</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>org.springframework.expression</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>org.springframework.test</artifactId>
      <version>${spring.version}</version>
    </dependency>
  </dependencies>

Once the jars are brought, I’ve replaced my old jarfiles with the all-new M2s then fired the build target.
The first issue I found was with the asm version.
Continue reading “Upgrading to Spring 3.0”

Spincloud Labs: Political boundaries overlay in Google maps (Part 2)

Update Sep.21.2011: I took the code in the two parts and made a github project off of it called Gborders. The code is simpler and there are more options to generate the borders overlay based on geographic regions. Happy forks!

In Part 1 we imported world political borders into a database table. In this second part we’ll use the table and generate a script that will be used to add the borders overlay to Google Maps. We’ll use the cool Ruby and some fancy GIS words along the way.

We left-off with a database table containing all borders. The goal today is to produce a Javascript file that will be used for overlaying polygons representing countries, over a map using the Google Maps API.

Let’s examine the table data first (I’m using mysql through the command line):

mysql> desc world_boundaries;
+-----------+--------------+------+-----+---------+-------+
| Field     | Type         | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+-------+
| ID        | int(11)      | NO   | PRI | NULL    |       |
| FIPS      | varchar(255) | YES  |     | NULL    |       |
| ISO2      | varchar(255) | YES  |     | NULL    |       |
| ISO3      | varchar(255) | YES  |     | NULL    |       |
| UN        | int(11)      | YES  |     | NULL    |       |
| NAME      | varchar(255) | YES  |     | NULL    |       |
| AREA      | int(11)      | YES  |     | NULL    |       |
| POP2005   | bigint(20)   | YES  |     | NULL    |       |
| REGION    | int(11)      | YES  |     | NULL    |       |
| SUBREGION | int(11)      | YES  |     | NULL    |       |
| LON       | double       | YES  |     | NULL    |       |
| LAT       | double       | YES  |     | NULL    |       |
| ogc_geom  | geometry     | YES  |     | NULL    |       |
+-----------+--------------+------+-----+---------+-------+

A lot of information here but we’ll need just these fields: name (country name), iso2 (two letter country codes) the_geom, iso2 (border geometry) and region (grouping countries by regions). To check the data-set let’s examine a small country. I’ll pick the tiny State of Vatican for its size:

mysql> select iso2, AsText(ogc_geom), region from world_boundaries where iso2='VA';
+------+---------------------------------------------------------------------------------------------------------------------------------------------------+--------+
| iso2 | AsText(ogc_geom)                                                                                                                                  | region |
+------+---------------------------------------------------------------------------------------------------------------------------------------------------+--------+
| VA   | MULTIPOLYGON(((12.445090330889 41.903117521785,12.451653339581 41.907989033391,12.456660170954 41.901426024699,12.445090330889 41.903117521785))) |    150 |
+------+---------------------------------------------------------------------------------------------------------------------------------------------------+--------+
1 row in set (0.00 sec)

The only surprise here is that the country border is described as a MULTIPLOYGON spatial type which describe a collection of polygons that don’t interset. This is in order to accommodate countries that have islands under ownership.

Let’s see how these points look on the map. We’ll use the excellent polygon encoder utility written by Mark McClure. Copy Vatican’s point set in the “Input Text” input box (choose lng/lat option):

12.445090330889, 41.903117521785
12.451653339581, 41.907989033391
12.456660170954, 41.901426024699
12.445090330889, 41.903117521785

Here’s the result:
va_polygon
Not very accurate but we’ll have to live with it, it’s a free data set after all…
Continue reading “Spincloud Labs: Political boundaries overlay in Google maps (Part 2)”

Atlantis spotted on Google Earth?

I couldn’t miss this one. It didn’t take long  after Google released its seafloor imagery to its Earth and Maps products for someone to claim the discovery of nothing less than Atlantis itself! Ah, and again it wasn’t me…

Take a closer look at the Atlantic Ocean floor area:

atlantis

On the left, a grid-like structure is clearly visible. I also spotted a similar “grid” east of the main one (yes, I called it!) and some more off the west coast of Ireland.

However, it may all be a false alarm. Google said that:

 “Bathymetric (or sea floor terrain) data is often collected from boats using sonar to take measurements of the sea floor […] The lines reflect the path of the boat as it gathers the data.”

I’m keeping my fingers crossed though. I’m waiting for Discovery Channel, bounty hunters and reality showmen to swarm the place now as I think this patch of open ocean is international waters. Finders keepers!

Spincloud Labs: Political boundaries overlay in Google maps (Part 1)

Update Sep.21.2011: I took the code in this post and part deux and made a github project off of it called Gborders. The code is simpler and there are more options to generate the borders overlay based on geographic regions. Happy forks!

One thing I needed when designing the Meteoalarm mashup for Spincloud were the political boundaries for all European countries. With them at hand, I would use the polygon overlay from the Coogle API and fill the country polygons with the respective weather warning colors.

This first part is a tutorial on how to import world political borders into a MySQL database table.
The second part in these series will use this table to create a script that will add the country borders overlay to Google Maps.

So after learning that Google Maps API doesn’t give programatic access to the political boundaries I moved on to doing it myself. I read about the encoded polylines and figured that I only missed the country boundaries as encoded polygons so I started searching for readily-available resources. Sure enough there were nowhere to be found.

The next best thing was to find the country boundaries in some GIS format and generate the polyligons myself. The information seems to be sparse but after a bit of research I found was the CIA World Databank but the format is incomplete, it only defines the polygons with no country names or any other administrative hook that I would be able to use. I then spent hours trying to find a better resource until I remembered that Mapping Hacks (an excellent book by the way) has data set for the examples in the book. I had the first breakthrough, the website makes available updated world borders files here, they are mirrored from thematicmapping.org.

We’ll use a utility called shp2mysql to export the boundaries to SQL. I’m on a MacBook and no shp2mysql binaries for my platform were available in the original package so we’ll have to compile it first then run it to be able to export the shapefile to SQL.

Below are detailed all steps needed to to produce the borders SQL file on Leopard 10.5.x (note that you have to have the Developer Tools installed). In short, copy and run the following script on your mac in a file called process_boundaries.sh. The script creates a file called wb_dump.sql which is ready to be imported into database:
Continue reading “Spincloud Labs: Political boundaries overlay in Google maps (Part 1)”

Spincloud, a month old: looking good

I launched Spincloud on New Year’s day. I didn’t expect a flood of traffic to hit the site since -let’s face it- there was nothing groundbreaking. Spincloud was born from my idea of having access to the world weather in one step or less and I’m pleased with the results so far. Spincloud gains adoption every day and this is only due to the people that saw something new and exciting in it. There are blog posts, traffic graphs and other goodies to talk about so let’s begin.

I announced spincloud’s launch on my personal blog then Keir from googlemapsmania broke the news to the community. And so the first spike of traffic was logged on Jan 2nd. 

jan_traffic

Then followed a month of relative silence during which I took a much needed break from the project. I couldn’t help but refactoring and cleaning-up the code a bit. I had two minor releases deployed in prod in the mean time and everything went smooth.

I had a new feature I wanted to have online before the initial release, the meteoalarm mashup that displays weather warnings across Europe but chose not to delay it (a Good Decision in hindsight) . I started working on it by mid January , did a lot of digging for administrative borders data then getting the meteoalarm warning data right (those guys don’t have any integration point). I was done two weeks later.

In the mean time I was trying to raise the awareness about spincloud. I submitted the site so some mapping/mashup themed websites, improved the indexing (still working on it). Then Wednesday last week the European bloggers finally found it. UK’s Mapperz ran a nice little story that seems to have set the things in motion. A number of other bloggers picked-up the story and a surprisingly good feedback came from Italy: Matteo and italiasw.com did a great job while  gisdk.blogspot.com of Denmark  noticed the RSS facilities. Then the referral machine kicked in,  killerstartups.com, programmableweb.com amongst the sites linking. And thus the second spike registered on the traffic meter:
Continue reading “Spincloud, a month old: looking good”

@Meteo_alarm twitter stream now available

ma_logo   =   ma_sc_logo
toplogo
twitter_logo

Update Nov.25.2009: The twitter name has changed to @meteo_alarm. Please update your bookmark or follow list.

Between code refactoring and cooking new ideas, I took some time to add a new feature to Spincloud. Inspired by the crowd-sourced weather updates triggered by really bad snow storms in the UK, I (finally) started to see the advantages to using Twitter. So I took the Meteoalarm data that I mashed-up on Spincloud’s map and streamed it to Twitter.

So here it is: Meteoalarm on Twitter via Spincloud = @Meteoalarm @Meteo_alarm. The stream is updated twice a day and it presents a concise text-only representation of the color encoded weather warnings  in Europe for today and tomorrow.

Spincloud now integrates with Europe’s weather warning service Meteoalarm

Spincloud + Meteoalarm
A short month after the initial public release of Spincloud, I am pleased to announce the addition of a new feature: integration with the European weather warning service Meteoalarm which provides the most relevant information needed to prepare for extreme weather, expected to occur over Europe.  The colors indicate the severity of the danger and its possible impact: Red: very dangerous, Orange: dangerous, Yelllow: potentially dangerous, Green: no warnings.

Currently only the country-level warnings are displayed. You can access the new feature by clicking the “Meteoalarm” button located on the top-left corner of the map. Note that the map has to be positioned over Europe for this buttton to be enabled.
More information about Meteoalarm here.

Important note: When using this new feature, the best experience is with Google’s Chrome, Mozilla or Safari browsers. Enabling the Meteoalarm overlay is much slower on IE browser which sometimes results in the browser reporting a slow-running script on slower hardware. Wait a few more seconds, the new overlay will render eventually.

@BreakingNewsOn map

I’m a bit of a news junkie and when I heard that a twitter stream called @BreakingNewsOn existed I did the natural geekish thing, mash it up. Yahoo pipes was my friend here. I haven’t used the Pipes before but that didn’t quite matter, Yahoo did a great job keeping this playgroundsy product in the child realm so even a caveman could do it. The mashup result -two pipe connections later- is beyond the link:

http://pipes.yahoo.com/newsplore/breakingnewson