Invalid parent project in Maven and side effects
Today I was returning to the old project after a long period of inactivity. So I’ve checked out the sources code from Subversion repository, built the project and deployed application to JBoss. And all of the JasperReports were failing. It’s important to mention that we precompile reports and use the compiled ones to generate reports.
The exception sounded like:
java.lang.NullPointerException at net.sf.jasperreports.engine.JRPropertiesMap.readObject(JRPropertiesMap.java:176)
I’ve tried to debug JasperReports but it didn’t make much sense. There were only several web sites in Chinese and Italian which described this problem but none of them provided exact solution.
At the same time we had production version generating the report successfully. So I’ve started comparing both application. It appeared that production application has version 3.5.2 while my just built application has version 2.0.2. So the problem was exactly in the version of the jasperreports library. The reports were compiled with 3.5.2 and application tried to generate it with 2.0.2.
I’ve checked version of libraries in Mavem pom.xml files, but they were correct! They were 3.5.2. So I’ve started investigating how does this old version appear in application. It appears that at some point we had a project which referenced this version 2.0.2 of jasperreports. Then this project has been removed but unfortunately it was referenced as a parent by the rest of the projects and this reference was not removed. So we didn’t have the project itself but it was in maven local cache and it was referenced, so I didn’t have any build errors. Exactly this made Maven bundling old version of the JasperReports library into the application.
This parent project misleading could be easily detected on a clean host without Maven cache, but unfortunately it took several hours to understand why it happens on my development host.