tkowalcz / tjahzi

Java clients, log4j2 and logback appenders for Grafana Loki
MIT License
106 stars 18 forks source link

What is the problem? #110

Closed chenmrU closed 1 year ago

chenmrU commented 1 year ago

2023-05-09T02:22:12.094470240Z Exception in thread "main" java.lang.reflect.InvocationTargetException 2023-05-09T02:22:12.094513853Z at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 2023-05-09T02:22:12.094517686Z at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 2023-05-09T02:22:12.094520441Z at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 2023-05-09T02:22:12.094523018Z at java.lang.reflect.Method.invoke(Method.java:498) 2023-05-09T02:22:12.094525623Z at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) 2023-05-09T02:22:12.094528399Z at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) 2023-05-09T02:22:12.094530903Z at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) 2023-05-09T02:22:12.094596691Z at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) 2023-05-09T02:22:12.094682593Z Caused by: java.lang.NoSuchMethodError: pl.tkowalcz.tjahzi.log4j2.LokiAppenderBuilder.getPropertyArray()[Lorg/apache/logging/log4j/core/config/Property; 2023-05-09T02:22:12.094689409Z at pl.tkowalcz.tjahzi.log4j2.LokiAppenderBuilder.build(LokiAppenderBuilder.java:154) 2023-05-09T02:22:12.094697614Z at pl.tkowalcz.tjahzi.log4j2.LokiAppenderBuilder.build(LokiAppenderBuilder.java:31) 2023-05-09T02:22:12.094733360Z at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:122) 2023-05-09T02:22:12.094740494Z at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:958) 2023-05-09T02:22:12.094743538Z at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:898) 2023-05-09T02:22:12.094781600Z at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:890) 2023-05-09T02:22:12.094787580Z at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:513) 2023-05-09T02:22:12.094790485Z at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:237) 2023-05-09T02:22:12.094797435Z at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:249)

tkowalcz commented 1 year ago

Hello,

log4j2 version that you have on classpath is incompatible with the version Tjahzi was compiled against. Tjahzi was compiled against 2.17.2 and method getPropertyArray is present in log4j2 since year 2018 (since version 2.12.2 of log4j2 but I might be wrong about exact one). Please check which version of log4j2 is in use and let me know if you think it is the correct one.

Longer explanation of the error: This error indicates that at runtime class LokiAppenderBuilder did not have a method getPropertyArray. That metod is part of log4j SPI and defined in class AbstractFilterable which LokiAppenderBuilder indirectly extends.

chenmrU commented 1 year ago

I have changed the version of Log4j to 2.17.2 , but the same error still appears.

tkowalcz commented 1 year ago

I'm sorry but I have no other ideas. Definitely there is a mismatch between compile time and runtime version of the class. Maybe you can share the class path? You could also run this code when you app starts to verify where AbstractFilterable comes from:

System.out.println(
    AbstractFilterable.class.getProtectionDomain().getCodeSource().getLocation().getPath()
);
tkowalcz commented 1 year ago

Closing due to inactivity. Feel free to re-open if you need more help.