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

AOT suggests Logback 1.3, but using greater than 1.2 breaks build #148

Closed
sgammon opened this issue Nov 4, 2022 · 2 comments
Closed

AOT suggests Logback 1.3, but using greater than 1.2 breaks build #148

sgammon opened this issue Nov 4, 2022 · 2 comments
Milestone

Comments

@sgammon
Copy link

sgammon commented Nov 4, 2022

Expected Behavior

In my version catalog:

[versions]
logback = "1.2.11"

[libraries]
logback_base = { group = "ch.qos.logback", name = "logback", version.ref = "logback" }
logback_core = { group = "ch.qos.logback", name = "logback-core", version.ref = "logback" }
logback = { group = "ch.qos.logback", name = "logback-classic", version.ref = "logback" }

In my build.gradle.kts:

micronaut {
  aot {
    configFile.set(file("${rootProject.projectDir}/gradle/aot.properties"))
  }
}

dependencies {
  runtimeOnly(framework.logback)
}

In my gradle/aot.properties:

logback.xml.to.java.enabled = true

I expect AOT to compile the config, according to settings.

Actual Behaviour

AOT lets me know that logback must be north of 1.3:

Caused by: java.lang.IllegalStateException: The logback.xml conversion feature requires logback 1.3 on the AOT optimizer classpath.
        at io.micronaut.aot.std.sourcegen.LogbackConfigurationSourceGenerator.generate(LogbackConfigurationSourceGenerator.java:55)
        at io.micronaut.aot.core.codegen.AbstractSingleClassFileGenerator.generate(AbstractSingleClassFileGenerator.java:35)
        at io.micronaut.aot.std.sourcegen.LogbackConfigurationSourceGenerator.generate(LogbackConfigurationSourceGenerator.java:87)
        at io.micronaut.aot.core.codegen.ApplicationContextConfigurerGenerator.generate(ApplicationContextConfigurerGenerator.java:66)
        at io.micronaut.aot.MicronautAotOptimizer$Runner.execute(MicronautAotOptimizer.java:343)
        at io.micronaut.aot.MicronautAotOptimizer.execute(MicronautAotOptimizer.java:202)
        ... 15 more

So, I modify the version catalog to use Logback at 1.3.0, or 1.3.4 (the first 1.3.x or latest), and in either case, I get the exception:

Caused by: java.lang.IllegalAccessError: class io.micronaut.aot.std.sourcegen.Logback13GeneratorHelper tried to access field ch.qos.logback.core.joran.event.SaxEventRecorder.saxEventList (io.micronaut.aot.std.sourcegen.Logback13GeneratorHelper and ch.qos.logback.core.joran.event.SaxEventRecorder are in unnamed module of loader java.net.URLClassLoader @6fadae5d)
        at io.micronaut.aot.std.sourcegen.Logback13GeneratorHelper.configureMethod(Logback13GeneratorHelper.java:133)
        at io.micronaut.aot.std.sourcegen.LogbackConfigurationSourceGenerator.generate(LogbackConfigurationSourceGenerator.java:61)
        at io.micronaut.aot.core.codegen.AbstractSingleClassFileGenerator.generate(AbstractSingleClassFileGenerator.java:35)
        at io.micronaut.aot.std.sourcegen.LogbackConfigurationSourceGenerator.generate(LogbackConfigurationSourceGenerator.java:87)
        at io.micronaut.aot.core.codegen.ApplicationContextConfigurerGenerator.generate(ApplicationContextConfigurerGenerator.java:66)
        at io.micronaut.aot.MicronautAotOptimizer$Runner.execute(MicronautAotOptimizer.java:343)
        at io.micronaut.aot.MicronautAotOptimizer.execute(MicronautAotOptimizer.java:202)
        ... 15 more

If I use 1.3.4 or 1.4.4 without Logback config generation, I get:

Caused by: java.lang.RuntimeException: Compilation errors:
File unknown, line: -1, Bad service configuration file, or exception thrown while constructing Processor object: javax.annotation.processing.Processor: Provider io.micronaut.annotation.processing.TypeElementVisitorProcessor could not be instantiated

        at io.micronaut.aot.MicronautAotOptimizer.throwCompilationError(MicronautAotOptimizer.java:240)
        at io.micronaut.aot.MicronautAotOptimizer.compileGeneratedSources(MicronautAotOptimizer.java:140)
        at io.micronaut.aot.MicronautAotOptimizer.access$200(MicronautAotOptimizer.java:98)
        at io.micronaut.aot.MicronautAotOptimizer$Runner.execute(MicronautAotOptimizer.java:344)
        at io.micronaut.aot.MicronautAotOptimizer.execute(MicronautAotOptimizer.java:202)
        ... 15 more

This forces me to use 1.2.11 (which works fine), as far as I can tell it is the only option usable with AOT enabled.

Steps To Reproduce

  1. With Micronaut at latest
  2. Use above configuration and Logback versions
  3. Enable AOT with Logback config generation
  4. Observe exceptions

Environment Information

  • Operating System: macOS Ventura
  • JDK Version: 17

Example Application

No response

Version

3.7.3

@sgammon
Copy link
Author

sgammon commented Nov 4, 2022

i realize logback config gen is experimental, but the AOT plugin breaks the regular build even if Logback config gen is shut off, so long as Logback > 1.2 is installed (so far as I can tell).

@melix melix added this to the 2.0.0 milestone Mar 3, 2023
@melix
Copy link
Collaborator

melix commented Mar 3, 2023

Test resources 2.0.0 will work with Logback 1.4+

@melix melix closed this as completed Mar 3, 2023
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

No branches or pull requests

2 participants