mock-server / mockserver

MockServer enables easy mocking of any system you integrate with via HTTP or HTTPS with clients written in Java, JavaScript and Ruby. MockServer also includes a proxy that introspects all proxied traffic including encrypted SSL traffic and supports Port Forwarding, Web Proxying (i.e. HTTP proxy), HTTPS Tunneling Proxying (using HTTP CONNECT) and SOCKS Proxying (i.e. dynamic port forwarding).
http://mock-server.com
Apache License 2.0
4.61k stars 1.08k forks source link

Can't load log handler "org.mockserver.logging.StandardOutConsoleHandler" Exception #1634

Open josephbaby92 opened 1 year ago

josephbaby92 commented 1 year ago

Describe the issue Getting below exception will trying to start mockserver through java api from spring boot application

Can't load log handler "org.mockserver.logging.StandardOutConsoleHandler" java.lang.ClassNotFoundException: org.mockserver.logging.StandardOutConsoleHandler java.lang.ClassNotFoundException: org.mockserver.logging.StandardOutConsoleHandler at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) at java.logging/java.util.logging.LogManager.createLoggerHandlers(LogManager.java:1005) at java.logging/java.util.logging.LogManager$4.run(LogManager.java:975) at java.logging/java.util.logging.LogManager$4.run(LogManager.java:971) at java.base/java.security.AccessController.doPrivileged(AccessController.java:318) at java.logging/java.util.logging.LogManager.loadLoggerHandlers(LogManager.java:971) at java.logging/java.util.logging.LogManager.initializeGlobalHandlers(LogManager.java:2424) at java.logging/java.util.logging.LogManager$RootLogger.accessCheckedHandlers(LogManager.java:2526) at java.logging/java.util.logging.Logger.getHandlers(Logger.java:2090) at java.logging/java.util.logging.Logger.log(Logger.java:977) at java.logging/java.util.logging.Logger.doLog(Logger.java:1007) at java.logging/java.util.logging.Logger.logp(Logger.java:1173) at org.apache.juli.logging.DirectJDKLog.log(DirectJDKLog.java:173) at org.apache.juli.logging.DirectJDKLog.info(DirectJDKLog.java:116) at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:611) at org.apache.catalina.connector.Connector.startInternal(Connector.java:1073) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardService.addConnector(StandardService.java:234) at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.addPreviouslyRemovedConnectors(TomcatWebServer.java:282) at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:213) at org.springframework.boot.web.servlet.context.WebServerStartStopLifecycle.start(WebServerStartStopLifecycle.java:43) at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178) at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54) at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356) at java.base/java.lang.Iterable.forEach(Iterable.java:75) at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155) at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123) at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:935) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:731) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292) at com.bt.ew.mockservice.app.Application.main(Application.java:12) 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:65)

What you are trying to do Trying to initialize mock server from spring boot application to mock endpoints for testing purpose

MockServer version 5.14.0

To Reproduce Steps to reproduce the issue: initialize mock server through java api from spring boot application.

MockServer Log ConfigurationProperties.disableLogging(true); ConfigurationProperties.logLevel("OFF");

Agembin1 commented 1 year ago

Any traction on this? I am having the same issue for months now.

Can't load log handler "org.mockserver.logging.StandardOutConsoleHandler" 2023-04-18 15:18:37 java.lang.ClassNotFoundException: org.mockserver.logging.StandardOutConsoleHandler 2023-04-18 15:18:37 java.lang.ClassNotFoundException: org.mockserver.logging.StandardOutConsoleHandler 2023-04-18 15:18:37 at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) 2023-04-18 15:18:37 at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) 2023-04-18 15:18:37 at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) 2023-04-18 15:18:37 at java.logging/java.util.logging.LogManager.createLoggerHandlers(LogManager.java:1000) 2023-04-18 15:18:37 at java.logging/java.util.logging.LogManager$4.run(LogManager.java:970) 2023-04-18 15:18:37 at java.logging/java.util.logging.LogManager$4.run(LogManager.java:966)

Agembin1 commented 1 year ago

It appears if you want to set this:

ConfigurationProperties.logLevel("INFO");

it needs to be in the same file as this:

String loggingConfiguration = "" + "handlers=org.mockserver.logging.StandardOutConsoleHandler\n"

InputStream lcbais = new ByteArrayInputStream(loggingConfiguration.getBytes(StandardCharsets.UTF_8));

it cannot be set with other configs in another file somewhere else -- like with these guys for instance:

    ConfigurationProperties.enableCORSForAPI(true);
    ConfigurationProperties.enableCORSForAllResponses(true);
    ConfigurationProperties.corsAllowCredentials(true);

That was the issue for me

Agembin1 commented 1 year ago

nope its back when i deploy :(