Maven

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.


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 »


Spotting duplicate classes in Jar files

After more than a month it’s time for another post. Sorry to all of you for keeping you waiting … well, honestly I don’t think somebody even noticed 🙂

Today, I stumbled upon a classpath related problem – once again. As I doubt that I am the only one to ever face this problem, I want to share a short shell script that came to the rescue.

But first, what was the problem? After adding some additional dependencies to our POM – quite carelessly I have to admit – our application started sending mails without subject, sender address and messed up special characters. Interestingly enough, I didn’t touch the mail part at all. I added Apache CXF dependencies, i.e. web service stuff. So what was wrong?
Read the rest of this entry »