Search code examples
javahibernatejbossjboss-eap-6jpa-2.1

Is it possible to configure JBoss EAP 6.4.x for Spring 4 and Hibernate 4.3.10 using JPA 2.1 by configuring it over jboss-deployment-structure.xml?


We recently switched to Java 8 to use java.time API (LocalDate, LocalDateTime,...). Therefore we updated our Hibernate dependency to version 4.3.10. We wrote some AttributeConverters to help Hibernate to map new Java 8 classes to the database.

e.g.

@Converter(autoApply = true)
public class LocalDateConverter implements AttributeConverter<LocalDate, Date> 

To use javax.persistence.Converter and javax.persistence.AttributeConverter we had to update Hibernate to 4.3.10 to work with JPA 2.1. But JBoss EAP 6.4.x does not support JPA 2.1 and comes along with JPA 2.0. Therefore, we get some deployment errors. How can we get our JPA 2.1 application running on JBoss!?

  • Should we downgrade Hibernate to a Hibernate version lower than 4.3.10 to work with JPA 2.0?

  • Or is there a nice way to exclude JPA 2.0 using the jboss-deployment-structure.xml?


Solution

  • You are mixing up Java8/JDK8 with JEE7 specification. JBoss EAP 6.4 is a JEE6 container. JEE6 requires JPA 2.0 which is why you have JPA 2.0 implementation in JBoss EAP 6.4. Once JBoss releases a JEE7 implemented container, you should be able to use JPA 2.1 there.

    It should be fine to use JBoss EAP 6.4 running on JDK8.

    I would not recommend modifying the hibernate jars or manually including JPA 2.1 jars. There are other aspects of JPA for example the secondary cache which is implemented by Infinispan in JBoss might not have been tested with JPA 2.1 cache stores.

    If you really need to utilize a JEE7 JBoss container, then take a look at WilFLy 9. However, this is a community build, so it is not supported.