正式项目中,web项目中的slf4j* jar包 删除 -- 项目错误记录

来源:互联网 发布:大非农数据是什么意思 编辑:程序博客网 时间:2024/05/18 00:46

否则会与tomcat的lib包里面的slf4j相冲突

参考 http://stackoverflow.com/questions/29504180/slf4j-error-class-loader-have-different-class-objects-for-the-type


PS:linux系统中,实时查看tomcat启动日志

1、先切换到:cd tomcat/logs

2、tail -f catalina.out

3、这样运行时就可以实时查看运行日志了

Ctrl+c 是退出tail命令。


——————————————————————————————————————————————————

The Tomcat log shows you have another slf4j-1.7.7.jar on the classpath:

Using CLASSPATH: /usr/local/Cellar/tomcat/8.0.18/libexec/bin/jul-to-slf4j-1.7.7.jar:/usr/local/Cellar/tomcat/8.0.18/libexec/bin/slf4j-api-1.7.7.jar:/usr/local/Cellar/tomcat/8.0.18/libexec/bin/logback-classic-1.1.2.jar:/usr/local/Cellar/tomcat/8.0.18/libexec/bin/logback-core-1.1.2.jar:/usr/local/Cellar/tomcat/8.0.18/libexec/bin/logback-config/:/usr/local/Cellar/tomcat/8.0.18/libexec/bin/bootstrap.jar:/usr/local/Cellar/tomcat/8.0.18/libexec/bin/tomcat-juli.jar

When Tomcat is been initialized, it initialize jul-to-slf4j and slf4j-api. These jars are been loading by the Classloader which loaded the Tomcat jars (sun/misc/Launcher$AppClassLoader).

When your application tries to access the slf4j-api classes, it uses the WebApplication Classloader (org/apache/catalina/loader/WebappClassLoader), which by default search for classes definition on the app classpath before the system classpath. Note this can be changed: https://tomcat.apache.org/tomcat-8.0-doc/class-loader-howto.html

In Java, the class signature is composed of the class full qualified name and the classloader that loaded the class. If a class is loaded two times from two different classloaders (same hierarchy), there will be two different classes for the JVM. Trying to point a object reference of one class to a variable of the other will trhow a ClassCastException. Check this blog post (item 5) for more info on this:https://techblug.wordpress.com/2012/03/17/classloader-tips/

So, as far as I know, you can fix this by removing the slf4j-*.jar from the Tomcat classpath,or if you have more then one webapp using the same version of slf4j, you can remove the jars from the webapp, so it will use those loaded by Tomcat classloader.



------------------------------------

angularjs中,添加的片段必须完整的包含在一个封闭的元素内,例如 <div></div>  或 <span></span>之内。开放式的多个元素是无法动态添加的。

tomcat超级大坑

将ROOT内文件都删除,将项目部署进ROOT之后,examples  docs manager  host-manager 这几个二级目录均不能用,否则会和tomcat固有的二级目录冲突!!! 即不能有 http://www.xxx.com/examples/..........等等形式









0 0