Running Apache Archiva on a Synology NAS

If you’re developing in Java and also using Maven you should be using a repository manager. You probably have one at work. But do have one for your hobby projects? As you probably know; proxying Maven repositories can be quite beneficial. It speeds up builds, as all dependencies only have to be downloaded from the remote repository once. And you will also have a nice place to store your own artifacts. Not everyone have a stock home server that can run such a repository manager, including myself. However I do have a Synology 1513+ NAS. This post shows how you can run Apache Archiva on this device and it’s sibilings in the 1×13+ series.

There are basically two ways of running Archiva; It can be a standalone application, or it can be a executing in a servlet container such as Apache Tomcat. The latter already comes in a handy package for Synology. In either case Java must be installed.

Using Tomcat

I started out by installing the Apache Tomcat package and continued by installing the Archiva WAR file into Tomcat. When I attempted to start Archiva I was rewarded with a wide range of error messages. A new one every time I tried something. I’m no Tomcat guru so I gave up and decided to run the standalone version of Archiva.


This method requires that a wrapper application is built for the CPU that the the 1513+ has (Intel Atom D2700).  I suspected that one of the ones shipping with Archiva would work, but decided to cross compile the wrapper using spksrc. With a bit of tweaking the standard distribution actually worked. However it would be a lot better if Archiva could be distributed as a Synology DSM Package (*.spk). This way I could just install the file using the DSM package manager and no tweaking would be required.

So I ended up with a bash script that downloads the Archiva distribution from Apache, tweaks it some and packages it for the Synology NAS. The source code is at GitHub and also the package for download, Archiva-x64-2.0.1-47-bin.spk. This can easily be manually installed using the package manager. Feel free to try it out. It works nicely on my host, but there may be some bugs.

After installing Archiva you must tell your local Maven to use the new proxy. Simply add the following section to ~/.m2/settings.xml. Remember to replace with the name or IP-address of your Synology DS.

You should probably set up the firewall so that one cannot access the server from the outside of your LAN. There are a lot of prying bots out there.

Happy coding!

Easily switching between Java versions on OS X

If you’re a Java developer you’re probably familiar with the problems caused by sometimes having to switch between Java versions. At least on OS X there is no straightforward way of doing this. A typical use case for me these days is that Java 7 is used most of the time and once in a while I switch to Java 8 for playing with the new features.

So in order to make this easier I added a few aliases and functions to my .profile. The following allows you to easily switch between Java 6, 7 and 8 simply by issuing j6, j7 or j8 respectively on the command line. You may also use the command jls in order to list all available Java versions. The script is written for OS X, but can possibly be adapted to work on other operating systems.

Running Eclipse Orion on a Raspberry Pi

Last week I joined the company of about a million others and became the proud owner of a Raspberry Pi. I got it just for fun; write some software and maybe make use of the GPIO ports.

I already knew I wanted to do something Eclipse related with this quite capable device, so why not run Eclipse Orion (Tools for the web, on the web) on it? During my research I discovered that someone already did that. Ken Walker of IBM Canada/Orion Project even demonstrated such a set-up as a teaser for a talk at last year´s EclipseCon Europe. Now he used the Node.js port of Orion – I had in mind to use the full package. Note that Ken also has a talk on the subject at this year’s EclipseCon in Boston.

Installing Linux

Support for software floating point is required for Java; so we have to pick a Linux distribution that provides this. The Soft-float Debian “wheezy” is a good choice. Note that I had trouble getting the image downloaded from the torrent to work. The direct download of the zip file was OK. Compare the SHA1 hashes to make sure.

Now we need to write the disk image to the SD card. First you must figure out where the card is mounted. On my MBP this is /dev/disk2. We must first unmount it. Note that these instructions are for OS X, if you’re on Linux there are some differences. If you’re on Windows you’re on your own. Sorry about that.

We can now write the image. Execute the command below and be prepared to wait for quite a while. All depending on the performance of your SD-card.

When done, insert the SD-card, connect the Ethernet cable and USB power. The green LED should start blinking and after a while all LEDs should be on. This means you should be able to log into a shell on the device. First you need to figure out it’s IP-address. You can do this from the terminal if you have a screen and keyboard hooked up. I used the nifty iNet iOS application for that and found

Enter the default password (“raspberry”) and you should be greeted with a welcome message. The shell prompt will also change, indicating that you’re now logged in as pi on raspberrypi. We should start with some initial setting up.

Install mDNS

Now, would it not be nice if we could access the Raspberry Pi without having to remember it’s IP-address (and without having to set up a DNS server)? We can do this by making use of multicast DNS (mDNS).

Now the Raspberry Pi can be accessed using it’s name. Try it:

Upgrade software and kernel

Things move fast in the open source world so the software that comes with the Raspberry Pi is unlikely to be up to date. Hence we should upgrade to the latest version of both the software and the kernel.

Expand root partition

In order to make more room we can make the root partition expand to fill the entire SD-card, start raspi-config. Select expand_rootfs then exit and reboot.

Wait a bit and log in again. The root partition should be much larger than the 1.8GB default.

Configure RAM

If you got your Raspberry Pi recently you probably have one with 512MB RAM, but all of that memory is not necessarily available. Check the memory chip to see which type you have and run free -h to see if the memory is there. My Raspberry Pi is a 512MB variant, but reported only 231MB available. In order to fix this we need to update the firmware. Thankfully we can make use of a nice script to do this.

As we’re going to use the Raspberry Pi without a graphical user interface it may be a good idea to limit the GPU memory to 16MB, this will allow applications to use more. Edit /boot/config.txt and add gpu_mem=16 to the bottom of the file. Now we need to restart again. After the device has booted we should see a lot more memory.

Install Java

At this point we’re ready to start installing the additional stuff. The Oracle download pages have been cleverly designed so that they are pretty impossible to use with a command line client. Hence you’ll have to pick the archive using your favourite web browser and transfer it to your Raspberry using SSH. Download the Java SE Embedded 7 , EABI, VFP, SoftFB ABI, Little Endian version and transfer it.

You should know how to log into the Raspberry Pi by now. Do that again (unless you’ve cleverly kept the terminal window open) and execute the following:

The last command should reveal something like this:


Installing Eclipse Orion

Eclipse Orion can be found at the projects website. I picked the 1.0 release for 32-bit Linux and downloaded it to my workstation. Use scp again to copy it to your home folder on the Raspberry Pi.

Eclipse Orion can launch stand-alone websites, which is quite useful for testing your work. However we need to use virtiual host names for these sites. This is done by setting the property in the server configuration file. Create a file named orion.confand add the following:

All sites will now be created on the form .raspberrypi.local. We’re going to start the “Hello World” example project so we’ll need a CNAME alias for this:

Now we’re ready to start Eclipse Orion

It will take some time to start. When everything looks good, open your web browser and enter the address to the running Eclipse Orion instance. It’s running on port 8080 (http://raspberrypi.local:8080/). You should be greeted by a welcome page. Create an account and log in.

Click Sample HTML5 Site and leave the defaults as they are. Simply click Submit in the dialog that pops up. Now go to Sites and create a new site. Name this one “hello” and add the “Hello World” project to it. You can now start the site and view the example project using http://hello.raspberrypi.local:8080/index.html.

That was fun! Now it’s time to read getting started with Orion

Visual Studio vs Eclipse

I‘ve been fighting an uphill battle against C# and Visual Studio (VS) the last few weeks. Loosing some and winning some. Coming from the Java and Eclipse (boot)camp it’s easy to think that every piece of work is a dance on roses.

For some of you this is going to sound like a lot of whining. If so, maybe take a look at Eclipse? If you’re not familiar with Visual Studio, consider this a warning. And if you work for Microsoft; maybe it’s time to do that overhaul?

  • Mylyn (Tasktop in my case) makes it easy to keep track of tasks/bugs and keeps me focused on the work ahead. VS has nothing like this.
  • Strong refactoring tools help me out whenever something has gone bad or just needs to change. Admittedly the VS refactoring tools are pretty much okay, but they are not so easily accessed.
  • My next edit location is just a Ctrl+Click away and various views allow me to see the code from several different angles. VS forces me to right click for a “Go to definition” command and there is very little else to show me how the type/method is in relation to others.
  • Another huge annoyance in Visual Studio is it’s inability to build in the background. I really prefer continue working while waiting for the launch to finish.
  • Not to mention the neatly integrated JavaDoc which is of great help when API documentation is needed. You get the picture.


And there is the small things:

  • In JDT I can just type the class name or what I think it’s called and activate content assist. It will bring up all alternatives along with the documentation. Nice when I’m not quite sure where I’m going.
  • Visual Studio does not show any links from stack trace to code.
  • The equivalent of NullPointerExceptions often end up in the core somewhere, making what should be a trivial bug to fix a PITA.
  • The JDT package explorer is in sync with the editor allowing me to see the terrain. The VS equivalent is not only confusing because it’s object oriented, it’s also not synchronized.
  • In Eclipse there is keystrokes for just about any command imaginable. I cannot remember half of them. But those I can remember I use a lot.
  • There is no outline view in Visual Studio. The combo box at the top of the editor pane is a lousy substitute.
  • There is no Alt+Left/Right for navigating between edit locations. And how can I set boomarks in the code?

There is a lot more I did not mention. Some of my trouble is probably due to a lack of experience with the language and the tool. But I can’t help feel that C#/Visual Studio is inferior to Java/Eclipse. This is suprising considering that both the language and the IDE appears to be important to Microsoft.

Anyway, the battle is not lost yet. I’m going to call in reinforcements. An “add-on” to Visual Studio named ReSharper.