使用 jboss 7 启动 Hibernate 5

Starting up Hibernate 5 with jboss 7

我在 JBoss 7.1.1-Final 上使用 Hibernate 5.1.0 时遇到问题。 它似乎与日志记录有关 类。 这是我的 build.gradle 文件

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'war'

targetCompatibility = 1.7
sourceCompatibility = 1.7

repositories {
    jcenter()
    flatDir {
       dirs 'src/main/webapp/WEB-INF/lib'
   }
}

dependencies {
    compile 'org.springframework:spring-context:4.2.5.RELEASE'
    compile 'org.springframework:spring-web:4.2.5.RELEASE'
    compile 'org.springframework:spring-webmvc:4.2.5.RELEASE'
    compile 'org.apache.cxf:cxf-rt-frontend-jaxrs:3.1.5'
    compile 'org.apache.cxf:cxf-rt-transports-http:3.1.5'
    compile 'org.apache.cxf:cxf-rt-rs-service-description:3.1.5'
    compile 'commons-httpclient:commons-httpclient:20020423'
    compile 'javax.ws.rs:javax.ws.rs-api:2.0.1'
    compile 'org.codehaus.jackson:jackson-jaxrs:1.9.13'

    compile project (':DaoCEOrder')
    compile 'org.hibernate:hibernate-core:5.1.0.Final'
    compile ':ojdbc6'
    compile 'log4j:log4j:1.2.17'
}

我在 Hibernate 初始化时遇到异常:

11:25:38,191 INFO  [org.hibernate.Version] (http--10.23.47.96-8080-1) HHH000412: Hibernate Core {5.1.0.Final}
11:25:38,198 INFO  [org.hibernate.cfg.Environment] (http--10.23.47.96-8080-1) HHH000021: Bytecode provider name : javassist
11:25:38,506 INFO  [org.hibernate.annotations.common.Version] (http--10.23.47.96-8080-1) HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
11:25:38,585 WARN  [org.hibernate.orm.connections] (http--10.23.47.96-8080-1) HHH10001002: Using Hibernate built-in connection pool (not for production use!)
11:25:38,587 INFO  [org.hibernate.orm.connections] (http--10.23.47.96-8080-1) HHH10001005: using driver [oracle.jdbc.driver.OracleDriver] at URL [jdbc:oracle:thin:@/ENGINE]
11:25:38,588 INFO  [org.hibernate.orm.connections] (http--10.23.47.96-8080-1) HHH10001001: Connection properties: {user=, password=****, autocommit=true}
11:25:38,588 INFO  [org.hibernate.orm.connections] (http--10.23.47.96-8080-1) HHH10001003: Autocommit mode: true
11:25:38,591 ERROR [stderr] (http--10.23.47.96-8080-1) java.lang.NoSuchMethodError: org.hibernate.internal.CoreMessageLogger.debugf(Ljava/lang/String;I)V
11:25:38,592 ERROR [stderr] (http--10.23.47.96-8080-1)  at org.hibernate.engine.jdbc.connections.internal.PooledConnections.<init>(PooledConnections.java:34)
11:25:38,592 ERROR [stderr] (http--10.23.47.96-8080-1)  at org.hibernate.engine.jdbc.connections.internal.PooledConnections.<init>(PooledConnections.java:19)
11:25:38,593 ERROR [stderr] (http--10.23.47.96-8080-1)  at org.hibernate.engine.jdbc.connections.internal.PooledConnections$Builder.build(PooledConnections.java:138)
11:25:38,593 ERROR [stderr] (http--10.23.47.96-8080-1)  at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.buildPool(DriverManagerConnectionProviderImpl.java:110)
11:25:38,594 ERROR [stderr] (http--10.23.47.96-8080-1)  at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:74)
11:25:38,594 ERROR [stderr] (http--10.23.47.96-8080-1)  at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94)
11:25:38,595 ERROR [stderr] (http--10.23.47.96-8080-1)  at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:217)
11:25:38,595 ERROR [stderr] (http--10.23.47.96-8080-1)  at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
11:25:38,596 ERROR [stderr] (http--10.23.47.96-8080-1)  at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.buildJdbcConnectionAccess(JdbcEnvironmentInitiator.java:145)
11:25:38,596 ERROR [stderr] (http--10.23.47.96-8080-1)  at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:66)
11:25:38,597 ERROR [stderr] (http--10.23.47.96-8080-1)  at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35)
11:25:38,597 ERROR [stderr] (http--10.23.47.96-8080-1)  at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88)
11:25:38,598 ERROR [stderr] (http--10.23.47.96-8080-1)  at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:234)
11:25:38,598 ERROR [stderr] (http--10.23.47.96-8080-1)  at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:208)
11:25:38,599 ERROR [stderr] (http--10.23.47.96-8080-1)  at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
11:25:38,599 ERROR [stderr] (http--10.23.47.96-8080-1)  at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:51)
11:25:38,599 ERROR [stderr] (http--10.23.47.96-8080-1)  at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94)
11:25:38,600 ERROR [stderr] (http--10.23.47.96-8080-1)  at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:217)
11:25:38,601 ERROR [stderr] (http--10.23.47.96-8080-1)  at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
11:25:38,601 ERROR [stderr] (http--10.23.47.96-8080-1)  at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.handleTypes(MetadataBuildingProcess.java:352)
11:25:38,601 ERROR [stderr] (http--10.23.47.96-8080-1)  at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:111)
11:25:38,602 ERROR [stderr] (http--10.23.47.96-8080-1)  at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:83)
11:25:38,602 ERROR [stderr] (http--10.23.47.96-8080-1)  at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:418)
11:25:38,603 ERROR [stderr] (http--10.23.47.96-8080-1)  at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:87)
11:25:38,603 ERROR [stderr] (http--10.23.47.96-8080-1)  at org.hibernate.boot.MetadataSources.buildMetadata(MetadataSources.java:179)
11:25:38,604 ERROR [stderr] (http--10.23.47.96-8080-1)  at it.tim.dao.ce.ceorder.H8Utils.getSessionFactory(H8Utils.java:61)

在 Tomcat 7.x 上一切正常。有人知道如何解决这个问题吗?

你的类路径中有一个旧的 hibernate-core-xxx.jar。它可以驻留在 JBoss 个默认库(模块)中。

比如JBoss AS 7.1.2 FinalHibernate Core 4.1.3.Final,对应这个

JBoss Enterprise Application Platform Component Details