Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to instantiate type org.fusesource.jansi.WindowsAnsiOutputStream #455

Closed
guillermocalvo opened this issue Jul 15, 2021 · 1 comment · Fixed by #456
Closed

Failed to instantiate type org.fusesource.jansi.WindowsAnsiOutputStream #455

guillermocalvo opened this issue Jul 15, 2021 · 1 comment · Fixed by #456

Comments

@guillermocalvo
Copy link
Contributor

I'm following Micronaut GCP guide and bumped into this problem:

Failed to instantiate type org.fusesource.jansi.WindowsAnsiOutputStream.

Steps to Reproduce

  1. mn create-app foobar
  2. Add new Gradle dependency: implementation("io.micronaut.gcp:micronaut-gcp-logging")
  3. Replace src/main/resources/logback.xml with:
<configuration>
    <include resource="io/micronaut/gcp/logging/logback-json-appender.xml" /> 
    <root level="INFO">
        <appender-ref ref="CONSOLE_JSON" /> 
    </root>
</configuration>
  1. ./gradlew run on Windows

Expected Behaviour

I was expecting that withJansi was not enabled by default, at least on Windows.

I looked into included file io/micronaut/gcp/logging/logback-json-appender.xml and discovered that an appender STDOUT is being defined inside it:

    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <withJansi>true</withJansi>
        <encoder>
            <pattern>%cyan(%d{HH:mm:ss.SSS}) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n </pattern>
        </encoder>
    </appender>

I just need appender CONSOLE_JSON (which is defined later on in that file) but since both of them are there, I get an error when I try to run the application on Windows. In fact, I'm not exactly sure whether STDOUT needs to be defined there at all.

So if there's no actual need I think that appender should be removed from the configuration file. In case it has to be there for some reason, I'd expect this withJansi flag to be configurable (something like <withJansi>${stdout.withJansi:true}</withJansi> would be enough).

Actual Behaviour

Stacktrace:

-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
-INFO in ch.qos.logback.core.ConsoleAppender[STDOUT] - Enabling JANSI WindowsAnsiOutputStream for the console.
-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - Failed to create WindowsAnsiOutputStream. Falling back on the default stream. ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type org.fusesource.jansi.WindowsAnsiOutputStream
        at ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type org.fusesource.jansi.WindowsAnsiOutputStream
        at      at ch.qos.logback.core.util.OptionHelper.instantiateByClassNameAndParameter(OptionHelper.java:69)
        at      at ch.qos.logback.core.util.OptionHelper.instantiateByClassNameAndParameter(OptionHelper.java:40)
        at      at ch.qos.logback.core.ConsoleAppender.getTargetStreamForWindows(ConsoleAppender.java:88)
        at      at ch.qos.logback.core.ConsoleAppender.start(ConsoleAppender.java:79)
        at      at ch.qos.logback.core.joran.action.AppenderAction.end(AppenderAction.java:90)
        at      at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:309)
        at      at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:193)
        at      at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:179)
        at      at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:62)
        at      at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:165)
        at      at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:152)
        at      at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:110)
        at      at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:53)
        at      at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:75)
        at      at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:150)
        at      at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:84)
        at      at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)
        at      at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
        at      at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
        at      at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:412)
        at      at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:357)
        at      at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:383)
        at      at io.micronaut.runtime.Micronaut.<clinit>(Micronaut.java:49)
        at      at foobar.Application.main(Application.java:8)
Caused by: java.lang.ClassNotFoundException: org.fusesource.jansi.WindowsAnsiOutputStream
        at      at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
        at      at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at      at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
        at      at ch.qos.logback.core.util.OptionHelper.instantiateByClassNameAndParameter(OptionHelper.java:56)
        at      ... 23 common frames omitted
17:13:48,151 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
17:13:48,151 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [CONSOLE_JSON]
17:13:48,255 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to INFO
17:13:48,255 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [CONSOLE_JSON] to Logger[ROOT]
17:13:48,256 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.

Environment Information

  • Operating System: Windows 10
  • Micronaut Version: 2.5.8
  • JDK Version: openjdk version "11.0.11" 2021-04-20

Example Application

@guillermocalvo
Copy link
Contributor Author

Related issue: micronaut-projects/micronaut-core#1521

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant