1

After J. Roberson kindly asked me to create a new answer because my code changed but didnt got fixed. First code and problem, I checked all answers at Thread, but they didnt helped me, I stil get an error and cant use

SessionFactory factory = new Configuration();

Problem :

    0 [main] DEBUG org.jboss.logging  - Logging Provider: org.jboss.logging.Log4jLoggerProvider
16 [main] DEBUG org.hibernate.integrator.internal.IntegratorServiceImpl  - Adding Integrator [org.hibernate.cfg.beanvalidation.BeanValidationIntegrator].
21 [main] DEBUG org.hibernate.integrator.internal.IntegratorServiceImpl  - Adding Integrator [org.hibernate.secure.spi.JaccIntegrator].
40 [main] DEBUG org.hibernate.integrator.internal.IntegratorServiceImpl  - Adding Integrator [org.hibernate.cache.internal.CollectionCacheInvalidator].
Exception in thread "main" java.lang.NoSuchFieldError: TRACE
    at org.jboss.logging.Log4jLogger.translate(Log4jLogger.java:60)
    at org.jboss.logging.Log4jLogger.doLog(Log4jLogger.java:40)
    at org.jboss.logging.Logger.trace(Logger.java:107)
    at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.registerStrategyImplementor(StrategySelectorImpl.java:66)
    at org.hibernate.boot.registry.selector.internal.StrategySelectorBuilder.addDialect(StrategySelectorBuilder.java:237)
    at org.hibernate.boot.registry.selector.internal.StrategySelectorBuilder.addDialects(StrategySelectorBuilder.java:188)
    at org.hibernate.boot.registry.selector.internal.StrategySelectorBuilder.buildSelector(StrategySelectorBuilder.java:154)
    at org.hibernate.boot.registry.BootstrapServiceRegistryBuilder.build(BootstrapServiceRegistryBuilder.java:222)
    at org.hibernate.cfg.Configuration.<init>(Configuration.java:118)
    at main.java.Main.main(Main.java:39)
    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:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Community
  • 1
  • 1
Marcus Y
  • 111
  • 2
  • 9
  • Looks like you have a problem with log4j installation.. probably you have more than one version of log4j in your classpath, or you are using an old version which is not compatible with the hibernate version you are using – mendieta Sep 29 '16 at 16:46
  • please share your log4j.properties file and its location. – Rohit Gaikwad Sep 29 '16 at 16:46

2 Answers2

4

You are getting java.lang.NoSuchFieldError: TRACE exception. The TRACE level is available in the log4j jar of version 1.2.12 or higher.

please check which version are you using? Also, check for conflicting version of class org.apache.log4j.Level in your classpath.

remove the log4j-boot.jar from your client's classpath if it exists and include a log4j jar of version 1.2.12 or higher.

Rohit Gaikwad
  • 3,677
  • 3
  • 17
  • 40
  • I used the preinstalled version that comes with Intellij Idea - log4j-1.2.8.jar, i ll try to add a newer version ( tried it before didnt helped but maybe this time) – Marcus Y Sep 29 '16 at 17:05
  • Thank you! You are the best. It fixed for me, tommorow i ll try on my work PC , hope it will fix itself there to, because i tried this already once. (problem was that IDEA was giving me an old version by default) – Marcus Y Sep 29 '16 at 17:12
  • in my case, dependency was in in parent and I hadn't included in child pom. – Smart Coder Dec 14 '20 at 18:33
  • Following also helped. org.apache.logging.log4j log4j-core 2.8.2 – Smart Coder Dec 14 '20 at 20:16
2

You can use log4j.1.2.12 or a higher version to fix this issue. log4j 1.2.17 can be downloaded from here.

g00glen00b
  • 41,995
  • 13
  • 95
  • 133
Brajesh
  • 1,515
  • 13
  • 18