Another move towards Git

If you’re interested in getting some basic information about Git, surely you already know about the Git Community Book – it’s undoubtedly a source of great knowledge. However, if you prefer the visual presentation and want to listen about the Git, I will highly recommend Scott Chacon’s “Introduction to Git”. It is great, compact and fast-paced talk about the basics of Git. So, either you know nothing about Git or you already know something and just want to summarize your knowledge – I would highly recommend you to spend this 1,5 h on watching this video....

April 24, 2012 · 1 min

Git and empty directories

I’m currently under the process of moving all my workplace repositories from SVN to Git (configured to work with Gerrit). As a side not, I already found it to be a great tool for code review, line-precise commenting of the artifacts and for reviewing new employees code before pushing the changes to the repository. But, back to my point. Recently I’ve stumbled upon a problem with committing an empty directory in Git....

April 21, 2012 · 2 min

GlassFish Java DB not started

I’ve had some problem with starting the GlassFish database. It occurs that in GlassFish 3.1 it started together with the Application Server (when you started the domain), but this doesn’t work for me since 3.1.1. So, if you see something like: Error connecting to server localhost on port 1527 with message Connection refused: connect. you can try to start the GlassFish Java DB by yourself. To do this, just invoke:...

February 28, 2012 · 1 min

Maven Surefire -- Integration tests recognition

By default, Maven’s test plugin Surefire doesn’t scan files for @Test annotations, but rather takes only the files which class names ends with “Test” or “TestCase”. I use both: unit tests and integration tests. I execute the latter using Arquillian framework, so it looks just like pure JUnit test. However, I prefer to name them with the “IT” suffix which means that they’re no longer recognized by Surefire plugin as test files....

February 28, 2012 · 1 min

Override differences in Java 5 and Java 6

Sometimes you might be struggling with such error shown, e.g. in Eclipse: The method … must override a superclass method. If this error is shown in the line when you have your interface method implementation with @Override annotation, it most probably means that you’re using JDK 5 instead of JDK 6. In Java 5, the @Override annotation might be applied only to the methods overriding superclass ones. Since Java 6 you can use the @Override annotation also with the methods that implements the interface ones....

February 28, 2012 · 1 min

Find your class in JAR files

Some time ago I’ve posted about using multiple -exec options for find command which can be used to find in what JARs particular class lies. Below you can find enriched and more intuitive/detailed solution for finding your class in a bunch of JARs: #!/bin/bash if [ $# -lt 1 ] then echo 'Usage: jarfind CLASS_NAME [DIR_WITH_JARS]'; exit 1; fi WHAT="$1" if [ $# -eq 2 ] then WHERE="$2" else WHERE="." fi FIND_RESULT=`find "$WHERE" -maxdepth 2 -name '*....

February 27, 2012 · 2 min

SVN and Time Synchronization Issue on VirtualBox

Some time ago I’ve had a problem with SVN on my VirtualBox guest Ubuntu machine. When the machine was hibernated (it’s state was saved – without shutting it down) there was a time synchronization issue. When I checked out the SVN repository on the guest machine, I couldn’t see any actual changes or new files which I was 100% sure I committed before (because I did it from my host machine just a minute ago)....

February 27, 2012 · 1 min

Adding contextual data to EJB method

Sometimes you need to pass some additional / contextual data to the called EJB method. Because it’s a contextual data you don’t want to end in changing signatures of all your EJB methods just to add a single or few such parameters. It is possible to add context data using the SessionContext object. Take a look at the following code example: package com.piotrnowicki; import javax.annotation.Resource; import javax.ejb.SessionContext; import javax.ejb.Stateless; import javax....

November 23, 2011 · 3 min

Am I in the same transaction? Am I using the same PersistenceContext?

Recently, I’ve bumped into few posts on StackOverflow where people tend to compare container managed EntityManager instances (so the one injected by the container) by invoking EntityManager#toString() method. I’ve felt that it’s fundamentally wrong to compare EntityManager instances without knowing how they’re managed by the JPA provider or the Server Application. And what if this behaviour differs between Application Server vendors? The JPA provider provides an implementation of EntityManager – that’s obvious....

November 23, 2011 · 4 min

Changing git master after cloning

If you’ve cloned a GitHub repository from the original one and not from your forked version and you would like to change it, you can just edit the .git/config file in your project and change the URL of the origin remote: [remote "origin"] fetch = +refs/heads/*:refs/remotes/origin/* url = VALUE_WHICH_SHOULD_BE_ADJUSTED Simple, easy, and most importantly – it works.

September 21, 2011 · 1 min