无法使用 Hibernate 5 部署应用程序

Can not deploy application with Hibernate 5

我用过 hibernate 4,一切正常。现在我想在应用程序中将 Hibernate 更新到最新版本。

应用程序构建成功,但部署到 glassfish 服务器失败,堆栈跟踪:

java.lang.NoSuchMethodError: org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V
    at org.hibernate.internal.NamedQueryRepository.checkNamedQueries(NamedQueryRepository.java:149)
    at org.hibernate.internal.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:756)
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:487)
    at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:445)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:779)
    at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:135)
    at org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:199)
    at org.glassfish.persistence.jpa.PersistenceUnitLoader.<init>(PersistenceUnitLoader.java:107)
    at org.glassfish.persistence.jpa.JPADeployer.visitPUD(JPADeployer.java:223)
    at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:510)
    at org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:230)
    at org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:168)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:925)
    at org.glassfish.javaee.full.deployment.EarDeployer.prepareBundle(EarDeployer.java:309)
    at org.glassfish.javaee.full.deployment.EarDeployer.access0(EarDeployer.java:88)
    at org.glassfish.javaee.full.deployment.EarDeployer.doBundle(EarDeployer.java:155)
    at org.glassfish.javaee.full.deployment.EarDeployer.doBundle(EarDeployer.java:152)
    at org.glassfish.javaee.full.deployment.EarDeployer.doOnBundles(EarDeployer.java:232)
    at org.glassfish.javaee.full.deployment.EarDeployer.doOnAllTypedBundles(EarDeployer.java:241)
    at org.glassfish.javaee.full.deployment.EarDeployer.doOnAllBundles(EarDeployer.java:267)
    at org.glassfish.javaee.full.deployment.EarDeployer.prepare(EarDeployer.java:152)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:925)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:434)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.run(CommandRunnerImpl.java:539)
... and more..

我该如何解决这个问题?我没有使用任何 jboss 日志记录。

问题已解决。 Glassfish 在 \glassfish\modules 文件夹中的 jboss-logging jar 已经过时。 用最新版本替换 jar 有帮助。