maven项目在tomcat中运行 主要会有两种错误:
一是依赖包冲突
二是slf4j包错误
如下:
- 信息: Deploying web application archive D:\tomcat7\webapps\ipFilterM-0.0.1-SNAPSHOT.war
- 2014-11-18 17:17:01 org.apache.catalina.loader.WebappClassLoader validateJarFile
- 信息: validateJarFile(D:\tomcat7\webapps\ipFilterM-0.0.1-SNAPSHOT\WEB-INF\lib\javax.servlet-3.0.1.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
- 2014-11-18 17:17:01 org.apache.catalina.loader.WebappClassLoader validateJarFile
- 信息: validateJarFile(D:\tomcat7\webapps\ipFilterM-0.0.1-SNAPSHOT\WEB-INF\lib\javax.servlet.jsp-3.0.1.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/el/Expression.class
- 2014-11-18 17:17:01 org.apache.catalina.loader.WebappClassLoader validateJarFile
- 信息: validateJarFile(D:\tomcat7\webapps\ipFilterM-0.0.1-SNAPSHOT\WEB-INF\lib\jsp-api-2.1.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/el/Expression.class
- 2014-11-18 17:17:01 org.apache.catalina.loader.WebappClassLoader validateJarFile
- 信息: validateJarFile(D:\tomcat7\webapps\ipFilterM-0.0.1-SNAPSHOT\WEB-INF\lib\servlet-api-2.3.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
- 2014-11-18 17:17:01 org.apache.catalina.loader.WebappClassLoader validateJarFile
- 信息: validateJarFile(D:\tomcat7\webapps\ipFilterM-0.0.1-SNAPSHOT\WEB-INF\lib\servlet-api-2.5.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
- 2014-11-18 17:17:01 org.apache.catalina.loader.WebappClassLoader validateJarFile
- 信息: validateJarFile(D:\tomcat7\webapps\ipFilterM-0.0.1-SNAPSHOT\WEB-INF\lib\tomcat-servlet-api-8.0.15.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
- 严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
- java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
- at org.apache.commons.logging.impl.SLF4JLocationAwareLog.info(SLF4JLocationAwareLog.java:159)
- at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:272)
- at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
- at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
- at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
- at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
- at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
- at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
- at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
- at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:976)
- at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1653)
- at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
- at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
- at java.util.concurrent.FutureTask.run(FutureTask.java:138)
- at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
- at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
- at java.lang.Thread.run(Thread.java:619)
我们来分析原因和尝试解决:
依赖包冲突
原因
在Maven1中,需要把依赖所需要的包每个列出。这对于使用类似如hibernate的用户来说所操的心太多了,而且也不方便。在Maven2及以上版本中实现了传递依赖,如此对于Hibernate所依赖的包,Maven2会自动下载,开发人员只需关心Hibernate即可。所以可以看出列出所需要的每个jar是在maven1中的功能,Maven2以上版本认为自动下载是一种改进。
这样就产生了一个问题:Maven2以上版本虽然把编译时需要的jar都下载了,但并不是所有编译需要的jar在打成war包后运行时也需要。所以也就发现有许多的jar是不需要的,以至war包比较大。还会产生冲突。
类包冲突的一个很大的原因即产类包之间的间接依赖引起的。每个显式声明的类包都会依赖于一些其它的隐式类包,这些隐式的类包会被maven间接引入进来,因而可能造成一个我们不想要的类包的载入,严重的甚至会引起类包之间的冲突。
例如:
servlet-api.jar
- 信息: validateJarFile(D:\tomcat7\webapps\ipFilterM-0.0.1-SNAPSHOT\WEB-INF\lib\servlet-api-2.3.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
造成这种情况的原因很可能是以下两种情况:
一、项目的WEB-INF/lib下有servlet-api.jar,与Tomcat自带的servlet-api.jar冲突了。
二、项目的WEB-INF/lib下有包含javax.servlet包的其他JAR包(如WebLogic 8.1的weblogic.jar),造成与Tomcat自带的servlet-api.jar的冲突。
因为Tomcat的WebappClassLoader加载JAR包时会进行校验,一旦发现上述冲突就会报出上面的异常。
解决方法
直接引用的包
要加上<scope>provided</scope>标签maven的dependency中有一个tag是<scope>option</scope>,其option有以下几个值:
compile, 缺省值,适用于所有阶段,会随着项目一起发布。
provided,类似compile,期望JDK、容器或使用者会提供这个依赖。如servlet-api-2.3.jar。
runtime, 在运行时使用,如JDBC驱动,适用运行和测试阶段。 如plexus-utils-1.1.jar
test 只在测试时使用,用于编译和运行测试代码。不会随项目发布。如Junit-3.8.1.jar
system, 类似provided,需要显式提供包含依赖的jar,Maven不会在Repository中查找它。
例如:
- javax.servlet-3.0.1.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
- <dependency>
- <groupId>org.glassfish</groupId>
- <artifactId>javax.servlet</artifactId>
- <version>3.0.1</version>
- </dependency>
在pom.xml中是直接引用的,则改为:
- <dependency>
- <groupId>org.glassfish</groupId>
- <artifactId>javax.servlet</artifactId>
- <version>3.0.1</version>
- <scope>provided</scope>
- </dependency>
间接引用包
间接冲突解决方法一新建一个provided冲突包
新建一个冲突包,加上<scope>provided</scope>标签例如:servlet-api-2.3.jar在pom.xml中没有它的信息,是其它包间接引用了它则我们新建如下:- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.3</version>
- <scope>provided</scope>
- </dependency>
间接冲突解决方法二把冲突包依赖排除在外
这种情况下同一类型的包只保留一个*的,其他有冲突的低级包全部要排除在外例子如下:项目里要用到commons-logging。它有几个依赖,其中有一个是servlet-api-2.3.jar。现在我需要用到容器内的servlet-api的异步功能,编译的时候却总是自动引用默认的2.3版本。请问哪位有经验处理这样的冲突,可以屏蔽掉servlet-api-2.3.jar这个依赖包。
如果你的工程是用maven管理的话,可以在commons-logging的依赖里把servlet-api-2.3去除掉,再加入你所需要的版本的servlet-api依赖。大概的例子如下:
- <!--如果你的工程是用maven管理的话,可以在commons-logging的依赖里把servlet-api-2.3去除掉,再加入你所需要的版本的servlet-api依赖。大概的例子如下: -->
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>1.1.1</version>
- <exclusions>
- <exclusion>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>servlet-api-2.5</artifactId>
- <version>6.1.14</version>
- <scope>provided</scope>
- </dependency>
- <!-- 指定scope为provided可以避免在发布的时候把servlet-api包拷到lib目录下。 -->
新增一个 冲突包的provided的dependency 针对每一个冲突包,要在它上级的包里都加上exclusions把冲突包排除在外
新增和排除 都能在myeclipse中可视化操作如图:
找间接依赖的包的两个方法
在myeclipse的视图中查找
依赖树
在cmd命令行中进入该项目的pom.xml所在位置:输入命令:- mvn dependency:tree
稍等一会我们就可以看到扫描出的依赖树了,在里面我们可以看到包的依赖关系
我扫描出的依赖树如下:
- .0.8/maven-model-2.0.8.pom
- Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-model/2.
- 0.8/maven-model-2.0.8.pom (4 KB at 2.8 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-project
- /2.0.8/maven-project-2.0.8.pom
- Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-project/
- 2.0.8/maven-project-2.0.8.pom (3 KB at 4.8 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-setting
- s/2.0.8/maven-settings-2.0.8.pom
- Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-settings
- /2.0.8/maven-settings-2.0.8.pom (3 KB at 3.7 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-profile
- /2.0.8/maven-profile-2.0.8.pom
- Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-profile/
- 2.0.8/maven-profile-2.0.8.pom (2 KB at 4.5 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-artifac
- t-manager/2.0.8/maven-artifact-manager-2.0.8.pom
- Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-artifact
- -manager/2.0.8/maven-artifact-manager-2.0.8.pom (3 KB at 6.4 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-reposit
- ory-metadata/2.0.8/maven-repository-metadata-2.0.8.pom
- Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-reposito
- ry-metadata/2.0.8/maven-repository-metadata-2.0.8.pom (2 KB at 4.5 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-
- registry/2.0.8/maven-plugin-registry-2.0.8.pom
- Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-r
- egistry/2.0.8/maven-plugin-registry-2.0.8.pom (2 KB at 4.5 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-
- api/2.0.8/maven-plugin-api-2.0.8.pom
- Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-a
- pi/2.0.8/maven-plugin-api-2.0.8.pom (2 KB at 3.3 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-uti
- ls/2.1/plexus-utils-2.1.pom
- Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-util
- s/2.1/plexus-utils-2.1.pom (4 KB at 1.8 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-
- invoker/2.0.11/maven-invoker-2.0.11.pom
- Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-i
- nvoker/2.0.11/maven-invoker-2.0.11.pom (5 KB at 2.7 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/reporting/mav
- en-reporting-api/3.0/maven-reporting-api-3.0.jar
- Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/reporting/mav
- en-reporting-impl/2.0.5/maven-reporting-impl-2.0.5.jar
- Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/doxia/doxia-c
- ore/1.0/doxia-core-1.0.jar
- Downloading: https://repo.maven.apache.org/maven2/commons-validator/commons-vali
- dator/1.2.0/commons-validator-1.2.0.jar
- Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-
- doxia-tools/1.0.2/maven-doxia-tools-1.0.2.jar
- Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/reporting/mave
- n-reporting-api/3.0/maven-reporting-api-3.0.jar (11 KB at 5.4 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/commons-beanutils/commons-bean
- utils/1.7.0/commons-beanutils-1.7.0.jar
- Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/reporting/mave
- n-reporting-impl/2.0.5/maven-reporting-impl-2.0.5.jar (21 KB at 3.6 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/commons-digester/commons-diges
- ter/1.6/commons-digester-1.6.jar
- Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-d
- oxia-tools/1.0.2/maven-doxia-tools-1.0.2.jar (41 KB at 6.7 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/commons-logging/commons-loggin
- g/1.0.4/commons-logging-1.0.4.jar
- Downloaded: https://repo.maven.apache.org/maven2/commons-logging/commons-logging
- /1.0.4/commons-logging-1.0.4.jar (38 KB at 2.6 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/oro/oro/2.0.8/oro-2.0.8.jar
- Downloaded: https://repo.maven.apache.org/maven2/oro/oro/2.0.8/oro-2.0.8.jar (64
- KB at 6.2 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/doxia/doxia-s
- ink-api/1.0/doxia-sink-api-1.0.jar
- Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/doxia/doxia-si
- nk-api/1.0/doxia-sink-api-1.0.jar (10 KB at 16.6 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/doxia/doxia-s
- ite-renderer/1.0/doxia-site-renderer-1.0.jar
- Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/doxia/doxia-si
- te-renderer/1.0/doxia-site-renderer-1.0.jar (46 KB at 38.3 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-i18
- n/1.0-beta-7/plexus-i18n-1.0-beta-7.jar
- Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-i18n
- /1.0-beta-7/plexus-i18n-1.0-beta-7.jar (11 KB at 17.2 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-vel
- ocity/1.1.7/plexus-velocity-1.1.7.jar
- Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-velo
- city/1.1.7/plexus-velocity-1.1.7.jar (8 KB at 12.6 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/org/apache/velocity/velocity/1
- .5/velocity-1.5.jar
- Downloaded: https://repo.maven.apache.org/maven2/commons-beanutils/commons-beanu
- tils/1.7.0/commons-beanutils-1.7.0.jar (185 KB at 5.0 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/doxia/doxia-d
- ecoration-model/1.0/doxia-decoration-model-1.0.jar
- Downloaded: https://repo.maven.apache.org/maven2/org/apache/velocity/velocity/1.
- 5/velocity-1.5.jar (383 KB at 58.3 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/doxia/doxia-m
- odule-apt/1.0/doxia-module-apt-1.0.jar
- Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/doxia/doxia-de
- coration-model/1.0/doxia-decoration-model-1.0.jar (48 KB at 30.4 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/doxia/doxia-m
- odule-fml/1.0/doxia-module-fml-1.0.jar
- Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/doxia/doxia-mo
- dule-apt/1.0/doxia-module-apt-1.0.jar (46 KB at 48.0 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/doxia/doxia-m
- odule-xdoc/1.0/doxia-module-xdoc-1.0.jar
- Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/doxia/doxia-mo
- dule-fml/1.0/doxia-module-fml-1.0.jar (19 KB at 20.0 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/doxia/doxia-m
- odule-xhtml/1.0/doxia-module-xhtml-1.0.jar
- Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/doxia/doxia-mo
- dule-xdoc/1.0/doxia-module-xdoc-1.0.jar (28 KB at 29.8 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-arc
- hiver/2.3/plexus-archiver-2.3.jar
- Downloaded: https://repo.maven.apache.org/maven2/commons-validator/commons-valid
- ator/1.2.0/commons-validator-1.2.0.jar (89 KB at 2.1 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-uti
- ls/3.0.9/plexus-utils-3.0.9.jar
- Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/doxia/doxia-mo
- dule-xhtml/1.0/doxia-module-xhtml-1.0.jar (22 KB at 22.6 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/shared/file-m
- anagement/1.2.1/file-management-1.2.1.jar
- Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/doxia/doxia-co
- re/1.0/doxia-core-1.0.jar (54 KB at 1.2 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-
- shared-io/1.1/maven-shared-io-1.1.jar
- Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-arch
- iver/2.3/plexus-archiver-2.3.jar (183 KB at 55.6 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-io/
- 2.0.6/plexus-io-2.0.6.jar
- Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/shared/file-ma
- nagement/1.2.1/file-management-1.2.1.jar (37 KB at 12.9 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-
- dependency-analyzer/1.4/maven-dependency-analyzer-1.4.jar
- Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-s
- hared-io/1.1/maven-shared-io-1.1.jar (39 KB at 14.7 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/asm/asm/3.3.1/asm-3.3.1.jar
- Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-d
- ependency-analyzer/1.4/maven-dependency-analyzer-1.4.jar (27 KB at 20.3 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-
- dependency-tree/2.1/maven-dependency-tree-2.1.jar
- Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-io/2
- .0.6/plexus-io-2.0.6.jar (57 KB at 29.4 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/org/eclipse/aether/aether-util
- /0.9.0.M2/aether-util-0.9.0.M2.jar
- Downloaded: https://repo.maven.apache.org/maven2/asm/asm/3.3.1/asm-3.3.1.jar (43
- KB at 22.0 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-
- common-artifact-filters/1.4/maven-common-artifact-filters-1.4.jar
- Downloaded: https://repo.maven.apache.org/maven2/commons-digester/commons-digest
- er/1.6/commons-digester-1.6.jar (165 KB at 3.8 KB/sec)
- Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-
- invoker/2.0.11/maven-invoker-2.0.11.jar
- Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-c
- ommon-artifact-filters/1.4/maven-common-artifact-filters-1.4.jar (31 KB at 26.1
- KB/sec)
- Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-d
- ependency-tree/2.1/maven-dependency-tree-2.1.jar (59 KB at 20.3 KB/sec)
- Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-i
- nvoker/2.0.11/maven-invoker-2.0.11.jar (29 KB at 18.5 KB/sec)
- Downloaded: https://repo.maven.apache.org/maven2/org/eclipse/aether/aether-util/
- 0.9.0.M2/aether-util-0.9.0.M2.jar (131 KB at 19.3 KB/sec)
- Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-util
- s/3.0.9/plexus-utils-3.0.9.jar (227 KB at 11.2 KB/sec)
- [INFO] ipFilterM:ipFilterM:war:0.0.1-SNAPSHOT
- [INFO] +- org.mortbay.jetty:servlet-api-2.5:jar:6.1.14:provided
- [INFO] +- javax.activation:activation:jar:1.1:compile
- [INFO] +- org.apache.james:apache-mime4j-core:jar:0.7.2:compile
- [INFO] +- org.apache.ws.commons.axiom:axiom-api:jar:1.2.13:compile
- [INFO] | +- org.apache.geronimo.specs:geronimo-activation_1.1_spec:jar:1.1:comp
- ile
- [INFO] | +- org.apache.geronimo.specs:geronimo-javamail_1.4_spec:jar:1.7.1:comp
- ile
- [INFO] | +- jaxen:jaxen:jar:1.1.3:compile
- [INFO] | \- org.apache.geronimo.specs:geronimo-stax-api_1.0_spec:jar:1.0.1:comp
- ile
- [INFO] +- org.apache.ws.commons.axiom:axiom-impl:jar:1.2.13:compile
- [INFO] | \- org.codehaus.woodstox:wstx-asl:jar:3.2.9:compile
- [INFO] +- org.apache.ws.commons.axiom:axiom-dom:jar:1.2.13:compile
- [INFO] +- org.apache.axis2:axis2-adb:jar:1.6.2:compile
- [INFO] +- org.apache.axis2:axis2-adb-codegen:jar:1.6.2:compile
- [INFO] | \- commons-cli:commons-cli:jar:1.2:compile
- [INFO] +- ant:ant:jar:1.6.2:compile
- [INFO] +- org.apache.axis2:axis2-codegen:jar:1.6.2:compile
- [INFO] +- org.apache.axis2:axis2-fastinfoset:jar:1.6.2:compile
- [INFO] | \- com.sun.xml.fastinfoset:FastInfoset:jar:1.2.7:compile
- [INFO] +- org.apache.axis2:axis2-java2wsdl:jar:1.6.2:compile
- [INFO] | \- org.apache.ant:ant:jar:1.7.0:compile
- [INFO] +- org.apache.axis2:axis2-ant-plugin:jar:1.6.2:compile
- [INFO] +- org.apache.axis2:axis2-clustering:jar:1.6.2:compile
- [INFO] | +- org.apache.tomcat:tribes:jar:6.0.16:compile
- [INFO] | \- org.apache.tomcat:juli:jar:6.0.16:compile
- [INFO] +- org.apache.axis2:axis2-jibx:jar:1.6.2:compile
- [INFO] | +- org.jibx:jibx-bind:jar:1.2:compile
- [INFO] | \- org.jibx:jibx-run:jar:1.2:compile
- [INFO] +- org.apache.axis2:axis2-json:jar:1.6.2:compile
- [INFO] | \- org.codehaus.jettison:jettison:jar:1.0-RC2:compile
- [INFO] +- org.apache.axis2:axis2-kernel:jar:1.6.2:compile
- [INFO] | +- org.apache.geronimo.specs:geronimo-ws-metadata_2.0_spec:jar:1.1.2:c
- ompile
- [INFO] | +- org.apache.geronimo.specs:geronimo-jta_1.1_spec:jar:1.1:compile
- [INFO] | +- javax.servlet:servlet-api:jar:2.3:compile
- [INFO] | \- javax.ws.rs:jsr311-api:jar:1.0:compile
- [INFO] +- org.apache.axis2:axis2-mtompolicy:jar:1.6.2:compile
- [INFO] +- org.apache.axis2:axis2-saaj:jar:1.6.2:compile
- [INFO] | \- org.apache.geronimo.specs:geronimo-saaj_1.3_spec:jar:1.0.1:compile
- [INFO] +- org.apache.axis2:axis2-soapmonitor-servlet:jar:1.6.2:compile
- [INFO] +- org.apache.axis2:axis2-spring:jar:1.6.2:compile
- [INFO] +- org.apache.axis2:axis2-transport-http:jar:1.6.2:compile
- [INFO] +- org.apache.axis2:axis2-transport-local:jar:1.6.2:compile
- [INFO] +- org.apache.axis2:axis2-xmlbeans:jar:1.6.2:compile
- [INFO] | +- org.apache.xmlbeans:xmlbeans:jar:2.3.0:compile
- [INFO] | \- org.apache.ant:ant-launcher:jar:1.7.0:compile
- [INFO] +- bcel:bcel:jar:5.1:compile
- [INFO] | \- regexp:regexp:jar:1.2:compile
- [INFO] +- net.sf.jmatchparser:jMatchParser-icu4j-chardet:jar:0.1:compile
- [INFO] | \- com.ibm.icu:icu4j:jar:4.8.1.1:compile
- [INFO] +- com.github.sebhoss:common-annotations:jar:1.0.0:compile
- [INFO] | \- com.google.code.findbugs:jsr305:jar:2.0.1:compile
- [INFO] +- commons-beanutils:commons-beanutils:jar:1.8.3:compile
- [INFO] +- commons-codec:commons-codec:jar:1.6:compile
- [INFO] +- commons-collections:commons-collections:jar:3.2.1:compile
- [INFO] +- commons-discovery:commons-discovery:jar:0.4:compile
- [INFO] +- commons-fileupload:commons-fileupload:jar:1.3:compile
- [INFO] +- commons-httpclient:commons-httpclient:jar:3.1:compile
- [INFO] +- commons-io:commons-io:jar:2.4:compile
- [INFO] +- commons-lang:commons-lang:jar:2.6:compile
- [INFO] +- org.apache.commons:commons-lang3:jar:3.1:compile
- [INFO] +- commons-logging:commons-logging:jar:1.1.1:compile
- [INFO] +- dom4j:dom4j:jar:1.6.1:compile
- [INFO] | \- xml-apis:xml-apis:jar:1.0.b2:compile
- [INFO] +- net.sf.ezmorph:ezmorph:jar:1.0.6:compile
- [INFO] +- net.sourceforge.htmlcleaner:htmlcleaner:jar:2.2:compile
- [INFO] | \- org.jdom:jdom:jar:1.1:compile
- [INFO] +- org.freemarker:freemarker:jar:2.3.19:compile
- [INFO] +- org.apache.httpcomponents:httpclient:jar:4.2.5:compile
- [INFO] +- org.apache.httpcomponents:httpclient-cache:jar:4.2.5:compile
- [INFO] +- org.apache.httpcomponents:httpcore:jar:4.2.4:compile
- [INFO] +- gov.nist.math:jama:jar:1.0.3:compile
- [INFO] +- javassist:javassist:jar:3.11.0.GA:compile
- [INFO] +- net.sf.json-lib:json-lib:jar:jdk15:2.3:compile
- [INFO] +- org.jsoup:jsoup:jar:1.7.2:compile
- [INFO] +- junit:junit:jar:4.11:compile
- [INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:compile
- [INFO] +- log4j:log4j:jar:1.2.17:compile
- [INFO] +- org.apache.lucene:lucene-core:jar:4.3.1:compile
- [INFO] +- org.mongodb:mongo-java-driver:jar:2.10.1:compile
- [INFO] +- org.apache.neethi:neethi:jar:3.0.2:compile
- [INFO] | \- org.codehaus.woodstox:woodstox-core-asl:jar:4.0.8:compile
- [INFO] | +- javax.xml.stream:stax-api:jar:1.0-2:compile
- [INFO] | \- org.codehaus.woodstox:stax2-api:jar:3.0.2:compile
- [INFO] +- ognl:ognl:jar:3.0.6:compile
- [INFO] +- org.apache.poi:poi:jar:3.9:compile
- [INFO] +- org.quartz-scheduler:quartz:jar:2.2.1:compile
- [INFO] | \- c3p0:c3p0:jar:0.9.1.1:compile
- [INFO] +- org.quartz-scheduler:quartz-jobs:jar:2.2.1:compile
- [INFO] +- org.slf4j:slf4j-api:jar:1.6.6:compile
- [INFO] +- org.slf4j:slf4j-simple:jar:1.7.5:compile
- [INFO] +- org.springframework:spring-beans:jar:4.0.0.RELEASE:compile
- [INFO] +- org.springframework:spring-aspects:jar:4.0.0.RELEASE:compile
- [INFO] +- org.springframework:spring-aop:jar:4.0.0.RELEASE:compile
- [INFO] +- org.springframework:spring-context:jar:4.0.0.RELEASE:compile
- [INFO] +- org.springframework:spring-context-support:jar:4.0.0.RELEASE:compile
- [INFO] +- org.springframework:spring-core:jar:4.0.0.RELEASE:compile
- [INFO] +- org.springframework.data:spring-data-commons:jar:1.5.0.RELEASE:compile
- [INFO] | \- org.slf4j:jcl-over-slf4j:jar:1.7.1:runtime
- [INFO] +- org.springframework.data:spring-data-mongodb:jar:1.2.0.RELEASE:compile
- [INFO] +- org.springframework.data:spring-data-mongodb-cross-store:jar:1.2.0.REL
- EASE:compile
- [INFO] | +- org.aspectj:aspectjrt:jar:1.7.1:compile
- [INFO] | +- cglib:cglib:jar:2.2:compile
- [INFO] | \- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.0.Fin
- al:compile
- [INFO] +- org.springframework.data:spring-data-mongodb-log4j:jar:1.2.0.RELEASE:c
- ompile
- [INFO] +- org.aspectj:aspectjweaver:jar:1.8.0:compile
- [INFO] +- org.springframework:spring-expression:jar:4.0.0.RELEASE:compile
- [INFO] +- org.springframework:spring-orm:jar:4.0.0.RELEASE:compile
- [INFO] | +- aopalliance:aopalliance:jar:1.0:compile
- [INFO] | \- org.springframework:spring-jdbc:jar:4.0.0.RELEASE:compile
- [INFO] +- org.springframework:spring-tx:jar:4.0.0.RELEASE:compile
- [INFO] +- org.springframework:spring-web:jar:4.0.0.RELEASE:compile
- [INFO] +- org.apache.struts:struts2-core:jar:2.3.15.1:compile
- [INFO] +- org.apache.struts:struts2-json-plugin:jar:2.3.15.1:compile
- [INFO] +- org.apache.struts:struts2-spring-plugin:jar:2.3.15.1:compile
- [INFO] +- org.apache.woden:woden-api:jar:1.0M9:compile
- [INFO] +- org.apache.woden:woden-impl-commons:jar:1.0M9:compile
- [INFO] +- org.apache.woden:woden-impl-dom:jar:1.0M9:compile
- [INFO] +- wsdl4j:wsdl4j:jar:1.6.2:compile
- [INFO] +- xalan:xalan:jar:2.7.0:compile
- [INFO] +- xml-resolver:xml-resolver:jar:1.2:compile
- [INFO] +- org.apache.ws.commons.schema:XmlSchema:jar:1.4.7:compile
- [INFO] \- org.apache.struts.xwork:xwork-core:jar:2.3.15.1:compile
- [INFO] +- asm:asm:jar:3.3:compile
- [INFO] \- asm:asm-commons:jar:3.3:compile
- [INFO] \- asm:asm-tree:jar:3.3:compile
- [INFO] ------------------------------------------------------------------------
- [INFO] BUILD SUCCESS
- [INFO] ------------------------------------------------------------------------
- [INFO] Total time: 02:27 min
- [INFO] Finished at: 2014-11-17T19:37:06+08:00
- [INFO] Final Memory: 14M/33M
- [INFO] ------------------------------------------------------------------------
- D:\workspace\ipFilterM>
根据以上方法依次解决每个包的依赖冲突后,该问题解决。
slf4j包错误
错误如下:- java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
- at org.apache.commons.logging.impl.SLF4JLocationAwareLog.error(SLF4JLocationAwareLog.java:225)
- at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:319)
- at com.alibaba.citrus.webx.context.WebxComponentsLoader.initWebApplicationContext(WebxComponentsLoader.java:117)
- at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
- at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779)
- at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)
- at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
- at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895)
原因
slf4j错误本质上也是包的冲突错误,编译时和运行时采用了不一样的jar.它的报错信息说的是 在这个类中找不到对应的方法,这是因为 slf4j包不同的版本,方法名不一样导致的。比如tomcat默认的使用某一版本的sjf4j包,但我们引入了一个新版本的包,这时候tomcat就会去找新版本的包,当然就找不到这个方法。我们在myeclipse的pom.xml视图中也能看到这样的冲突,如图:
那么解决的方法跟上述的依赖包类似