Java

Upgrade from Maven 2 to Maven 3 and property substitutions

I just ran across a problem after upgrading from Maven 2 to Maven 3. It seemed as if one of our properties, which we defined like this in the pom.xml of the parent project

1
<foobar.prop>barfoo.value</foobar.prop>

wouldn’t be replaced in the child pom. Our directory lineout was:

Screen Shot 2013-07-16 at 11.44.01

The resulting error message was:

1
'dependencyManagement.dependencies.dependency.groupId' for ${foobar.prop}:foobar:jar with value '${foobar.prop}' does not match a valid id pattern.

The problem lies in the way Maven 3 handles the path to the parent pom. The file child-of-child/pom.xml referenced its parent like this:

<parent>
	<groupId>at.molindo.pom</groupId>
	<artifactId>child-of-parent</artifactId>
	<version>1.0</version>	
</parent>

There’s the new behaviour that Maven 3 brought into place. Maven 2 tried to look for the pom.xml of child-of-parent in the reactor of currently building processes first. Whereas Maven 3 doesn’t look there at all, but relies on an explicit path first, before looking into the local repository.

Therefore the solution was to add the path:

<parent>
	<groupId>at.molindo.pom</groupId>
	<artifactId>child-of-parent</artifactId>
	<version>1.0</version>
	<relativePath>../child-of-parent/pom.xml</relativePath>
</parent>

There you go.


Serving Wicket Resources from CDN

This post is short but still just amazing. Now it’s possible to serve Wicket resources from CDNs supporting custom orgins within just a few minutes (at least if you are already using wicketstuff-merged-resources). First of all, you’ll need the latest version (3.1-alpha-1) of wicketstuff-merged-resources (which is now available from Maven Central!).
Read the rest of this entry »


wicketstuff-merged-resources: 2.1 and 3.0 released!

I’m happy to announce the releases of wicketstuff-merged-resources 2.1 and 3.0.

Read the rest of this entry »


Compass: Role based searching using CompassQueryFilter

While implementing a forum with wicket, spring, hibernate and compass for search, I recently ran into a problem: there are topics and posts that should only visible for some users. Say there’s a moderator forum where all content should only be visible for … well moderators :-).
Read the rest of this entry »


The Final Take On Java System Properties

In this post, I’m looking for active collaboration of my readers (as I really hope that I have some). I’ve thought about a simpler way to handle Java system properties as I tend to forget them all the time. Additionally, I don’t like to see them as string constants – neither within the code nor somewhere else. I’ve come up with a single enum class, that aims to simplify handling of system properties. Actually, you won’t ever think of possible best practices – hence “The Final Take on Java System Properties” 🙂
Read the rest of this entry »


Efficiently Tracking Response Time Percentiles

As we’ve recently started feeling that response times of one of our webapps got worse, we decided to spend some time tweaking the apps’ performance. As a first step, we wanted to get a thorough understanding of current response times. For performance evaluations, using minimum, maximum or average response times is a bad idea: “The ‘average’ is the evil of performance optimization and often as helpful as ‘average patient temperature in the hospital'” (MySQL Performance Blog). Instead, performance tuners should be looking at the percentile: “A percentile is the value of a variable below which a certain percent of observations fall” (Wikipedia). In other words: the 95th percentile is the time in which 95% of requests finished. Therefore, a performance goals related to the percentile could be similar to “The 95th percentile should be lower than 800 ms”. Setting such performance goals is one thing, but efficiently tracking them for a live system is another one. Read the rest of this entry »


Wicket: Annotation-based Mounting of Resources

Today, I’m happy to announce the availability of annotation-based mounting and merging of resources in wicketstuff-merged-resources (version 3.0-SNAPSHOT for Wicket 1.4, version 2.1-SNAPSHOT for Wicket 1.3). In order to mount resources, all that’s needed is adding annotations to component classes:

@JsContribution
@CssContribution(media = "print")
@ResourceContribution(value = "accept.png", path = "/img/accept.png")
public class PanelOne extends Panel {
 
    public PanelOne(String id) {
        super(id);
        // ...
    }
}

Read the rest of this entry »


Using MySQL Collations in Java

I’ve recently discovered Stackoverflow as a nice pass-time on the one hand and as a valuable source for answers on the other hand. Normally it takes only a few minutes to get answers for most questions. However, I managed to ask a question that nobody was able to answer yet. The question was about Collations. As I’m suspecting that Collations are a Java feature that is hardly used, I kept working on the problem myself rather then just waiting for an answer on Stackoverflow.

I’ve managed to get something working right now. It’s not completely tested but it should work quite well. What I’m doing is the following: I parse the charset files of MySQL (on an Ubuntu system, you can find them in /usr/share/mysql/charsets/) and do the collation based on those files myself rather than using Java’s built-in collations.

EDIT: I’ve just created a github project that’s available as a Maven artifact from Sonatype’s OSS repository.


wicketstuff-merged-resources: New (much simpler) Version

It’s been a while since I’ve last posted here. Nevertheless, I’ve been busy working on some (yet to be released) Open Source projects. Others are already released but not documented/promoted yet. One of these unpromoted releases is the new version of wicketstuff-merged-resources.  wicketstuff-merged-resources was the result of my “Wicket Interface Speed-up” series where I investigate how to reduce time spent rendering Wicket pages on the client side. wicketstuff-merged-resources has two main purposes: reducing the number of HTTP requests by merging resources (i.e. JS and CSS files) and enabling aggressive caching (up to a year) by adding a version number to mounted resources (e.g. /css/all-42.css instead of /css/all.css). While wicket has the option to add a timestamp to references (something like /css/all.css?t=20090924), adding the version to the name is preferred over adding a query string. This said, let’s see how to use wicketstuff-merged-resources’ new version. Read the rest of this entry »


Maven/Eclipse: Build path specifies execution environment J2SE-1.5

After running `mvn eclipse:eclipse` this morning, we got a warning from eclipse, telling us that “Build path specifies execution environment J2SE-1.5. There are no JREs in the workspace strictly compatible with this environment.” We didn’t make any changes that could cause this warning, though. We deceided to leave the problem as it was and fix it later – it’s only a warning anyway. However, when trying to start another project, I got another exception I haven’t ever received before. It was caused by mixing up wrong versions of different slf4j JARs.

Read the rest of this entry »