I have one simple @Singleton
whitin Java EE project that parses data from internet and saves it with Hibernate to 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'm getting this
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
Pointing to
SessionFactory sessionFactory=new Configuration().configure().buildSessionFactory();
But hibernate.cfg.xml
works well within Java SE project, and within Java EE I'm getting this error. All JARs that I used are in /WEB-INF/lib
. hibernate.cfg.xml
is in src
folder and in /WEB-INF
folder. And I'm using GlassFish without any containers and building tools, which I think is bad, but I need to know where mistake was made in this simple example.
I solved this problem by deleting jboss-logging jar file from project's lib folder and replacing jboss-logging.jar from glassfish\modules folder to last version from http://mvnrepository.com/artifact/org.jboss.logging/jboss-logging/3.3.0.Final
It seems like there's a version mismatch between the logging libs included in the application server and the logging libs 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 solved excluding the jboss logging module in the 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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With