Setting up a Git server on Ubuntu, accessing from Mac OS X

This wiki post walks you through the key steps configuring a Git server on Ubuntu.

Edit 4/3/12: there’s a lot of other articles on how to setup gitosis on linux – here’s some I followed, but they all have slight variations in the approach: here, here, and here. It seems somewhat hit and miss whether it works or not (as you’ll find if you google for related articles). For me, I could only get this approach working for the user in the gitosis-admin group, and I could not get access for any other users, despite how many variations of the setup instructions I worked through. There’s numerous comments that gitosis is also no longer supported and to use gitolite instead, so I’m going to try installing gitolite instead and will write another post on using this approach . See here for my notes on setting up gitolite, which by the way I got setup with no issues at all.

The setup steps in the wiki article walk you through setting up a gitosis user through which you connect using an ssh public key – since I was trying to follow the instructions but not really sure what I was doing, the key steps (once you’ve already done the above setup) are:

  • if you already have an ssh public key, copy it to your remote server and then add it for the gitosis user with this step:
sudo -H -u gitosis gitosis-init < your.pub_file

If you don’t have a .pub file in your ~/.ssh dir, create one with the steps here. This step is only done one time, for your admin user to get the gitosis-conf project setup.

To add new projects and users is via the gitosis-admin project which you clone from your new server. Once you’ve pulled the project local, all admin of adding new projects is done via making changes to the gitosis.conf file and then pushing the change back to the server.

To add a new group/team add a new section like this:

[group group_name_here]
members = dev1@host1 dev2@host2 dev3@host3
writable = Project1 Project2

Notice the members and writable list of source project are space separated, not comma.

For each new user, add their .pub ssh file to the gitosis-admin/keydir directory, named user@host.pub, where user@host matches their id and host at the end of the key details in the file.

Add, commit and push them to the server:

git add .
git commit -m "added new key files"
git push

To push a new project for the first time, eg’Project1′

  • cd into the project you’re adding for the first time and add your remote:
git remote add origin gitosis@your_server_name:Project1.git
  • Add, commit and then push your code on the master branch:
git add .
git commit -m "commit message"
git push origin master

Subsequent pushes, you can just do ‘git push’

Mapping JodaTime properties using JPA and custom UserTypes

JPA does not natively support mapping custom types to table columns. If you’re using Hibernate as your JPA provider then it does support custom UserTypes to provide mappings beyond the normal String to varchar, and other simple types.

For using the JodaTime’s DateTime, there’s a couple of options:

  • Joda Time Hibernate is a Hibernate contributed library (http://joda-time.sourceforge.net/contrib/hibernate/index.html)
  • UserType for Hibernate looks like it is an updated version of Joda Time Hibernate,   adds support for JSR310 (the new JDK Date implementation based on JodaTime), while also keeping backwards compatibility with Joda Time Hibernate

I tried UserType for Hibernate first, but got errors on a Roo generated @RooEntity:

@Type(type="org.joda.time.contrib.hibernate.PersistentDateTime")
private DateTime testDate;

I got this trying to persist:

java.lang.AbstractMethodError: org.jadira.usertype.dateandtime.joda.PersistentDateTime.nullSafeSet(Ljava/sql/PreparedStatement;Ljava/lang/Object;I)V
at org.hibernate.type.CustomType.nullSafeSet(CustomType.java:140)

I’m not sure what this is about so switched the type to the Joda Time Hibernate library, and got it to work as expected straight away:

@Type(type="org.joda.time.contrib.hibernate.PersistentDateTime")
private DateTime testDate;

Could Oracle end up losing money on their Java lawsuit against Google?

According to their original claims in 2010/2011, Oracle’s lawsuit against Google for Android violating Java related patents and copyright was worth somewhere between $1.6 billion and $6 billion in damages.

As the courts continued to throw out an increasing number of the claims, the estimated damages has come tumbling down. Right now, Oracle’s estimates are around $32 million. Google’s estimates are around $37 million.

At this rate, I wonder if it’s possible for Oracle to actually lose money on the case due to legal costs? $32 million is hardly big bucks for Google.

If Oracle had any sense, they should have licensed Android from Google as the replacement for Java ME, and not try to remove Android from the picture with legal action. Android is everything that Java ME should have been from the beginning but has always been so far from the mark.

Adding new views to a Spring Roo app using Tiles

Spring Roo by default uses Tiles to construct your views. Without some digging through the generated configuration files, this is not as obvious as you’d think, so by dropping a new jspx file in one of your views subdirs and trying to forward to it from your Controllers will give you an error like this:

Servlet.service() for servlet ContestEntry threw exception:
javax.servlet.ServletException: Could not resolve view with
name 'somedomain/someview' in servlet with name 'WebappName'

Each of your view subdirs beneath /WEB-INF/views/ has it’s own views.xml file that declares it’s Tiles definitions. To add a new view, you need to add both an entry in the corresponding views.xml file and drop a new jspx file in the same views dir