gpt4 book ai didi

hibernate - java.lang.NoSuchMethodError : org. hibernate.internal.CoreMessageLogger.debugf(Ljava/lang/String; I)V

转载 作者:行者123 更新时间:2023-12-04 03:50:15 39 4
gpt4 key购买 nike

我有一个简单的@Singleton whitin Java EE项目,该项目解析来自Internet的数据并将其与Hibernate一起保存到PostgreSQL。

@Startup
@Singleton
public class PSNDBB {

@PostConstruct
public void Parser(){

//getting data

SessionFactory sessionFactory=new Configuration().configure().buildSessionFactory();
Session session=sessionFactory.openSession();
session.beginTransaction();

for(Object obj : array){
GameData game=new GameData();
session.save(game);
}

session.getTransaction().commit();
session.close();
}
}
但是我得到这个
Caused by: java.lang.NoSuchMethodError: org.hibernate.internal.CoreMessageLogger.debugf(Ljava/lang/String;I)V
at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:87)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:217)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.buildJdbcConnectionAccess(JdbcEnvironmentInitiator.java:145)
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:66)
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:234)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:208)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:51)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:217)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.handleTypes(MetadataBuildingProcess.java:352)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:111)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:83)
at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:418)
at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:87)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:692)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724)
at org.showgazer.psn.PSNDBB.Parser(PSNDBB.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.sun.ejb.containers.interceptors.BeanCallbackInterceptor.intercept(InterceptorManager.java:1035)
at com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:72)
at com.sun.ejb.containers.interceptors.CallbackInvocationContext.proceed(CallbackInvocationContext.java:205)
... 70 more
指向
SessionFactory sessionFactory=new Configuration().configure().buildSessionFactory();
但是 hibernate.cfg.xml在Java SE项目中运行良好,并且在Java EE中出现此错误。我使用的所有JAR都在 /WEB-INF/lib中。 hibernate.cfg.xmlsrc文件夹和 /WEB-INF文件夹中。而且我使用的GlassFish没有任何容器和构建工具,我认为这很糟糕,但是我需要知道在这个简单示例中哪里出错了。

最佳答案

我通过从项目的lib文件夹中删除jboss-logging jar文件并从glassfish\modules文件夹中将jboss-logging.jar替换为http://mvnrepository.com/artifact/org.jboss.logging/jboss-logging/3.3.0.Final的最新版本来解决了此问题

关于hibernate - java.lang.NoSuchMethodError : org. hibernate.internal.CoreMessageLogger.debugf(Ljava/lang/String; I)V,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33595237/

39 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com