Caused by: java.lang.NoSuchMethodError: org.apache.log4j.Category.log
出现的异常:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:287)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:425)
Caused by: java.lang.NoSuchMethodError: org.apache.log4j.Category.log(Ljava/lang/String;Lorg/apache/log4j/Level;Ljava/lang/Object;Ljava/lang/Throwable;)V
at org.apache.commons.logging.impl.Log4JCategoryLog.debug(Log4JCategoryLog.java:94)
at org.apache.catalina.startup.TldConfig.execute(TldConfig.java:314)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4282)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1083)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:789)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1083)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:478)
at org.apache.catalina.core.StandardService.start(StandardService.java:480)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:2313)
at org.apache.catalina.startup.Catalina.start(Catalina.java:556)
... 6 more
原因:commons-logger.jar和你的log4j.jar版本不兼容。前者是对后者的一个封装,而hibernate中主要是使用前者。前者的功能就是:它封装了一些通常的日志类,比如log4j,java.util.logging.Logger 等,使用的log4j,但是由于版本不对,commons-logger中用了log4j中的那个类,在当前的log4j版本中已经不存在了,所以报错
解决方法:
将class目录下commons-logging.properties
org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JCategoryLog
更改为
org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger
相关文章
- 01-28Caused by: java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.
(I)V - 01-28Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getClassLoader()Ljava/lang/ClassLoader;
- 01-28Caused by: java.lang.NoSuchMethodError:javax.servlet.http.HttpServletRequest.getServletContext()L
- 01-28Caused by: Java.lang.NoSuchMethodError: org.springframework.http.HttpMethod.matches(Ljava/lang/Strin
- 01-28异常:Caused by: java.lang.NoSuchMethodError: javax.persistence.OneToMany.orphanRemoval()Z
- 01-28Caused by: java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/
- 01-28异常:Caused by: java.lang.NoSuchMethodError: javax.persistence.OneToMany.orphanRemoval()Z/Caused by: java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreign
- 01-28Caused by: java.lang.NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index
- 01-28Caused by: Java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey;
- 01-28Caused by: java.lang.NoSuchMethodError: org.springframework.util.Assert.isTrue(ZLjava/util/function/Supplier;)V