Creating a DDL in the Maven build with the hibernate3-maven-plugin fails if you explicitly configure an array of javax.persistence.CascadeType values in your JPA annotations. The stacktrace is similar to
1 2 3 4 5 6 7 | javax.persistence.PersistenceException: [PersistenceUnit: spontacts] Unable to configure EntityManagerFactory at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:265) at org.codehaus.mojo.hibernate3.configuration.JPAComponentConfiguration.createConfiguration(JPAComponentConfiguration.java:28) ... Caused by: java.lang.ArrayStoreException: sun.reflect.annotation.EnumConstantNotPresentExceptionProxy at sun.reflect.annotation.AnnotationParser.parseEnumArray(AnnotationParser.java:673) at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:462) |
Once I realized what the actual cause is, the fix was simple. Turns out that the CascadeType is not in the classpath when Maven runs the hbm2ddl goal. Hence you need to add a dependency to JPA to the hibernate3-maven-plugin:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>hibernate3-maven-plugin</artifactId> <dependencies> <dependency> <groupId>org.hibernate.javax.persistence</groupId> <artifactId>hibernate-jpa-2.0-api</artifactId> <version>1.0.0.Final</version> </dependency> </dependencies> <executions> ... </executions> <configuration> ... </configuration> </plugin> |
A solution to this exception in a different context was posted here: http://javahowto.blogspot.com/2008/10/solve-javalangarraystoreexception.html
Thnx a lot
Thank you this solved my problems. Good suggestion!!