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

Compile error with logback.groovy after updating to Micronaut 3.2.0 #6691

Closed
puneetbehl opened this issue Dec 27, 2021 · 1 comment · Fixed by #6692
Closed

Compile error with logback.groovy after updating to Micronaut 3.2.0 #6691

puneetbehl opened this issue Dec 27, 2021 · 1 comment · Fixed by #6692
Assignees
Labels
status: pr submitted A pull request has been submitted for the issue

Comments

@puneetbehl
Copy link
Contributor

Expected Behavior

The logback.groovy file should not be loaded too early during the build process and the code should compile without any errors.

Actual Behaviour

It appears that the LoggerContext is trying to instantiate during the compilation phase which results in the following error:

Failed to instantiate [ch.qos.logback.classic.LoggerContext]
Reported exception:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script1.groovy: 1: unable to resolve class grails.util.BuildSettings
 @ line 1, column 1.
   import grails.util.BuildSettings
   ^

Script1.groovy: 2: unable to resolve class grails.util.Environment
 @ line 2, column 1.
   import grails.util.Environment
   ^

Script1.groovy: 3: unable to resolve class org.springframework.boot.logging.logback.ColorConverter
 @ line 3, column 1.
   import org.springframework.boot.logging.logback.ColorConverter
   ^

Script1.groovy: 4: unable to resolve class org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter
 @ line 4, column 1.
   import org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter
   ^

Script1.groovy: -1: unable to resolve class ch.qos.logback.classic.encoder.PatternLayoutEncoder
 @ line -1, column -1.
Script1.groovy: -1: unable to resolve class ch.qos.logback.classic.Level
 @ line -1, column -1.
Script1.groovy: -1: unable to resolve class ch.qos.logback.classic.Level
 @ line -1, column -1.
Script1.groovy: -1: unable to resolve class ch.qos.logback.classic.Level
 @ line -1, column -1.
Script1.groovy: -1: unable to resolve class ch.qos.logback.classic.Level
 @ line -1, column -1.
Script1.groovy: -1: unable to resolve class ch.qos.logback.classic.Level
 @ line -1, column -1.
Script1.groovy: -1: unable to resolve class ch.qos.logback.classic.Level
 @ line -1, column -1.
Script1.groovy: -1: unable to resolve class ch.qos.logback.classic.Level
 @ line -1, column -1.
Script1.groovy: -1: unable to resolve class ch.qos.logback.classic.Level
 @ line -1, column -1.
13 errors

        at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:295)
        at org.codehaus.groovy.control.CompilationUnit$ISourceUnitOperation.doPhaseOperation(CompilationUnit.java:914)
        at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:627)
        at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:389)
        at groovy.lang.GroovyClassLoader.lambda$parseClass$3(GroovyClassLoader.java:332)
        at org.codehaus.groovy.runtime.memoize.StampedCommonCache.compute(StampedCommonCache.java:163)
        at org.codehaus.groovy.runtime.memoize.StampedCommonCache.getAndPut(StampedCommonCache.java:154)
        at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:330)
        at groovy.lang.GroovyShell.parseClass(GroovyShell.java:526)
        at groovy.lang.GroovyShell.parse(GroovyShell.java:538)
        at groovy.lang.GroovyShell.parse(GroovyShell.java:570)
        at groovy.lang.GroovyShell.parse(GroovyShell.java:565)
        at groovy.lang.GroovyShell$parse.call(Unknown Source)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:139)
        at ch.qos.logback.classic.gaffer.GafferConfigurator.run(GafferConfigurator.groovy:71)
        at ch.qos.logback.classic.gaffer.GafferConfigurator$run.callCurrent(Unknown Source)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:171)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:185)
        at ch.qos.logback.classic.gaffer.GafferConfigurator.run(GafferConfigurator.groovy:44)
        at ch.qos.logback.classic.gaffer.GafferUtil.runGafferConfiguratorOn(GafferUtil.java:43)
        at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:67)
        at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:150)
        at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:84)
        at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)
        at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
        at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
        at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:417)
        at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:362)
        at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:388)
        at io.micronaut.core.io.service.SoftServiceLoader.<clinit>(SoftServiceLoader.java:65)
        at io.micronaut.ast.groovy.TypeElementVisitorStart.visit(TypeElementVisitorStart.groovy:61)
        at org.codehaus.groovy.transform.ASTTransformationVisitor.lambda$addPhaseOperationsForGlobalTransforms$4(ASTTransformationVisitor.java:337)
        at org.codehaus.groovy.control.CompilationUnit$ISourceUnitOperation.doPhaseOperation(CompilationUnit.java:901)
        at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:671)
        at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:635)
        at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:610)
        at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:262)
        at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:64)
        at org.gradle.api.internal.tasks.compile.GroovyCompilerFactory$DaemonSideCompiler.execute(GroovyCompilerFactory.java:97)
        at org.gradle.api.internal.tasks.compile.GroovyCompilerFactory$DaemonSideCompiler.execute(GroovyCompilerFactory.java:76)
        at org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerWorkAction.execute(AbstractDaemonCompiler.java:135)
        at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
        at org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:49)
        at org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:43)
        at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:97)
        at org.gradle.workers.internal.AbstractClassLoaderWorker.executeInClassLoader(AbstractClassLoaderWorker.java:43)
        at org.gradle.workers.internal.IsolatedClassloaderWorker.run(IsolatedClassloaderWorker.java:49)
        at org.gradle.workers.internal.IsolatedClassloaderWorker.run(IsolatedClassloaderWorker.java:30)
        at org.gradle.workers.internal.WorkerDaemonServer.run(WorkerDaemonServer.java:85)
        at org.gradle.workers.internal.WorkerDaemonServer.run(WorkerDaemonServer.java:55)
        at org.gradle.process.internal.worker.request.WorkerAction$1.call(WorkerAction.java:138)
        at org.gradle.process.internal.worker.child.WorkerLogEventListener.withWorkerLoggingProtocol(WorkerLogEventListener.java:41)
        at org.gradle.process.internal.worker.request.WorkerAction.run(WorkerAction.java:135)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
        at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182)
        at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164)

Steps To Reproduce

Please check grails/grails-core#12291 for more information on how to reproduce it.

Environment Information

JDK Version: openjdk version "11.0.10" 2021-01-19
OS: macOS Monterey
Grails: 5.1.1
Micronaut: 3.2.0

Example Application

No response

Version

3.2.0

@puneetbehl
Copy link
Contributor Author

After looking into the Changelog, I think this happening because of initializing Logger in SoftServiceLoader.

@puneetbehl puneetbehl self-assigned this Dec 27, 2021
puneetbehl added a commit that referenced this issue Dec 27, 2021
The problem with the current implementation is that in Grails® framework applicatio (version 5.1.1), the compilation fails because the class `SoftServiceLoader` will try to initialize LOGGER during compilation and result in `MultipleCompilationErrorsException`. Please check grails/grails-core#12291 for more information. In this commit, we are using `java.util.function.Supplier` instead of directly initializing the LOGGER which will make sure it is initialized after compilation.

Fixes #6691 and so grails/grails-core#12291
@puneetbehl puneetbehl added the status: pr submitted A pull request has been submitted for the issue label Dec 28, 2021
jameskleeh pushed a commit that referenced this issue Jan 3, 2022
…ER (#6692)

The problem with the current implementation is that in Grails® framework applicatio (version 5.1.1), the compilation fails because the class `SoftServiceLoader` will try to initialize LOGGER during compilation and result in `MultipleCompilationErrorsException`. Please check grails/grails-core#12291 for more information. In this commit, we are using `java.util.function.Supplier` instead of directly initializing the LOGGER which will make sure it is initialized after compilation.

Fixes #6691 and so grails/grails-core#12291
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: pr submitted A pull request has been submitted for the issue
Projects
None yet
1 participant