Announcement Announcement Module
Collapse
No announcement yet.
Grails and JPA integration Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Grails and JPA integration

    I'm trying to integrate a Java domain and service layer with a Grails app. The Java projects are built with Maven and the Grails project loads the JARs from the Maven repo. The service project contains an XML Spring config file, that defines a bunch of Spring beans. I'm trying to make these available to the Grails app, by loading these beans in grails-app/conf/spring/resources.groovy

    Code:
    beans = {    
        importBeans('classpath:/applicationContext-services.xml')
    }
    One of the beans in this file is an instance of LocalContainerEntityManagerFactoryBean. On attempting to create this bean, I get the error:

    Error creating bean with name 'entityManagerFactory' defined in class path resource [applicationContext-services.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.persistence.spi.PersistenceUnitInfo.getValid ationMode()Ljavax/persistence/ValidationMode;
    Based on this issue in Spring's JIRA, it would appear that the underlyiing problem is some incompatibility between the Spring and Hibernate/JPA versions. It appears that I'm using:
    • Spring 3.0.5.RELEASE
    • Hibernate 3.6.0.Final
    • Hibernate-jpa-2.0-api 1.0.0.Final
    I tried removing the Hibernate plugin from the Grails app, but it didn't seem to make any difference.

  • #2
    This has been answered elsewhere, but in the interests of future readers the problem here is down to the use of Hibernate 3.6 which is not supported in Grails 1.3. Note that Grails 2 uses/will use that version of Hibernate.

    Also, you can use the 'grails dependency-report' command to generate an HTML report that allows you to see what JARs are being included by your application. That can help diagnose issues. You can then put in exclusions for any transitive dependencies that are causing problems.

    Comment

    Working...
    X