我是maven和storm的新手。我尝试通过此命令以本地模式运行myTopology
mvn compile exec:java -Dstorm.topology=my.Topology
但是我收到了这个错误
clojure.tools.logging$eval1$fn__7 invoke
SEVERE: Async loop died!
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.log4j.Category.differentiatedLog(Category.java:186)
at org.apache.log4j.Category.info(Category.java:229)
at backtype.storm.utils.ShellProcess.getSerializer(ShellProcess.java:78)
at backtype.storm.utils.ShellProcess.launch(ShellProcess.java:58)
at backtype.storm.task.ShellBolt.prepare(ShellBolt.java:117)
at backtype.storm.daemon.executor$fn__3439$fn__ 3451.invoke (executor.clj:699)
at backtype.storm.util$async_loop$fn__460.invoke(util.clj:461)
at clojure.lang.AFn.run(AFn.java:24)
at java.lang.Thread.run(Thread.java:701)
我使用了mvn dependency:tree
并获得了
[INFO] +- org.slf4j:slf4j-api:jar:1.7.5:provided
[INFO] +- org.slf4j:log4j-over-slf4j:jar:1.6.6:provided
我试图在pom中添加这些行
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
但在执行mvn dependency:tree
+- org.slf4j:log4j-over-slf4j:jar:1.6.6:provided
同样的错误仍然是
答案 0 :(得分:0)
以下适用于我:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.22</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.7</version>
</dependency>
</dependencies>
测试是:
package com.greg;
import static org.junit.Assert.*;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class AppTest {
@Test
public void test1() {
Logger logger = LoggerFactory.getLogger(AppTest.class);
logger.debug("hello greg");
assertTrue(true);
}
}
确保资源目录中有log4j.xml。
请参阅http://learnjava-soa.blogspot.co.uk/2015/06/slf4j-with-log4j2-example.html