Spring Boot Spring Data JPA JBoss EAP 6.4

16: 57: 41,389 ERROR [org.springframework.boot.SpringApplication] (ServerService thread pool - 86) Failed to start application: org.springframework.beans.factory.BeanCreationException: Error creating bean named "entityManagerFactory" defined in path to resource class [org / springframework / boot / autoconfiguration / orp / JPA / HibernateJpaAutoConfiguration.class]: Call init method failed; nested exception java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey () Ljavax / persistence / ForeignKey;

I am deploying a .war file in JBoss EAP 6.4

I am using Spring Boot version '1.2.4.RELEASE'

I tried:

  • Generating jboss-deployment-structure.xml with:

    <jboss-deployment-structure>
        <deployment>
            <exclude-subsystems>
                <subsystem name="jpa" />
            </exclude-subsystems>
            <exclusions>
                <module name="javax.persistence.api" />
                <module name="org.hibernate"/>
            </exclusions>
        </deployment>
    </jboss-deployment-structure>
    
          

  • Note. excluding the module javaee.api

    throws more exceptions

  • Also, changed the standalone.xml file to remove the jpa subsystem:

    <subsystem xmlns="urn:jboss:domain:jpa:1.1">
        <jpa default-datasource="" default-extended-persistence-inheritance="DEEP"/>
    </subsystem> 
    
          

  • Also changed /middleware/jboss64/modules/system/layers/base/javaee/api/main/module.xml

    :

    <module name="javax.persistence.api" export="false"/>
    
          

  • I can see from Spring Boot 1.2.4.RELEASE Documentation -

org.springframework.data spring-data-jpa
1.7.2.RELEASE

  1. I see in spring-data-jpa 1.7.x pom.xml

    :

    <hibernate>3.6.10.Final</hibernate>
    
          

But the war file was generated using gradle 2.4 contains Hibernate-core-4.3.8.jar

and hibernate-jpa-2.1-1.0.0.jar

why?

The only theory I have is that JBoss is injecting its own Jpa jar and NOT hibernate jar which causes the Hibernate API to mismatch and the jpa throws an exception.

  1. I think that overriding the Hibernate version in the Spring boot project will fix this inconsistency, so I changed the build.gradle ...

    configurations.all {
        resolutionStrategy {
            eachDependency {
                if (it.requested.group == 'org.hibernate') {  
                    it.useVersion '4.2.19.Final'
                }
            }
        }
    
          

I got the following error

Could not resolve all dependencies for config ': Callcentre2: compile. Failed to resolve org.hibernate: hibernate-validator :. 4.2.19.Final

(.... some https url here, but I can't write it here cos stackoverflow won't let me save the question)

I am on the right track to downgrade Hibernate, if so how can I fix the build error? What is a repo for Hibernate?

Update:

I fixed this by including ...

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        // Use Hibernate 4.2
        if (details.requested.name == "hibernate-core") {
            details.useTarget "org.hibernate:hibernate-core:4.2.19.Final"
        }
        if (details.requested.name == "hibernate-entitymanager") {
            details.useTarget "org.hibernate:hibernate-entitymanager:4.2.19.Final"
        }
        // Use JPA 2.0
        if (details.requested.name == "hibernate-jpa-2.1-api") {
            details.useTarget "org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final"
        }
    }
}

      

But now I am getting JBoss EAP 6.4:

Caused by: java.lang.LinkageError: Failed to link org / springframework / boot / orm / jpa / hibernate / SpringJtaPlatform (module "deployment.callcentre2.war: main" from service module loader) on org.jboss.modules.ModuleClassLoader.defineClass (ModuleClassLoader.java:487) [JBoss-modules.jar: 1.3.6.Final-RedHat-1] ... 31 more Cause: java.lang.NoClassDefFoundError: org / hibernate / engine / transaction / jta / platform / internal / AbstractJtaPlatform at java.lang.ClassLoader.defineClass1 (native method) [rt.jar: 1.8.0_40] at java.lang.ClassLoader.defineClass (ClassLoader.java:760) [rt.jar: 1.8.0_40] at org. jboss.modules.ModuleClassLoader.doDefineOrLoadClass (ModuleClassLoader.java:361) [JBoss-modules.jar: 1.3.6.Final-RedHat-1] at org.jboss.modules.ModuleClassLoader.defineClass (ModuleClass :Loava.482) [JBoss-modules.jar: 1.3.6.Final-RedHat-1] ... 53 more Caused by: java.lang.ClassNotFoundException: org.hibernate.engine.transaction.jta.platform.internal.AbstractJtaPlatform from [Module "deployment.callcentre2.war: main" from the service module Loader]

+3


source to share





All Articles