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

I have one simple @Singleton whitin Java EE project that parses data from the Internet and saves it with Hibernate in 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(); } } 

But I get it

 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 

Indication of

 SessionFactory sessionFactory=new Configuration().configure().buildSessionFactory(); 

But hibernate.cfg.xml works well as part of the Java SE project, and in Java EE I get this error. All the JARs that I used are in /WEB-INF/lib . hibernate.cfg.xml is located in the src folder and in the /WEB-INF folder. And I use GlassFish without any containers and building tools that I think are bad, but I need to know where the error was in this simple example.

+7
java-ee hibernate glassfish
source share
3 answers

I solved this problem by deleting the jaross-logging jar file from the lib project folder and replacing jboss-logging.jar from the glassfish \ modules folder with the latest version from http://mvnrepository.com/artifact/org.jboss.logging/jboss-logging /3.3.0.Final

+7
source share

There appears to be a version mismatch between the logging libraries included in the application server and the logging libraries required by Hibernate.

I had the same problem and my configuration was: Jboss AS 7.1.1.Final and Hibernate 5.1.0, and I decided to exclude the jboss registration module in jboss-deployment-structure.xml

  <jboss-deployment-structure> <deployment> <!-- ADDED --> <exclusions> <module name="org.hibernate" /> <!-- Escludo l'Hibernate integrato in jboss e uso quello interno --> <module name="org.jboss.logging" /> <!-- Escludo li logger integrato in jboss --> </exclusions> <!-- FINE ADDED --> <dependencies> </dependencies> </deployment> </jboss-deployment-structure> 
+2
source share

The silver bullet to fix all these problems with the crazy version is to use the Spring IO Platform

http://platform.spring.io/platform/

which does dependency management for everything in Spring via Maven or Gradle.

(After that, you don’t need to tear your hair and worry about problems with the secret version, which a typical developer should monitor and endure every few months when updating or adding projects).

Also note: you also need to make sure that all of your modules (in a multi-module project) have the same version numbers. This sounds obvious, but you can forget about it when adding modules.

+1
source share

All Articles