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

Disable BTrace debug logging #558

Closed
kushal-ti opened this issue Jun 29, 2022 · 4 comments
Closed

Disable BTrace debug logging #558

kushal-ti opened this issue Jun 29, 2022 · 4 comments

Comments

@kushal-ti
Copy link

I'm frequently getting these messages on a springboot project

btrace WARNING: java.lang.IllegalAccessException: class org.openjdk.btrace.instr.ClassInfo cannot access a member of class java.lang.ClassLoader (in module java.base) with modifiers "static"
java.lang.IllegalAccessException: class org.openjdk.btrace.instr.ClassInfo cannot access a member of class java.lang.ClassLoader (in module java.base) with modifiers "static"
        at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:392)
        at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:674)
        at java.base/java.lang.reflect.Method.invoke(Method.java:560)
        at org.openjdk.btrace.instr.ClassInfo.isBootstrap(ClassInfo.java:113)
        at org.openjdk.btrace.instr.ClassInfo.inferClassLoader(ClassInfo.java:86)
        at org.openjdk.btrace.instr.ClassInfo.loadExternalClass(ClassInfo.java:202)
        at org.openjdk.btrace.instr.ClassInfo.<init>(ClassInfo.java:77)
        at org.openjdk.btrace.instr.ClassCache.get(ClassCache.java:66)
        at org.openjdk.btrace.instr.ClassCache.get(ClassCache.java:58)
        at org.openjdk.btrace.instr.InstrumentUtils.collectHierarchyClosure(InstrumentUtils.java:78)
        at org.openjdk.btrace.instr.InstrumentUtils.isAssignable(InstrumentUtils.java:120)
        at org.openjdk.btrace.instr.MethodInstrumentor.validateArguments(MethodInstrumentor.java:383)
        at org.openjdk.btrace.instr.Instrumentor$5.onCatch(Instrumentor.java:696)
        at org.openjdk.btrace.instr.CatchInstrumentor.visitLabel(CatchInstrumentor.java:62)
        at org.openjdk.btrace.libs.org.objectweb.asm.MethodVisitor.visitLabel(MethodVisitor.java:489)
        at org.openjdk.btrace.libs.org.objectweb.asm.Label.accept(Label.java:358)
        at org.openjdk.btrace.libs.org.objectweb.asm.ClassReader.readCode(ClassReader.java:2057)
        at org.openjdk.btrace.libs.org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1514)
        at org.openjdk.btrace.libs.org.objectweb.asm.ClassReader.accept(ClassReader.java:744)
        at org.openjdk.btrace.instr.BTraceClassReader.accept(BTraceClassReader.java:155)
        at org.openjdk.btrace.libs.org.objectweb.asm.ClassReader.accept(ClassReader.java:424)
        at org.openjdk.btrace.instr.BTraceClassReader.accept(BTraceClassReader.java:164)
        at org.openjdk.btrace.instr.InstrumentUtils.accept(InstrumentUtils.java:179)
        at org.openjdk.btrace.instr.InstrumentUtils.accept(InstrumentUtils.java:173)
        at org.openjdk.btrace.instr.BTraceClassWriter.instrument(BTraceClassWriter.java:99)
        at org.openjdk.btrace.instr.BTraceTransformer.transform(BTraceTransformer.java:158)
        at java.instrument/java.lang.instrument.ClassFileTransformer.transform(ClassFileTransformer.java:244)
        at java.instrument/sun.instrument.TransformerManager.transform(TransformerManager.java:188)
        at java.instrument/sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:541)
        at java.base/java.lang.ClassLoader.defineClass1(Native Method)
        at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1012)
        at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
        at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:524)
        at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:427)
        at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:421)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:712)
        at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:420)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
        at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:151)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:467)
        at org.springframework.util.ClassUtils.forName(ClassUtils.java:284)
        at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:469)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1607)
        at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1534)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:704)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:674)
        at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1670)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:570)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:542)
        at org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration$DispatcherServletRegistrationCondition.checkServletRegistration(DispatcherServletAutoConfiguration.java:187)
        at org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration$DispatcherServletRegistrationCondition.getMatchOutcome(DispatcherServletAutoConfiguration.java:167)
        at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47)
        at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108)
        at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:226)
        at org.springframework.context.annotation.ConfigurationClassParser.processMemberClasses(ConfigurationClassParser.java:372)
        at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:272)
        at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:250)
        at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:600)
        at org.springframework.context.annotation.ConfigurationClassParser.access$800(ConfigurationClassParser.java:111)
        at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGroupingHandler.lambda$processGroupImports$1(ConfigurationClassParser.java:812)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
        at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGroupingHandler.processGroupImports(ConfigurationClassParser.java:809)
        at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorHandler.process(ConfigurationClassParser.java:780)
        at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:193)
        at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:331)
        at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:247)
        at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:311)
        at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:112)
        at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:746)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:564)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732)
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:414)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:302)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292)
        at in.co.codenation.cap.cg_finders_pipeline.CgFindersPipelineApplication.main(CgFindersPipelineApplication.java:53)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)

I have tried to modify the class name pattern to ensure btrace doesn't try to instrument these classes but that hasn't worked
However, the warning seems harmless, and it is not affecting the working of the rest of my application, so i would just like to disable them altogether.

Going through the source code, i suspect this line is printing the warnings. Since the class is named Debug Support, is there any way to disable it ?

@jbachorik
Copy link
Collaborator

Can you share what Java version is running here?
The exception is pretty weird as the Method instance is made accessible a few lines before and this failure should not really happen.

As for disabling - BTrace is using very unsophisticated logging and all warnings will be printed out, no way do disable them :(

In a near future I might attempt to use SimpleLogger instead and that should provide more configuration knobs for logging.

@kushal-ti
Copy link
Author

I'm on openJDK 17, running on ubuntu 20.04

@jbachorik
Copy link
Collaborator

With #562 you should be able to configure the SLF4J SimpleLogger to log at ERROR level only, leaving out any warnings.

Out of curiosity - can you share the BTrace script?

@github-actions
Copy link

github-actions bot commented Sep 8, 2022

Stale issue message

@jbachorik jbachorik added this to the 2.3.0 milestone Nov 10, 2022
@jbachorik jbachorik modified the milestones: 2.3.0, 2.2.3 Dec 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants