I have a maven project that is split into several modules.
proj-parent
+- proj-campaign
+- proj-core
+- proj-data
+- proj-rawimport
+- proj-ui
+- proj-ui-core
The data module contains most of the JPA entity classes, which has been configured to create metamodel classes using the maven-processor-plugin:
<build>
<plugins>
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>2.2.4</version>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<outputDirectory>src/generated</outputDirectory>
<processors>
<processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
</processors>
<compilerArguments>-ApersistenceXml="src/main/resources/META-INF/persistence-data.xml"</compilerArguments>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>4.3.4.Final</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
This all works fine and the classes are autogenerated, and are populated with actual values at runtime.
However, I also have the rawimport project which contains some jpa entity classes as well. Until now it has not been referenced by any of the other projects but now the ui module requires it. So I wired it in the same way as the data project, expecting it to work fine:
- Added the rawimport project as a managed dependency in the parent (seems ok)
- Added the metamodel generator, as with the data config above but pointing to a different persistence.xml (seems ok and classes generated ok)
- Referenced the rawimport project in the ui project. (this step causes the problem)
But now, when I start the system, the attributes in the data project are no longer populated, causing NullPointerExceptions everywhere.
I've tried clearing my maven repository, command line clean and rebuild, eclipse maven project update.. nothing helps.
I'm trying to trawl the debug-level startup logging but can't find any errors, it just seems to silently not populate them.
Does anyone know what I should be looking for, or typical reasons why the attributes don't get created? Has anyone had similar problems when adding a module to an existing project? I'm hoping I don't have to merge the rawimport and data modules as that is a last resort.
Versions used:
<wicket.version>6.11.0</wicket.version>
<hibernate.version>4.3.8.Final</hibernate.version>
<mysql.version>5.1.34</mysql.version>
<c3p0.version>0.9.5</c3p0.version>
<spring.version>4.1.4.RELEASE</spring.version>
<hsql.version>2.3.2</hsql.version>
<jetty.version>7.6.3.v20120416</jetty.version>
Thanks in advance.
====UPDATE===== Update for those who have had a similar problem: I've gone with mushing the two projects together. The problem was because I had a transaction manager and persistence data in both projects with the same bean names, so one would begin to correctly populate the metamodel and then halfway through be replaced by another one which didn't finish the job.
Due to the complications of keeping 2 entity managers looking at the same data, it was best (for my situation) to combine them together.