Closed kle-pra closed 1 year ago
Caused by: java.lang.Exception: java.lang.NoSuchMethodError: 'org.slf4j.spi.LoggingEventBuilder org.slf4j.Logger.atInfo()'
at com.sun.ejb.containers.interceptors.CallbackInvocationContext.proceed(CallbackInvocationContext.java:185)
at org.jboss.weld.module.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:81)
at org.jboss.weld.module.ejb.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:52)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:577)
at com.sun.ejb.containers.interceptors.CallbackInterceptor.intercept(InterceptorManager.java:975)
at com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:47)
at com.sun.ejb.containers.interceptors.CallbackInvocationContext.proceed(CallbackInvocationContext.java:181)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:136)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.init(SystemInterceptorProxy.java:98)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:577)
at com.sun.ejb.containers.interceptors.CallbackInterceptor.intercept(InterceptorManager.java:975)
at com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:47)
at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:391)
at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:354)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:1793)
at com.sun.ejb.containers.AbstractSingletonContainer.createSingletonEJB(AbstractSingletonContainer.java:441)
java.exe
Process ID: 38040
Command Line: "C:\Program Files\Java\jdk-18.0.1.1\bin\java.exe" -cp C:\Users\tomaz\appserver\glassfish-6.2.5\glassfish6\glassfish\modules\glassfish.jar -Djava.awt.headless=true
-Djdk.corba.allowOutputStreamSubclass=true -Djdk.tls.rejectClientInitiatedRenegotiation=true -Djavax.xml.accessExternalSchema=all -Djavax.management.builder.initial=com.sun.enterprise.v3.admin.AppServerMBeanServerBuilder -XX:+UnlockDiagnosticVMOptions
-Djava.security.policy=C:\Users\tomaz\appserver\glassfish-6.2.5\glassfish6\glassfish\domains\domain1/config/server.policy -Djava.security.auth.login.config=C:\Users\tomaz\appserver\glassfish-6.2.5\glassfish6\glassfish\domains\domain1/config/login.conf
-Dcom.sun.enterprise.security.httpsOutboundKeyAlias=s1as -Xmx512m
-Djavax.net.ssl.keyStore=C:\Users\tomaz\appserver\glassfish-6.2.5\glassfish6\glassfish\domains\domain1/config/keystore.jks
-Djavax.net.ssl.trustStore=C:\Users\tomaz\appserver\glassfish-6.2.5\glassfish6\glassfish\domains\domain1/config/cacerts.jks -Djdbc.drivers=org.apache.derby.jdbc.ClientDriver -DANTLR_USE_DIRECT_CLASS_LOADING=true Dcom.sun.enterprise.config.config_environment_factory_class=com.sun.enterprise.config.serverbeans.AppserverConfigEnvironmentFactory
-Dorg.glassfish.additionalOSGiBundlesToStart=org.apache.felix.shell,org.apache.felix.gogo.runtime,org.apache.felix.gogo.shell,org.apache.felix.gogo.command,org.apache.felix.shell.remote,org.apache.felix.fileinstall -Dosgi.shell.telnet.port=6666 -Dosgi.shell.telnet.maxconn=1 -Dosgi.shell.telnet.ip=127.0.0.1
-Dgosh.args=--nointeractive -Dfelix.fileinstall.dir=C:\Users\tomaz\appserver\glassfish-6.2.5\glassfish6\glassfish/modules/autostart/ -Dfelix.fileinstall.poll=5000
-Dfelix.fileinstall.log.level=2 -Dfelix.fileinstall.bundles.new.start=true
-Dfelix.fileinstall.bundles.startTransient=true -Dfelix.fileinstall.disableConfigSave=false
-Dorg.glassfish.gmbal.no.multipleUpperBoundsException=true -Dcom.ctc.wstx.returnNullForDefaultNamespace=true -XX:NewRatio=2
-Xbootclasspath/a:C:\Users\tomaz\appserver\glassfish-6.2.5\glassfish6\glassfish/lib/grizzly-npn-api.jar --add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED --add-opens=java.base/sun.net.www.protocol.jrt=ALL-UNNAMED
--add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED --add-opens=java.naming/javax.naming.spi=ALL-UNNAMED --add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED
-javaagent:C:\Users\tomaz\appserver\glassfish-6.2.5\glassfish6\glassfish\lib\monitor\flashlight-agent.jar
-Dcom.sun.aas.derbyRoot=C:\Users\tomaz\appserver\glassfish-6.2.5\glassfish6\javadb
-Dcom.sun.aas.instanceRoot=C:\Users\tomaz\appserver\glassfish-6.2.5\glassfish6\glassfish\domains\domain1
-Dcom.sun.aas.installRoot=C:\Users\tomaz\appserver\glassfish-6.2.5\glassfish6\glassfish "
-Dcom.sun.aas.javaRoot=C:\Program Files\Java\jdk-18.0.1.1" com.sun.enterprise.glassfish.bootstrap.ASMain
--domain domain1 --domaindir C:\Users\tomaz\appserver\glassfish-6.2.5\glassfish6\glassfish\domains\domain1
mvn dependency:tree
[INFO] +- com.ibm.informix:jdbc:jar:4.50.8:compile
[INFO] | \- org.mongodb:bson:jar:3.8.0:compile
[INFO] +- jakarta.platform:jakarta.jakartaee-api:jar:9.1.0:provided
[INFO] +- jakarta.ws.rs:jakarta.ws.rs-api:jar:3.1.0:provided
[INFO] +- jakarta.ejb:jakarta.ejb-api:jar:4.0.1:provided
[INFO] | \- jakarta.transaction:jakarta.transaction-api:jar:2.0.0:provided
[INFO] +- org.slf4j:slf4j-api:jar:2.0.3:compile
[INFO] +- org.projectlombok:lombok:jar:1.18.24:provided
[INFO] +- org.apache.poi:poi-ooxml:jar:5.2.3:compile
[INFO] | +- org.apache.poi:poi:jar:5.2.3:compile
[INFO] | | +- commons-codec:commons-codec:jar:1.15:compile
[INFO] | | +- org.apache.commons:commons-math3:jar:3.6.1:compile
[INFO] | | \- com.zaxxer:SparseBitSet:jar:1.2:compile
[INFO] | +- org.apache.poi:poi-ooxml-lite:jar:5.2.3:compile
[INFO] | +- org.apache.xmlbeans:xmlbeans:jar:5.1.1:compile
[INFO] | | \- xml-apis:xml-apis:jar:1.4.01:compile
[INFO] | +- org.apache.commons:commons-compress:jar:1.21:compile
[INFO] | +- commons-io:commons-io:jar:2.11.0:compile
[INFO] | +- com.github.virtuald:curvesapi:jar:1.07:compile
[INFO] | +- org.apache.logging.log4j:log4j-api:jar:2.18.0:compile
[INFO] | \- org.apache.commons:commons-collections4:jar:4.4:compile
[INFO] +- io.prometheus:simpleclient_servlet:jar:0.16.0:compile
[INFO] | +- io.prometheus:simpleclient:jar:0.16.0:compile
[INFO] | | +- io.prometheus:simpleclient_tracer_otel:jar:0.16.0:compile
[INFO] | | | \- io.prometheus:simpleclient_tracer_common:jar:0.16.0:compile
[INFO] | | \- io.prometheus:simpleclient_tracer_otel_agent:jar:0.16.0:compile
[INFO] | +- io.prometheus:simpleclient_common:jar:0.16.0:compile
[INFO] | \- io.prometheus:simpleclient_servlet_common:jar:0.16.0:compile
[INFO] +- com.typesafe:config:jar:1.4.2:compile
[INFO] +- io.sentry:sentry:jar:6.5.0:compile
[INFO] +- org.junit.jupiter:junit-jupiter:jar:5.9.1:test
[INFO] | +- org.junit.jupiter:junit-jupiter-api:jar:5.9.1:test
[INFO] | | +- org.opentest4j:opentest4j:jar:1.2.0:test
[INFO] | | +- org.junit.platform:junit-platform-commons:jar:1.9.1:test
[INFO] | | \- org.apiguardian:apiguardian-api:jar:1.1.2:test
[INFO] | +- org.junit.jupiter:junit-jupiter-params:jar:5.9.1:test
[INFO] | \- org.junit.jupiter:junit-jupiter-engine:jar:5.9.1:test
[INFO] | \- org.junit.platform:junit-platform-engine:jar:1.9.1:test
[INFO] +- org.mockito:mockito-core:jar:4.8.1:test
[INFO] | +- net.bytebuddy:byte-buddy:jar:1.12.16:test
[INFO] | +- net.bytebuddy:byte-buddy-agent:jar:1.12.16:test
[INFO] | \- org.objenesis:objenesis:jar:3.2:test
[INFO] +- org.mockito:mockito-junit-jupiter:jar:4.8.1:test
[INFO] \- org.glassfish.jersey.core:jersey-server:jar:3.1.0-M8:test
[INFO] +- org.glassfish.jersey.core:jersey-common:jar:3.1.0-M8:test
[INFO] | \- org.glassfish.hk2:osgi-resource-locator:jar:1.0.3:test
[INFO] +- org.glassfish.jersey.core:jersey-client:jar:3.1.0-M8:test
[INFO] +- jakarta.annotation:jakarta.annotation-api:jar:2.1.1:test
[INFO] +- jakarta.inject:jakarta.inject-api:jar:2.0.1:test
[INFO] \- jakarta.validation:jakarta.validation-api:jar:3.0.2:test
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
I would guess it is some incompatibility between SLF4J2 and Logback. Perhaps there is yet another (older) slf4j-api on the classpath (ie. inside war file)? I am sure GlassFish doesn't contain this dependency. https://www.slf4j.org/api/org/slf4j/Logger.html#atInfo--
GF6 uses JUL. Addition of another logging framework is not possible on the server level, but you can use whatever you need in you war/ear file - there should go application dependencies. Or to domain's lib dir.
GF7 uses GJULE, which is nearly rewritten original logging, much faster and also with the support for System.Logger. Hypothetically it should be possible even to replace GJULE with custom logging framework, but at this moment we did not test it as we don't need it, see https://glassfish.org/docs/SNAPSHOT/administration-guide.html#administering-the-logging-service
If you followed something like this, that cannot work, because endorsed is dead, see #23383
If you would have some time, could you try GF7? https://download.eclipse.org/ee4j/glassfish/
We have some plans to cover these situation by tests, but it will take some time.
http://localhost:8080/gf6/api/v1
it works, using log.info("BEGIN: {}", "ping");
http://localhost:8080/gf6/api/v2
not works, using log.atInfo().log("BEGIN:")
; java.lang.NoSuchMethodError: 'org.slf4j.spi.LoggingEventBuilder org.slf4j.Logger.atInfo()'
at si.gf6.api.V2.ping(V2.java:18)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:577)
at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:124)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:167)
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:176)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:79)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:475)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:397)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:81)
at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:255)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:244)
at org.glassfish.jersey.internal.Errors.process(Errors.java:292)
at org.glassfish.jersey.internal.Errors.process(Errors.java:274)
at org.glassfish.jersey.internal.Errors.process(Errors.java:244)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:265)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:234)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:684)
at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:394)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:346)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:366)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:319)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:205)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1540)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:217)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:119)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:611)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:550)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:75)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:114)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:332)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:199)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:440)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:144)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:174)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:153)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:196)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:88)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:246)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:178)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:118)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:96)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:51)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:510)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:82)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:83)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:34)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:101)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:535)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:515)
at java.base/java.lang.Thread.run(Thread.java:833)
java.lang.NoSuchMethodError: 'org.slf4j.spi.LoggingEventBuilder org.slf4j.Logger.atInfo()'
at si.gf6.api.V2.ping(V2.java:18)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:577)
at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:134)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:177)
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:176)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:81)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:478)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:400)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:81)
at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:260)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:244)
at org.glassfish.jersey.internal.Errors.process(Errors.java:292)
at org.glassfish.jersey.internal.Errors.process(Errors.java:274)
at org.glassfish.jersey.internal.Errors.process(Errors.java:244)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:265)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:239)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:697)
at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:394)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:346)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:357)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:311)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:205)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1376)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:217)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:120)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:611)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:550)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:75)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:121)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:294)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:187)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:440)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:144)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:174)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:153)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:196)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:88)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:246)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:178)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:118)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:96)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:51)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:510)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:82)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:83)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:101)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:535)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:515)
at java.base/java.lang.Thread.run(Thread.java:833)
even if I remove logback, and only use slf4j-api:2.0.3 I get :
'org.slf4j.spi.LoggingEventBuilder org.slf4j.Logger.atInfo()'
at si.gf6.api.V2.ping(V2.java:18)
It looks like in gf6 distribution there is **slf4j-api:1.*** code to be envoked
The same problem in glassfish-7.0.0-SNAPSHOT-nightly
@Path("v2")
public class V2 {
private static final ch.qos.logback.classic.Logger logger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger("logging");
@GET
public Response ping(){
logger.atInfo().log("BEGIN:");
return Response
.ok("ping pong Jakarta EE 9.1")
.build();
}
}
HTTP Status 500 - Internal Server Error
type Exception report
messageInternal Server Error
descriptionThe server encountered an internal error that prevented it from fulfilling this request.
exception
jakarta.servlet.ServletException: A MultiException has 1 exceptions. They are:
A MultiException has 1 exceptions. They are:
java.lang.NoClassDefFoundError: Could not initialize class si.gf6.api.V2 root cause
java.lang.ExceptionInInitializerError: Exception java.lang.ClassCastException: class org.slf4j.helpers.NOPLogger cannot be cast to class ch.qos.logback.classic.Logger (org.slf4j.helpers.NOPLogger is in unnamed module of loader org.apache.felix.framework.BundleWiringImpl$BundleClassLoader @5d99a54; ch.qos.logback.classic.Logger is in unnamed module of loader org.glassfish.web.loader.WebappClassLoader @3631dea0) [in thread "http-listener-1(1)"]
- It looks like **felix** is doing some magic
- same error in **glassfish-7.0.0-SNAPSHOT-nightly**
❯ mvn dependency:tree
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------------------< si:gf6 >-------------------------------
[INFO] Building gf6-1.0-SNAPSHOT 1.0-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:3.3.0:tree (default-cli) @ gf6 ---
[INFO] si:gf6:war:1.0-SNAPSHOT
[INFO] +- jakarta.platform:jakarta.jakartaee-api:jar:9.1.0:provided
[INFO] +- ch.qos.logback:logback-core:jar:1.4.4:compile
[INFO] +- ch.qos.logback:logback-classic:jar:1.4.4:compile
[INFO] | \- org.slf4j:slf4j-api:jar:2.0.1:compile
[INFO] \- org.projectlombok:lombok:jar:1.18.24:provided
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3)
// Source File Name: Logger.java
package org.slf4j;
import org.slf4j.event.EventConstants;
import org.slf4j.event.Level;
import org.slf4j.spi.DefaultLoggingEventBuilder;
import org.slf4j.spi.LoggingEventBuilder;
import org.slf4j.spi.NOPLoggingEventBuilder;
// Referenced classes of package org.slf4j:
// Marker
public interface Logger
{
...
public LoggingEventBuilder atLevel(Level level)
{
if(isEnabledForLevel(level))
return makeLoggingEventBuilder(level);
else
return NOPLoggingEventBuilder.singleton();
}
....
....
...
public LoggingEventBuilder atInfo()
{
if(isInfoEnabled())
return makeLoggingEventBuilder(Level.INFO);
else
return NOPLoggingEventBuilder.singleton();
}
}
// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3)
// Source File Name: SubstituteLogger.java
package org.slf4j.helpers;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Queue;
import org.slf4j.Logger;
import org.slf4j.Marker;
import org.slf4j.event.*;
import org.slf4j.spi.LoggingEventBuilder;
// Referenced classes of package org.slf4j.helpers:
// NOPLogger
public class SubstituteLogger
implements Logger
{
public SubstituteLogger(String name, Queue eventQueue, boolean createdPostInitialization)
{
this.name = name;
this.eventQueue = eventQueue;
this.createdPostInitialization = createdPostInitialization;
}
public LoggingEventBuilder atLevel(Level level)
{
return _mthdelegate().atLevel(level);
}
....
...
public void log(LoggingEvent event)
{
if(isDelegateEventAware())
try
{
logMethodCache.invoke(_delegate, new Object[] {
event
});
}
catch(IllegalAccessException illegalaccessexception) { }
catch(IllegalArgumentException illegalargumentexception) { }
catch(InvocationTargetException invocationtargetexception) { }
}
public boolean isDelegateNOP()
{
return _delegate instanceof NOPLogger;
}
....
}
WEB-INF/lib/slf4j-api-2.0.1.jar
version in war@sysmat Why is felix providing a NOPLogger?
Anyhow, my guess would be that an implementation of org.slf4j.Logger is somehow "leaking" into your application where the exception is thrown. This implementation was compiled with Logger
interface of type org.slf4j.Logger@V1 and not org.slf4j.Logger@V2.
private final static Logger LOG = LoggerFactory.getLogger(V1.class);
, it worksprivate final static Logger LOG = LoggerFactory.getLogger(V2.class);
StandardWrapperValve[si.gf6.JakartaRestConfiguration]: Servlet.service() for servlet si.gf6.JakartaRestConfiguration threw exception
java.lang.NoSuchMethodError: 'org.slf4j.spi.LoggingEventBuilder org.slf4j.Logger.atLevel(org.slf4j.event.Level)'
at si.gf6.api.V2.ping(V2.java:17)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:577)
at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:124)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:167)
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:176)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:79)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:475)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:397)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:81)
at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:255)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:244)
at org.glassfish.jersey.internal.Errors.process(Errors.java:292)
at org.glassfish.jersey.internal.Errors.process(Errors.java:274)
at org.glassfish.jersey.internal.Errors.process(Errors.java:244)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:265)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:234)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:684)
at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:394)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:346)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:366)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:319)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:205)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1540)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:217)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:119)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:611)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:550)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:75)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:114)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:332)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:199)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:440)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:144)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:174)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:153)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:196)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:88)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:246)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:178)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:118)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:96)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:51)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:510)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:82)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:83)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:34)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:101)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:535)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:515)
at java.base/java.lang.Thread.run(Thread.java:833)
The jar file modules/webservices-osgi.jar, part of Eclipse GlassFish 6.2.5, contains class files from the org.slf4j
package. My guess is that those class files are leaking into your REST service.
@sysmat Can you please remove or at least shorten the decompiled Java files in your comments? They are quite long and don't shed much light on to the matter.
@ceki thx, then something Eclipse GlassFish 6.2.5 is the problem
Thanks, there is
version=1.7.30
groupId=org.slf4j
artifactId=slf4j-api
in modules/webservices-osgi.jar
Can we expect a GF 6 version/patch without the included slf4j-api in this module?
@dmatej org.slf4j:slf4j-api:2.0.3 has all the methods and extra as org.slf4j:slf4j-api:1.7.30, I think slf4j-api should be upgraded or removed
I should search slf4j-api in all GF6 installation folder it would be obvious
SLF4J is not a part of GlassFish, but for some reason these classes were integrated to GF6 webservices-osgi.jar as you already found.
We can try to backport changes from GF7 to GF6, but I am not sure about consequences. If GF7 does the same ... the dependency had to move - If I remember well, it was a transitive dependency of some jboss artifact.
So ... another option is to touch osgi properties or boot classpath. Or we could add support for both SLF4J1 and 2, so it would provide roof for both ... but I would prefer rather kick it out, if it is possible. First we have to find it in GF7, because it is not in this jar file.
I got it ...
[INFO] \- org.apache.santuario:xmlsec:jar:3.0.1:compile
[INFO] \- org.slf4j:slf4j-api:jar:1.7.36:compile
For your information, in GlassFish 7.0 M8 Web Profile, there are no jar files containing classes in the org.slf4j
package.
As for GlassFish 7.0 M8 Full Platform, classes in the org.slf4j
package can be found in modules/webservices-extra-xmlsec.jar
. It is not clear to me how this matches the findings by @dmatej.
For your information, in GlassFish 7.0 M8 Web Profile, there are no jar files containing classes in the
org.slf4j
package.As for GlassFish 7.0 M8 Full Platform, classes in the
org.slf4j
package can be found inmodules/webservices-extra-xmlsec.jar
. It is not clear to me how this matches the findings by @dmatej.
Same, these jars are repackaged dependencies with some additional osgi and hk2 files. I hope I will fix that this week, but now I have too many things on the table. Or you can create a pr and we will see if it is possible to just exclude slf4j and pass all tests, or replace it with the newer version.
Same, these jars are repackaged dependencies with some additional osgi and hk2 files. I hope I will fix that this week, but now I have too many things on the table. Or you can create a pr and > we will see if it is possible to just exclude slf4j and pass all tests, or replace it with the newer version.
Dealing with such class loader issues is not exactly for the faint of heart. Thank you for the PR proposal. However, I am not going to attempt such an adventure in an unknown code base.
As far as I can tell, the least-headache inducing approach would be to remove slf4j from the server modules, assuming that is possible.
I hit the same issue in Payara (https://github.com/payara/Payara/issues/5898). As a workaround I'm repackaging xmlsec.jar and webservices-extra-xmlsec.jar into one module so that slf4j-api isn't exposed to applications.
I hit the same issue in Payara (payara/Payara#5898). As a workaround I'm repackaging xmlsec.jar and webservices-extra-xmlsec.jar into one module so that slf4j-api isn't exposed to applications.
Hmmm, seems that's the only option except going to Sanctuario, fork it, replace SLF4J with System.Logger and wait for the release (if committers would agree).
Just FYI, I started working on xmlsec to abandon SLF4J and use System.Logger instead.
@dmatej As far as I understand, the issue was not use of SLF4J but bundling of SLF4J classes within xmlsec.jar.
@dmatej As far as I understood. the issue was not use of SLF4J but bundling of SLF4J classes within xmlsec.jar.
That is not possible without "scratching by foot behind the ear" = repackaging dependencies together and restricting osgi dependencies. That would still hit embedded, because embedded doesn't use osgi and SLF4J is still a mandatory dependency. Maybe it would be possible to use Java modules instead, but there are other dependencies which is not possible to use in the modular system. That will be target for GF8, long way to go.
I loved SLF4J for years, but in situations like this and when I have System.Logger available it is better to avoid it in generic libraries like santuario xmlsec. The less dependencies the better.
On the other hand, soon it should be possible to replace JUL/GJULE with Logback or any other impl, with some limitations.
So ... on monday I am continuing with this, sorry, I was interrupted by more serious issue ;)
@dmatej Still not working on glassfish 7.0.2
@dmatej Still not working on glassfish 7.0.2
True, I have to do something with the xmlsec pr, which is a blocker of this.
slf4j 2.0.7 is released, it is better for OSGI, maybe this will help
We are migrating to glassfish 7. We were facing the issue where slf4j logging was not working. This was the blocker for us because we could not see any logs. We checkout slf4j branch and used glassfish application from there. It fixed the logging issue for us that helped us in migration. We need the fix to be merged into master branch. Could you please merge it.
We are migrating to glassfish 7. We were facing the issue where slf4j logging was not working. This was the blocker for us because we could not see any logs. We checkout slf4j branch and used glassfish application from there. It fixed the logging issue for us that helped us in migration. We need the fix to be merged into master branch. Could you please merge it.
It will take some time, after 6 months my PR to xmlsec was finally merged, but we are still waiting for the final release of the project; Then is required yet Metro WS release, that is inside Eclipse organization, so it could be faster, and then finally we can merge this branch in GlassFish. Meanwhile someone could try to resolve that issue with OSGI configuration, as @sysmat suggested?
in which glassfish version is this fixed?
in which glassfish version is this fixed?
7.0.10 will contain the fix. The fix was recently committed.
p.s. you can try the fix if you want in the latest build here: https://ci.eclipse.org/glassfish/job/glassfish_build-and-test-using-jenkinsfile/job/master/lastSuccessfulBuild/artifact/bundles/glassfish.zip
Environment Details
GlassFish Version (and build number): 6.2.5 (build 6.x-b66-g0159b68 2022-02-12T17:39:59+0000).
JDK version:11
OS: Linux Ubuntu
Problem Description
I am trying to use slf4j-api with Logback on Glassfish 6.2.5.
I copied logging jars to
glassfish/lib
folder as I did with older versions (I come from Payara 4):When I deploy the web app, the logging calls through slf4j logger calls are either:
a) ignored, as if they are a NO-OP (ie.
log.info("OK");
) .b) If I use newer methods from slf4j-api 2.x only (like
log.atInfo().log("OK:");
) I getWhich indicates the jar is not even loaded.
Is this expected and how to ensure my slf4j-api jar is being loaded?