最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - Log parser ERROR in ApplicationContext Constructor - Stack Overflow

programmeradmin2浏览0评论

I have the requirement to implement the Spring framework into a legacy application in order to give it more structure. However the run process cannot be changed (large setup where hundreds of jobs would need to be adapted should I touch how the application is invoked).

So, the program is started with java -cp program.jar ProgramMain -class_name "script" ...

ProgramMain main method looks like this:

public static void main(String[] args) {
        try {
            setEnvironmentVariables(args);
            ApplicationContext context = new AnnotationConfigApplicationContext(EnvironmentConfiguration.class);
            var className = context.getBean("className", String.class);
            var executionScript = context.getBean(className, ScriptInterface.class);
            System.out.println("Executing script");
            executionScript.setup();
            executionScript.run();
            System.exit(0);
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

Everything works, but the logging looks like this (abbreviated since its a lot of the same):

2025-02-17T13:38:44.732463534Z main ERROR Unrecognized format specifier [d]
2025-02-17T13:38:44.734027716Z main ERROR Unrecognized conversion specifier [d] starting at position 16 in conversion pattern.
2025-02-17T13:38:44.734713836Z main ERROR Unrecognized format specifier [thread]
2025-02-17T13:38:44.734788519Z main ERROR Unrecognized conversion specifier [thread] starting at position 25 in conversion pattern.
...
2025-02-17T13:38:44.742182084Z main ERROR Unrecognized format specifier [msg]
2025-02-17T13:38:44.742221296Z main ERROR Unrecognized conversion specifier [msg] starting at position 54 in conversion pattern.
2025-02-17T13:38:44.742265692Z main ERROR Unrecognized format specifier [n]
2025-02-17T13:38:44.742302840Z main ERROR Unrecognized conversion specifier [n] starting at position 56 in conversion pattern.
[main] INFO com.package.program.configuration.EnvironmentConfiguration - Setting up environment

The last log line is in the first line of the EnvironmentConfiguration class Constructor. So this ERRORS are being logged when the AnnotationConfigApplicationContext class is instantiated and before it loads the EnvironmentConfiguration.

Relevant dependencies from the mvn dependency tree:

[INFO] |  |  \- commons-logging:commons-logging:jar:1.1.3:compile
[INFO] +- .apache.logging.log4j:log4j-api:jar:2.24.3:compile
[INFO] +- .apache.logging.log4j:log4j-core:jar:2.24.3:compile
[INFO] \- .apache.logging.log4j:log4j-slf4j2-impl:jar:2.24.3:compile
[INFO] |  \- .slf4j:jcl-over-slf4j:jar:1.7.10:compile
[INFO] +- .slf4j:slf4j-api:jar:2.0.16:compile
[INFO] +- .slf4j:slf4j-simple:jar:2.0.16:compile

So I have no "multiple versions of the same jar". I have no clue where these ERRORS come from. Logging with slf4j.Logger in the rest of the application works fine and it's parsed correctly (for example: [main] INFO com.package.program.scripts.AbstractScriptInterfaceImpl - Running TestScript

I have played around with so many combinations of dependencies. The "best" solution is only having slf4j-api and slf4j-simple as dependencies, which leads to only one ERROR being logged:

ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...

log4j2.xml:

<Configuration>
  <Appenders>
    <Console name="Console">
      <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
    </Console>
  </Appenders>
  <Loggers>
    <Root level="info">
      <AppenderRef ref="Console"/>
    </Root>
  </Loggers>
</Configuration>

I have no idea how to get rid of these ERRORS and any idea is appreciated, thank you.

EDIT: Added log4j2.xml

[INFO] +- me.tongfei:progressbar:jar:0.10.1:compile
[INFO] |  \- .jline:jline-terminal:jar:3.24.1:compile
[INFO] |     \- .jline:jline-native:jar:3.24.1:compile
[INFO] +- .springframework:spring-web:jar:6.2.0:compile
[INFO] |  +- .springframework:spring-core:jar:6.2.0:compile
[INFO] |  |  \- .springframework:spring-jcl:jar:6.2.0:compile
[INFO] |  \- io.micrometer:micrometer-observation:jar:1.14.0:compile
[INFO] |     \- io.micrometer:micrometer-commons:jar:1.14.0:compile
[INFO] +- .springframework.boot:spring-boot:jar:3.4.0:compile
[INFO] +- .springframework.boot:spring-boot-autoconfigure:jar:3.2.4:compile
[INFO] +- .springframework:spring-context:jar:6.2.0:compile
[INFO] |  +- .springframework:spring-aop:jar:6.2.0:compile
[INFO] |  \- .springframework:spring-expression:jar:6.2.0:compile
[INFO] +- .springframework:spring-beans:jar:6.2.0:compile
[INFO] +- io.minio:minio:jar:8.5.12:compile
[INFO] |  +- com.carrotsearch.thirdparty:simple-xml-safe:jar:2.7.1:compile
[INFO] |  +- com.google.guava:guava:jar:33.0.0-jre:compile
[INFO] |  |  +- com.google.guava:failureaccess:jar:1.0.2:compile
[INFO] |  |  +- com.google.guava:listenablefuture:jar:9999.0-empty-to-avoid-conflict-with-guava:compile
[INFO] |  |  +- com.google.code.findbugs:jsr305:jar:3.0.2:compile
[INFO] |  |  +- .checkerframework:checker-qual:jar:3.41.0:compile
[INFO] |  |  +- com.google.errorprone:error_prone_annotations:jar:2.23.0:compile
[INFO] |  |  \- com.google.j2objc:j2objc-annotations:jar:2.8:compile
[INFO] |  +- com.squareup.okhttp3:okhttp:jar:4.12.0:compile
[INFO] |  |  +- com.squareup.okio:okio:jar:3.6.0:compile
[INFO] |  |  |  \- com.squareup.okio:okio-jvm:jar:3.6.0:compile
[INFO] |  |  |     \- .jetbrains.kotlin:kotlin-stdlib-common:jar:1.9.10:compile
[INFO] |  |  \- .jetbrains.kotlin:kotlin-stdlib-jdk8:jar:1.8.21:compile
[INFO] |  |     +- .jetbrains.kotlin:kotlin-stdlib:jar:1.8.21:compile
[INFO] |  |     \- .jetbrains.kotlin:kotlin-stdlib-jdk7:jar:1.8.21:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.16.1:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-core:jar:2.16.1:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.16.1:compile
[INFO] |  +- .bouncycastle:bcprov-jdk18on:jar:1.78:compile
[INFO] |  +- .apachemons:commons-compress:jar:1.26.0:compile
[INFO] |  +- commons-codec:commons-codec:jar:1.16.1:compile
[INFO] |  \- .xerial.snappy:snappy-java:jar:1.1.10.5:compile
[INFO] +- .apachemons:commons-text:jar:1.12.0:compile
[INFO] |  \- .apachemons:commons-lang3:jar:3.14.0:compile
[INFO] +- .reflections:reflections:jar:0.9.11:compile
[INFO] |  \- .javassist:javassist:jar:3.21.0-GA:compile
[INFO] +- com.inhouse.elasticsearch:elastic_connector:jar:7.9.1-0.8:compile
[INFO] |  +- com.fasterxml.jackson.dataformat:jackson-dataformat-properties:jar:2.8.6:compile
[INFO] |  +- .elasticsearch.client:elasticsearch-rest-high-level-client:jar:7.9.1:compile
[INFO] |  |  +- .elasticsearch.plugin:mapper-extras-client:jar:7.9.1:compile
[INFO] |  |  +- .elasticsearch.plugin:parent-join-client:jar:7.9.1:compile
[INFO] |  |  +- .elasticsearch.plugin:aggs-matrix-stats-client:jar:7.9.1:compile
[INFO] |  |  +- .elasticsearch.plugin:rank-eval-client:jar:7.9.1:compile
[INFO] |  |  \- .elasticsearch.plugin:lang-mustache-client:jar:7.9.1:compile
[INFO] |  |     \- com.github.spullara.mustache.java:compiler:jar:0.9.6:compile
[INFO] |  +- .elasticsearch:elasticsearch:jar:7.9.1:compile
[INFO] |  |  +- .elasticsearch:elasticsearch-core:jar:7.9.1:compile
[INFO] |  |  +- .elasticsearch:elasticsearch-secure-sm:jar:7.9.1:compile
[INFO] |  |  +- .elasticsearch:elasticsearch-x-content:jar:7.9.1:compile
[INFO] |  |  |  +- .yaml:snakeyaml:jar:1.26:compile
[INFO] |  |  |  +- com.fasterxml.jackson.dataformat:jackson-dataformat-smile:jar:2.10.4:compile
[INFO] |  |  |  +- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.10.4:compile
[INFO] |  |  |  \- com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:jar:2.10.4:compile
[INFO] |  |  +- .elasticsearch:elasticsearch-geo:jar:7.9.1:compile
[INFO] |  |  +- .apache.lucene:lucene-core:jar:8.6.2:compile
[INFO] |  |  +- .apache.lucene:lucene-analyzers-common:jar:8.6.2:compile
[INFO] |  |  +- .apache.lucene:lucene-backward-codecs:jar:8.6.2:compile
[INFO] |  |  +- .apache.lucene:lucene-grouping:jar:8.6.2:compile
[INFO] |  |  +- .apache.lucene:lucene-highlighter:jar:8.6.2:compile
[INFO] |  |  +- .apache.lucene:lucene-join:jar:8.6.2:compile
[INFO] |  |  +- .apache.lucene:lucene-memory:jar:8.6.2:compile
[INFO] |  |  +- .apache.lucene:lucene-misc:jar:8.6.2:compile
[INFO] |  |  +- .apache.lucene:lucene-queries:jar:8.6.2:compile
[INFO] |  |  +- .apache.lucene:lucene-queryparser:jar:8.6.2:compile
[INFO] |  |  +- .apache.lucene:lucene-sandbox:jar:8.6.2:compile
[INFO] |  |  +- .apache.lucene:lucene-spatial-extras:jar:8.6.2:compile
[INFO] |  |  +- .apache.lucene:lucene-spatial3d:jar:8.6.2:compile
[INFO] |  |  +- .apache.lucene:lucene-suggest:jar:8.6.2:compile
[INFO] |  |  +- .elasticsearch:elasticsearch-cli:jar:7.9.1:compile
[INFO] |  |  |  \- net.sf.jopt-simple:jopt-simple:jar:5.0.2:compile
[INFO] |  |  +- com.carrotsearch:hppc:jar:0.8.1:compile
[INFO] |  |  +- com.tdunning:t-digest:jar:3.2:compile
[INFO] |  |  +- .hdrhistogram:HdrHistogram:jar:2.1.9:compile
[INFO] |  |  \- .elasticsearch:jna:jar:5.5.0:compile
[INFO] |  +- .elasticsearch.client:elasticsearch-rest-client:jar:7.9.1:compile
[INFO] |  |  +- .apache.httpcomponents:httpasyncclient:jar:4.1.4:compile
[INFO] |  |  \- .apache.httpcomponents:httpcore-nio:jar:4.4.12:compile
[INFO] |  +- joda-time:joda-time:jar:2.9.5:compile
[INFO] |  +- io.lettuce:lettuce-core:jar:5.1.0.RELEASE:compile
[INFO] |  |  +- io.projectreactor:reactor-core:jar:3.2.0.RELEASE:compile
[INFO] |  |  |  \- .reactivestreams:reactive-streams:jar:1.0.2:compile
[INFO] |  |  +- ioty:netty-common:jar:4.1.29.Final:compile
[INFO] |  |  +- ioty:netty-transport:jar:4.1.29.Final:compile
[INFO] |  |  |  +- ioty:netty-buffer:jar:4.1.29.Final:compile
[INFO] |  |  |  \- ioty:netty-resolver:jar:4.1.29.Final:compile
[INFO] |  |  \- ioty:netty-handler:jar:4.1.29.Final:compile
[INFO] |  |     \- ioty:netty-codec:jar:4.1.29.Final:compile
[INFO] |  +- .apache.httpcomponents:httpclient:jar:4.5.2:compile
[INFO] |  +- .apache.httpcomponents:httpcore:jar:4.4.10:compile
[INFO] |  +- .jetbrains:annotations:jar:15.0:compile
[INFO] |  +- javax.annotation:javax.annotation-api:jar:1.3.2:compile
[INFO] |  \- .assertj:assertj-core:jar:3.11.1:compile
[INFO] +- .json:json:jar:20240303:compile
[INFO] +- .glassfish.jersey.core:jersey-client:jar:2.22.2:compile
[INFO] |  +- javax.ws.rs:javax.ws.rs-api:jar:2.0.1:compile
[INFO] |  +- .glassfish.jersey.core:jersey-common:jar:2.22.2:compile
[INFO] |  |  +- .glassfish.jersey.bundles.repackaged:jersey-guava:jar:2.22.2:compile
[INFO] |  |  \- .glassfish.hk2:osgi-resource-locator:jar:1.0.1:compile
[INFO] |  +- .glassfish.hk2:hk2-api:jar:2.4.0-b34:compile
[INFO] |  |  +- .glassfish.hk2:hk2-utils:jar:2.4.0-b34:compile
[INFO] |  |  \- .glassfish.hk2.external:aopalliance-repackaged:jar:2.4.0-b34:compile
[INFO] |  +- .glassfish.hk2.external:javax.inject:jar:2.4.0-b34:compile
[INFO] |  \- .glassfish.hk2:hk2-locator:jar:2.4.0-b34:compile
[INFO] +- .glassfish.jersey.connectors:jersey-apache-connector:jar:2.22.2:compile
[INFO] +- .glassfish.jersey.security:oauth2-client:jar:2.22.2:compile
[INFO] |  \- .glassfish.jersey.media:jersey-media-json-jackson:jar:2.22.2:compile
[INFO] |     +- .glassfish.jersey.ext:jersey-entity-filtering:jar:2.22.2:compile
[INFO] |     +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.5.4:compile
[INFO] |     \- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.5.4:compile
[INFO] |        \- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.5.4:compile
[INFO] +- commons-io:commons-io:jar:2.4:compile
[INFO] +- .apachemons:commons-csv:jar:1.2:compile
[INFO] +- redis.clients:jedis:jar:2.9.0:compile
[INFO] |  \- .apachemons:commons-pool2:jar:2.4.2:compile
[INFO] +- net.snowflake:snowflake-jdbc:jar:3.13.21:compile
[INFO] +- net.snowflake:snowflake-ingest-sdk:jar:2.0.1:compile
[INFO] +- commons-cli:commons-cli:jar:1.4:compile
[INFO] +- com.sun.mail:javax.mail:jar:1.6.2:compile
[INFO] |  \- javax.activation:activation:jar:1.1:compile
[INFO] +- com.atlassian.jira:jira-rest-java-client-app:jar:5.2.2:compile
[INFO] |  +- com.atlassian.jira:jira-rest-java-client-core:jar:5.2.2:compile
[INFO] |  |  +- com.atlassian.jira:jira-rest-java-client-api:jar:5.2.2:compile
[INFO] |  |  |  \- com.atlassian.httpclient:atlassian-httpclient-api:jar:2.0.0:compile
[INFO] |  |  +- com.sun.jersey:jersey-client:jar:1.19:compile
[INFO] |  |  |  \- com.sun.jersey:jersey-core:jar:1.19:compile
[INFO] |  |  |     \- javax.ws.rs:jsr311-api:jar:1.1.1:compile
[INFO] |  |  +- com.sun.jersey:jersey-json:jar:1.19:compile
[INFO] |  |  |  +- .codehaus.jettison:jettison:jar:1.1:compile
[INFO] |  |  |  +- com.sun.xml.bind:jaxb-impl:jar:2.2.3-1:compile
[INFO] |  |  |  |  \- javax.xml.bind:jaxb-api:jar:2.2.2:compile
[INFO] |  |  |  |     \- javax.xml.stream:stax-api:jar:1.0-2:compile
[INFO] |  |  |  +- .codehaus.jackson:jackson-core-asl:jar:1.9.2:compile
[INFO] |  |  |  +- .codehaus.jackson:jackson-mapper-asl:jar:1.9.2:compile
[INFO] |  |  |  +- .codehaus.jackson:jackson-jaxrs:jar:1.9.2:compile
[INFO] |  |  |  \- .codehaus.jackson:jackson-xc:jar:1.9.2:compile
[INFO] |  |  +- com.atlassian.sal:sal-api:jar:3.0.7:compile
[INFO] |  |  +- com.atlassian.event:atlassian-event:jar:3.0.0:compile
[INFO] |  |  +- com.atlassian.httpclient:atlassian-httpclient-library:jar:2.0.0:compile
[INFO] |  |  |  +- .apache.httpcomponents:httpasyncclient-cache:jar:4.1.4:compile
[INFO] |  |  |  +- .apache.httpcomponents:httpclient-cache:jar:4.5.5:compile
[INFO] |  |  |  \- .apache.httpcomponents:httpmime:jar:4.5.5:compile
[INFO] |  |  \- io.atlassian.util.concurrent:atlassian-util-concurrent:jar:4.0.1:compile
[INFO] |  +- io.atlassian.fugue:fugue:jar:3.0.0:compile
[INFO] |  \- .slf4j:jcl-over-slf4j:jar:1.7.10:compile
[INFO] +- com.atlassian.fugue:fugue:jar:2.6.2:compile
[INFO] +- .slf4j:slf4j-api:jar:2.0.16:compile
[INFO] +- .slf4j:slf4j-simple:jar:2.0.16:compile
[INFO] +- .apache.logging.log4j:log4j-api:jar:2.24.3:compile
[INFO] +- .apache.logging.log4j:log4j-core:jar:2.24.3:compile
[INFO] \- .slf4j:slf4j-reload4j:jar:2.0.15:compile
[INFO]    \- ch.qos.reload4j:reload4j:jar:1.2.22:compile

EDIT2: added dependency:tree

发布评论

评论列表(0)

  1. 暂无评论