Pages

Monday, January 18, 2016

Auto-Wiring of Optional Beans with Spring using JSR-330

I've been using Spring for years and particularly like how little intrusive the framework is. For that reason I even still use the XML configuration option in order to have as little dependencies on the Spring framework as possible in my code. I also used to prefer explicit bean wiring over auto-wiring for the same reason, @Autowire is Spring annotation I tried to avoid; and also I have a tendency of being a control freak and didn't want some magic to determine my application setup. Not having a dependency on Spring is particularly important in my current project for various reasons. However, I'm over my control-freak attitude and with the arrival of JSR-330 I can get it all: Auto-wiring as well as JDK-only annotations/classes.

Thursday, September 17, 2015

Maven Shade Plugin with Spring Applications

I recently came across multiple projects that use the Maven Shade Plugin to package Java applications into one big jar. Not that I think this is a particularly good idea, in fact I believe it's a terrible idea that may lead to somewhat unpredictable results. However, you sometimes have to live with what's already in place...

When I started using Spring in my applications another downside of this approach emerged: While all the tests passed just fine the packaged application failed to even start throwing somewhat unexpected exceptions like this:

Saturday, September 27, 2014

Spring Data Neo4j Namespace Configuration Fails on Reload

I started a graph DB project using Neo4j a couple of weeks ago and decided to use Spring Data Neo4j to make my life easier. I got my app up without much hassle using the Spring Data Neo4j namespace configuration to configure my application in XML. This is quickly done with just 2 lines of XML:
<neo4j:config storeDirectory="/var/neo4j" base-package="graph.model" />
<neo4j:repositories base-package="graph.repositories"/>
Everything worked fine until I embedded my project in a larger Spring project which loads around 15 or so top level application context files for all the modules. Suddenly my configuration started throwing exceptions:

Friday, August 8, 2014

Syntax Highlighting for Groovy in Kate

Groovy has been my scripting language of choice for some time now and since I'm running KDE I'm using Kate for quick scripts. And even though Groovy has been around for quite some time and Kate supports a myriad of syntax highlighting modes, Groovy for some odd reason isn't one that comes bundled with Kate out of the box. At least not up to my current KDE version 4.13.2 running on Ubuntu derivatives - neither on (K)Ubuntu nor my latest install of Mint 17 KDE.

Thankfully Kate's syntax highlighting is extendible and the Groovy project provides plugins for various editors including kate. Unfortunately the instructions on  this page have never worked for me on an Ubuntu based system. The path names listed on that plugin page weren't correct with any install of KDE out of the repository.

To make Groovy syntax highlighting work, I instead had to place the groovy.xml file into

~/.kde/share/apps/katepart/syntax/

in order to make it available for a single user or in

/usr/share/kde4/apps/katepart/syntax

to make it available system wide. Restart Kate, here you go. It gets picked up automatically when you save a .groovy file and resides in the Tools -> Highlighting -> Sources menu.

Thursday, November 28, 2013

Making Java Groovy

Manning Publications recently published "Making Java Groovy" by Ken Kouson so I went and bought it. I often buy books about topics I'm interested in and read them on the train to work to find out if the described technologies can help me with my current or future projects. I really like Manning books because they are usually a good mixture between tutorial/reference and just good introduction into technologies.

Working in an almost Java-only environment have been interested in Groovy for quite some time. Most Java developers know the problem: You have all kinds of libraries or at least code snippets that already capture your business logic. But if you want to run a quick script to make use of it, you either have to create a full blown Java app with all it's draw-backs, or go for some other scripting language that can do the trick with as little code as possible; for my quick-and-dirty scripts I usually resorted to one of bash, PHP or Perl. For more complicated tasks I bit the bullet I wrote Java app, bundled into one big jar with a myriad of command line parameters to be able to switch environment, figure out best settings and what not.

Tuesday, August 27, 2013

Loops in Message Routing/Graphs

This topic seems to be so beat down even to me that it was somewhat surprising to actually come across a real life example where a major corporation seemed to have not paid attention to it. Even more surprising if this happens to a company which's whole business is about routing: USPS.

I recently ordered something online that was supposed to be delivered by USPS, which was tasked to just complete "the last mile". Now I made a mistake and had the package shipped to my office but accidentally had typed in the zip code of my home address (which are only about 7 miles apart from each other). Looking at the online tracking app, I could not believe what is happening:

Wednesday, August 7, 2013

Don' forget about IOPS on RDS

A lot of things a slightly different when you run your application on cloud services like AWS. Take database servers: Increased load can always change the performance of DB look-ups and writes. Larger tables can lead to slow queries if the tables are not indexed right, a lot of writes may cause unexpected locking, etc.

However if you use Amazon's AWS there is another important factor you should not loose sight of: IOPS. This measures the number of I/O operations between the database server and its storage, which is attached as network storage.

It's somewhat unclear if/how Amazon throttles the throughput if you don't reserve IOPS. You might be at the mercy of other RDS instances that are running on the machine and probably some kind of rate limit AWS implicitly imposes.