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

Class generated by Logback-tyler needs to be declared public? #6

Open
ceki opened this issue Dec 18, 2024 Discussed in #5 · 0 comments
Open

Class generated by Logback-tyler needs to be declared public? #6

ceki opened this issue Dec 18, 2024 Discussed in #5 · 0 comments
Labels
bug Something isn't working DONE

Comments

@ceki
Copy link
Member

ceki commented Dec 18, 2024

Discussed in #5

Originally posted by orpheusx December 14, 2024
@ceki I used the online generator to convert my logback.xml file to a TylerConfigurator class. It did not declare the class public and thus, it seems, didn't work. The stack trace looks like this:

Exception in thread "main" java.util.ServiceConfigurationError: ch.qos.logback.classic.spi.Configurator: com.enoughisasgoodasafeast.TylerConfigurator Unable to get public no-arg constructor
	at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:582)
	at java.base/java.util.ServiceLoader.getConstructor(ServiceLoader.java:675)
	at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1236)
	at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1269)
	at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1305)
	at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1387)
	at ch.qos.logback.classic.util.ClassicEnvUtil.loadFromServiceLoader(ClassicEnvUtil.java:50)
	at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:84)
	at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:66)
	at ch.qos.logback.classic.spi.LogbackServiceProvider.initializeLoggerContext(LogbackServiceProvider.java:52)
	at ch.qos.logback.classic.spi.LogbackServiceProvider.initialize(LogbackServiceProvider.java:41)
	at org.slf4j.LoggerFactory.bind(LoggerFactory.java:199)
	at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:186)
	at org.slf4j.LoggerFactory.getProvider(LoggerFactory.java:496)
	at org.slf4j.MDC.<clinit>(MDC.java:92)
	at com.enoughisasgoodasafeast.WebService.<clinit>(WebService.java:13)
Caused by: java.lang.NoSuchMethodException: com.enoughisasgoodasafeast.TylerConfigurator.<init>()
	at java.base/java.lang.Class.getConstructor0(Class.java:3833)
	at java.base/java.lang.Class.getConstructor(Class.java:2501)
	at java.base/java.util.ServiceLoader$1.run(ServiceLoader.java:662)
	at java.base/java.util.ServiceLoader$1.run(ServiceLoader.java:659)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:571)
	at java.base/java.util.ServiceLoader.getConstructor(ServiceLoader.java:670)
	... 14 more

I tried a few things to get past this before editing the generated com.enoughisasgoodasafeast.TylerConfigurator to make it a public class. This resolved the problem. The README only mentions setting up a provider-configuration for the service-provider mechanism. Is there any other configuration or library that needs to be done to enable the XML-less logging setup?

@ceki ceki added bug Something isn't working DONE labels Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working DONE
Projects
None yet
Development

No branches or pull requests

1 participant