GCP数据流:Log4J StackOverflowError aka Java Classpath操作

时间:2019-05-15 21:42:47

标签: java logging log4j classpath google-cloud-dataflow

我正在尝试在Google Cloud Dataflow上部署一个简单的管道(以将一些数据从PubSub复制到Bigtable),但是我一直收到以下错误消息:

Exception in thread "main"  
java.lang.StackOverflowError
        at java.util.HashMap.hash(HashMap.java:338)
        at java.util.HashMap.get(HashMap.java:556)
        at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:67)
        at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
[ multiple times ... ]
        at org.apache.log4j.Category.<init>(Category.java:57)
        at org.apache.log4j.Logger.<init>(Logger.java:37)
        at org.apache.log4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:43)
        at org.apache.log4j.LogManager.getLogger(LogManager.java:45)
        at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:73)
        at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
java failed with exit status 1

此错误导致该工人死亡。即使我的代码中没有没有日志记录语句或导入,并且在堆栈跟踪中确实引用了我的代码没有,也会发生这种情况。我熟悉this question,并且在GCP Stackdriver中可以看到我的Java命令确实 确实包含log4j_to_slf4j.jar

java -Xmx5834483752 -XX:-OmitStackTraceInFastThrow -Xloggc:/var/log/dataflow/jvm-gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=2 -XX:GCLogFileSize=512K -cp /opt/google/dataflow/streaming/libWindmillServer.jar:/opt/google/dataflow/streaming/dataflow-worker.jar:/opt/google/dataflow/slf4j/jcl_over_slf4j.jar:/opt/google/dataflow/slf4j/log4j_over_slf4j.jar:/opt/google/dataflow/slf4j/log4j_to_slf4j.jar: ...

问题是此Java命令由Google创建。 log4j_to_slf4j.jar在我自己的依赖项中。如何编辑此命令并将其从Classpath中删除?还是有更好的解决方案?

谢谢!

1 个答案:

答案 0 :(得分:0)

好吧,降级这些依赖项:

<dependency>
   <groupId>org.apache.beam</groupId>
   <artifactId>beam-runners-google-cloud-dataflow-java</artifactId>
   <version>2.12.0</version>
</dependency>
<dependency>
   <groupId>org.apache.beam</groupId>
   <artifactId>beam-sdks-java-extensions-json-jackson</artifactId>
   <version>2.12.0</version>
</dependency>

2.12.02.9.0的问题已解决。 2.10.0再次失败。我当时在官方(?)examples上建模实现,但是使用2.4.0