Sunday, April 19, 2015

Spring Data JPA Setup

I'm having one of those "build your own lightsaber" moments.

At work, we are using Spring Data JPA and Hibernate.

Everything is nice and configured already, the Repositories, the TransactionManager, the EntityManagerRef.

With everything configured, it's pretty easy to just create a new Repository, write a couple of query methods following the nice findByFirstNameAndLastName  DSL provided by Spring Data, and inject the Repository into a Spring Service Bean.

The hard part is the configuration.  I'm trying to do that from scratch on a little personal project this weekend, to make sure I can do it.

Issue #1: java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration

Was getting this as a Runtime error immediately when deploying in JBoss Wildfly 8.2.0.Final.

In my Maven POM:


        
        
        
          org.hibernate
          hibernate-core
          4.3.7.Final
          provided
        


According to wildfly.org 8.2.0 Release Notes:

  • Hibernate 4.3.7.Final
Is supposed to be included as a component.

I could get around it by changing dependency scope from provided to compile and the error goes away, but that feels wrong.

I really don't want to package Hibernate into my WAR file when the Application Server I've selected (JBoss Wildfly 8.2.0.Final) provides it.  

No comments:

Post a Comment