java.lang.NoSuchMethodError:org.slf4j.spi.LocationAwareLogger.log

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (2)
  • 关注 (0)
  • 查看 (68)

我在部署我的应用程序时遇到此错误

    java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Ma
      rker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V
        at org.apache.commons.logging.impl.SLF4JLocationAwareLog.info(SLF4JLocat
        ionAwareLog.java:141)
        at org.springframework.web.context.ContextLoader.initWebApplicationConte
        xt(ContextLoader.java:272)      

我正在使用maven而这是我的pom.xml

    <properties>
    <!-- Using this GWT version -->
    <gwt.version>2.4.0</gwt.version>

    <!-- Using this Jackrabbit version -->
    <jcr.version>1.6.5</jcr.version>

    <!-- Using this Spring version -->
    <spring.version>3.1.0.RELEASE</spring.version>
    <spring.security.version>3.1.0.RELEASE</spring.security.version>

    <!-- Apache CXF -->
    <cxf.version>2.5.1</cxf.version>

    <!-- Apache POI -->
    <poi.version>3.8</poi.version>

    <!-- Milton WebDAV -->
    <milton.version>1.8.1.3</milton.version>

    <!-- Tell the compiler we can use 1.6 -->
    <java.compiler>1.6</java.compiler>

     <!-- Default source encoding ${default.encoding} -->
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     </properties>

    <repositories>
     <!-- Needed for org.jbpm & org.hibernate-->
    <repository>
      <id>jboss.org</id>
      <name>JBoss Maven Repository</name>
      <url>http://repository.jboss.org/nexus/content/groups/public</url>
    </repository>

    <!-- Needed for ROME -->
    <repository>
      <id>maven2-repository.dev.java.net</id>
      <name>Java.net Repository for Maven</name>
      <url>http://download.java.net/maven/2/</url>
    </repository>

    <!-- Needed for Gson -->
    <repository>
      <id>gson</id>
      <name>GSon Repository for Maven</name>
      <url>http://google-gson.googlecode.com/svn/mavenrepo</url>
    </repository>

    <!-- Needed for Milton -->
    <repository>
      <id>ettrema-repo</id>
      <name>Milto WebDAV</name>
      <url>http://milton.io/maven</url>
    </repository>

    <!-- OpenKM repository -->
    <repository>
      <id>openkm.com</id>
      <name>OpenKM Maven Reporitory</name>
      <url>http://maven.openkm.com/maven2</url>
    </repository>

    <!-- StringTree repository -->
    <repository>
      <id>StringTree</id>
      <name>String Tree</name>
      <url>http://stringtree.org/repository/</url>
    </repository>

    <!-- Video conversion and resolution change -->
    <repository>
        <id>xuggle repo</id>
        <name>Xuggle</name>
        <url>http://xuggle.googlecode.com/svn/trunk/repo/share/java/</url>
    </repository>
  </repositories>

  <dependencies>
    <!-- Test units -->
    <dependency>
      <groupId>javax.transaction</groupId>
      <artifactId>jta</artifactId>
      <version>1.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>javassist</groupId>
      <artifactId>javassist</artifactId>
      <version>3.12.1.GA</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.hsqldb</groupId>
      <artifactId>hsqldb</artifactId>
      <version>2.2.6</version>
      <scope>test</scope>
    </dependency>

    <!-- Provided libraries -->
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>servlet-api</artifactId>
      <version>2.5</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>jstl</artifactId>
      <version>1.2</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>javax.servlet.jsp</groupId>
      <artifactId>jsp-api</artifactId>
      <version>2.1</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>javax.mail</groupId>
      <artifactId>mail</artifactId>
      <version>1.4.5</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <!-- JBoss already have its own log4j.jar -->
      <!-- http://www.coderanch.com/t/91054/JBoss/log-j-messages-JBoss-log -->
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <version>1.2.17</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-catalina</artifactId>
      <version>7.0.27</version>
      <scope>provided</scope>
    </dependency>

    <!-- Misc -->
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <version>1.4</version>
    </dependency>
    <dependency>
      <groupId>commons-fileupload</groupId>
      <artifactId>commons-fileupload</artifactId>
      <version>1.2.2</version>
    </dependency>
    <dependency>
      <groupId>commons-httpclient</groupId>
      <artifactId>commons-httpclient</artifactId>
      <version>3.1</version>
    </dependency>
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-compress</artifactId>
      <version>1.0</version>
    </dependency>
    <dependency>
      <groupId>de.schlichtherle</groupId>
      <artifactId>truezip</artifactId>
      <version>6.8.2</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
      <version>1.7.5</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>jul-to-slf4j</artifactId>
      <version>1.7.5</version>
    </dependency>
    <dependency>
      <groupId>dnsjava</groupId>
      <artifactId>dnsjava</artifactId>
      <version>2.0.8</version>
    </dependency>
    <dependency>
      <groupId>commons-beanutils</groupId>
      <artifactId>commons-beanutils</artifactId>
      <version>1.8.3</version>
    </dependency>

    <!-- Base64 encoding / decoding -->
    <!-- http://www.techiegyan.com/?p=333 -->
    <!-- Downgraded to 1.3 due to GWT 2.2 dependency -->
    <dependency>
      <groupId>commons-codec</groupId>
      <artifactId>commons-codec</artifactId>
      <version>1.2</version>
    </dependency>

    <!-- Jackrabbit -->
    <dependency>
      <groupId>javax.jcr</groupId>
      <artifactId>jcr</artifactId>
      <version>1.0</version>
    </dependency>
    <dependency>
      <groupId>org.apache.jackrabbit</groupId>
      <artifactId>jackrabbit-core</artifactId>
      <version>${jcr.version}</version>
      <exclusions>
        <!-- We want to use the last POI version -->
        <exclusion>
          <groupId>poi</groupId>
          <artifactId>poi</artifactId>
        </exclusion>

        <!-- Hibernate Search uses a more recent version of Lucene-->
        <exclusion>
          <groupId>org.apache.lucene</groupId>
          <artifactId>lucene-core</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.apache.jackrabbit</groupId>
      <artifactId>jackrabbit-text-extractors</artifactId>
      <version>${jcr.version}</version>
      <exclusions>
        <exclusion>
          <groupId>pdfbox</groupId>
          <artifactId>pdfbox</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <!-- Twitter4j -->
    <dependency>
      <groupId>net.homeip.yusuke</groupId>
      <artifactId>twitter4j</artifactId>
      <version>2.0.10</version>
    </dependency>

    <!-- ROME -->
    <dependency>
      <groupId>rome</groupId>
      <artifactId>rome</artifactId>
      <version>1.0</version>
    </dependency>

    <!-- JasperReports -->
    <dependency>
      <groupId>net.sf.jasperreports</groupId>
      <artifactId>jasperreports</artifactId>
      <version>3.7.6</version>
      <exclusions>
        <!-- Avoid java.lang.NoSuchMethodError: org.eclipse.jdt.internal.compiler.Compiler -->
        <!-- See http://groups.google.com/group/google-web-toolkit/browse_thread/thread/49e20fb5185b34ce/75436f95e29dce85?hl=en -->
        <exclusion>
          <groupId>eclipse</groupId>
          <artifactId>jdtcore</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-all-minimal</artifactId>
      <version>1.5.8</version>
    </dependency>

    <!-- Workflow library from JBoss -->
    <dependency>
      <groupId>org.jbpm.jbpm3</groupId>
      <artifactId>jbpm-jpdl</artifactId>
      <version>3.3.1.OKM</version>
      <exclusions>
        <exclusion>
          <groupId>org.hibernate</groupId>
          <artifactId>hibernate</artifactId>
        </exclusion>
        <exclusion>
          <groupId>bsh</groupId>
          <artifactId>bsh</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.jbpm.jbpm3</groupId>
      <artifactId>jbpm-identity</artifactId>
      <version>3.3.1.OKM</version>
    </dependency>

    <!-- Hibernate -->
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-core</artifactId>
      <version>3.6.10.Final</version>
      <exclusions>
        <exclusion>
          <groupId>javax.transaction</groupId>
          <artifactId>jta</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-search</artifactId>
      <version>3.4.2.Final</version>
      <exclusions>
        <exclusion>
          <groupId>javax.transaction</groupId>
          <artifactId>jta</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-validator</artifactId>
      <version>4.2.0.Final</version>
    </dependency>
    <dependency>
      <groupId>org.apache.lucene</groupId>
      <artifactId>lucene-queries</artifactId>
      <version>3.1.0</version>
    </dependency>

    <!-- BeanShell support -->
    <dependency>
      <groupId>org.beanshell</groupId>
      <artifactId>bsh</artifactId>
      <version>1.3.0</version>
    </dependency>

    <!-- OpenOffice.org integration -->
    <dependency>
      <groupId>org.artofsolving.jodconverter</groupId>
      <artifactId>jodconverter-core</artifactId>
      <version>3.0-beta-4</version>
    </dependency>

    <!-- Text extractors -->
    <dependency>
      <groupId>entagged.audioformats</groupId>
      <artifactId>audioformats</artifactId>
      <version>0.15</version>
    </dependency>
    <dependency>
      <groupId>com.drewnoakes</groupId>
      <artifactId>metadata-extractor</artifactId>
      <version>2.4.0-beta-1</version>
    </dependency>
    <dependency>
      <groupId>org.apache.poi</groupId>
      <artifactId>poi</artifactId>
      <version>${poi.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.poi</groupId>
      <artifactId>poi-scratchpad</artifactId>
      <version>${poi.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.pdfbox</groupId>
      <artifactId>pdfbox</artifactId>
      <version>1.6.0</version>
    </dependency>
    <dependency>
      <!-- http://books.evc-cit.info/odf_utils -->
      <groupId>com.catcode</groupId>
      <artifactId>odfutils</artifactId>
      <version>051129</version>
    </dependency>

    <!-- Spell checking -->
    <!-- http://kenai.com/projects/jmyspell -->
    <dependency>
      <groupId>org.dts</groupId>
      <artifactId>jmyspell-core</artifactId>
      <version>1.0.0-beta-2</version>
    </dependency>

    <!-- Templates -->
    <dependency>
      <groupId>net.sf</groupId>
      <artifactId>jodreports</artifactId>
      <version>2.3.0</version>
    </dependency>
    <dependency>
      <groupId>org.odftoolkit</groupId>
      <artifactId>odfdom-java</artifactId>
      <version>0.8.6</version>
    </dependency>

    <!-- SIGAR -->
    <dependency>
      <groupId>org.hyperic</groupId>
      <artifactId>sigar</artifactId>
      <version>1.6.5.132</version>
    </dependency>

    <!-- GWT -->
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-servlet</artifactId>
      <version>${gwt.version}</version>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-user</artifactId>
      <version>${gwt.version}</version>
      <scope>provided</scope>
    </dependency>
    <!-- Only for development -->
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-dev</artifactId>
      <version>${gwt.version}</version>
      <scope>provided</scope>
    </dependency>

    <!-- GWT plugins -->
    <dependency>
      <groupId>com.google.code.gwt-log</groupId>
      <artifactId>gwt-log</artifactId>
      <version>3.1.6</version>
    </dependency>
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-incubator</artifactId>
      <version>2.1.0</version>
    </dependency>
    <dependency>
      <groupId>gwt-vl.sourceforge.net</groupId>
      <artifactId>gwt-vl</artifactId>
      <version>2.0b-without-hibernate</version>
    </dependency>

    <!-- KEA -->
    <dependency>
      <groupId>org.openrdf.sesame</groupId>
      <artifactId>onejar</artifactId>
      <version>2.2.4</version>
    </dependency>

    <!-- Gson: Java to Json conversion -->
    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
      <version>1.5</version>
    </dependency>

    <!-- Java CronTab Syntax Parser -->
    <dependency>
      <groupId>com.kenai.crontab-parser</groupId>
      <artifactId>crontab-parser</artifactId>
      <version>1.0.1</version>
    </dependency>

    <!-- Apache CXF -->
    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-frontend-jaxws</artifactId>
      <version>${cxf.version}</version>
      <exclusions>
        <exclusion>
          <groupId>org.apache.geronimo.specs</groupId>
          <artifactId>geronimo-javamail_1.4_spec</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-transports-http</artifactId>
      <version>${cxf.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-ws-security</artifactId>
      <version>${cxf.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.ws.security</groupId>
      <artifactId>wss4j</artifactId>
      <version>1.6.8</version>
    </dependency>

    <!-- Spring -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-beans</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-web</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-orm</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.ws</groupId>
      <artifactId>spring-ws-core</artifactId>
      <version>2.1.3.RELEASE</version>
    </dependency>

    <!-- Spring Security -->
    <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-core</artifactId>
      <version>${spring.security.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-config</artifactId>
      <version>${spring.security.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-web</artifactId>
      <version>${spring.security.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-taglibs</artifactId>
      <version>${spring.security.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-ldap</artifactId>
      <version>${spring.security.version}</version>
    </dependency>

    <!-- Plugin framework -->
    <dependency>
      <groupId>com.google.code</groupId>
      <artifactId>jspf</artifactId>
      <version>1.0.1</version>
    </dependency>

    <!-- Milton WebDAV -->
    <dependency>
      <groupId>com.ettrema</groupId>
      <artifactId>milton-api</artifactId>
      <version>${milton.version}</version>
    </dependency>
    <dependency>
      <groupId>com.ettrema</groupId>
      <artifactId>milton-servlet</artifactId>
      <version>${milton.version}</version>
      <exclusions>
        <exclusion>
          <groupId>org.springframework</groupId>
          <artifactId>spring</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.springframework</groupId>
          <artifactId>spring-webmvc</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <!-- Java Bean to Java Bean mapper -->
    <dependency>
      <groupId>net.sf.dozer</groupId>
      <artifactId>dozer</artifactId>
      <version>5.3.2</version>
    </dependency>

    <!-- Language detection -->
    <dependency>
      <groupId>com.cybozu</groupId>
      <artifactId>langdetect</artifactId>
      <version>2011.11.28</version>
    </dependency>

    <!-- OWASP Java Encoders -->
    <!-- https://code.google.com/p/owasp-java-encoder/ -->
    <dependency>
      <groupId>org.owasp</groupId>
      <artifactId>encoder</artifactId>
      <version>1.1</version>
    </dependency>

    <!-- Outlook Message -->
    <dependency>
      <groupId>com.auxilii</groupId>
      <artifactId>msgparser</artifactId>
      <version>1.11</version>
    </dependency>

    <!-- International Component for Unicode for Java -->
    <dependency>
      <groupId>com.ibm.icu</groupId>
      <artifactId>icu4j</artifactId>
      <version>51.1</version>
    </dependency>

    <!-- Dropbox -->
    <dependency>
      <groupId>com.dropbox.sdk</groupId>
      <artifactId>dropbox-client</artifactId>
      <version>5.1.3</version>
    </dependency>

    <!-- OMR Tool -->
    <!-- http://www.cse.iitd.ernet.in/~aseth/udai/OMRProj/README.html -->
    <dependency>
      <groupId>ca.uwaterloo.a3seth</groupId>
      <artifactId>omr-tool</artifactId>
      <version>2007.07.01</version>
    </dependency>
    <dependency>
      <groupId>net.sourceforge</groupId>
      <artifactId>jiu</artifactId>
      <version>2007.07.01</version>
    </dependency>

    <!-- Video File manipulation -->
    <dependency>
   <groupId>xuggle</groupId>
   <artifactId>xuggle-xuggler</artifactId>
   <version>5.4</version>
  </dependency>
  <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>1.7.5</version>
    </dependency>
    <dependency>
      <groupId>commons-cli</groupId>
      <artifactId>commons-cli</artifactId>
      <version>1.1</version>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-core</artifactId>
      <version>1.0.13</version>
      <scope>runtime</scope>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <version>1.0.13</version>
      <scope>runtime</scope>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.5</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

最近我添加了xuggle-xuggler:5.4用于视频处理功能。并升级了大部分的jar版本。从那时起我得到这个错误

提问于
用户回答回答于

mvn dependency:tree看哪个SLF4J行家的版本决定给你。如果选择了错误的版本,则可以使用依赖关系管理部分来指定您想要的版本。

如果dependency:tree的输出显示了正确的版本(即包含它找不到的方法的版本),那么添加-verbose:class一个jvm参数以查看它从何处加载该类(例如,如果在jboss中部署它可能会从它的内部日志记录罐而不是你的slf4j罐装载它)。

用户回答回答于

dependency:tree是一个有用的工具,这是真的。

另外,另一种解决方法是:

在使用Eclipse IDE时,使用SHIFT + CTRL + T打开以下类型的“ SLF4JLocationAwareLog

你应该能够找到相关的图书馆以及潜在的冲突。

切换到pom.xml知道要添加的排除项的依赖关系树视图。

就我而言,与struts依赖关系有关jcl104-over-slf4j。我只是从依赖中排除这一个:

        <dependency>
        <groupId>displaytag</groupId>
        <artifactId>displaytag</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>jcl104-over-slf4j</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

扫码关注云+社区