'No bundle provided' errors after upgrading to Lucee 5.3.10.120 from 5.3.7.48

Hi all,

I’ve recently had a go at upgrading our application to the latest version of Lucee 5.3.10.120, but our application seems to be unhappy with the recent Log4j2 upgrade.

We were already using Log4j2 within our application for our own logging, and it seems now that Lucee is using it also, we have a conflict on our hands. Here’s a stacktrace.

lucee.runtime.exp.NativeException: No Bundle provided
	at java.util.Objects.requireNonNull(Objects.java:228)
	at org.apache.logging.log4j.core.osgi.BundleContextSelector.locateContext(BundleContextSelector.java:137)
	at org.apache.logging.log4j.core.osgi.BundleContextSelector.getContext(BundleContextSelector.java:124)
	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:230)
	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:47)
	at org.apache.logging.log4j.LogManager.getContext(LogManager.java:176)
	at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:666)
	at com.redacted.redacted.logging.Logger.getCfmlLogger(Logger.java:33)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at lucee.runtime.reflection.pairs.MethodInstance.invoke(MethodInstance.java:56)
	at lucee.runtime.java.JavaObject.call(JavaObject.java:265)
	at lucee.runtime.java.JavaObject.call(JavaObject.java:287)
	at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:787)
	at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1775)
	at components.logger_cfc$cf.udfCall(/redacted/components/Logger.cfc:75)
	at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112)
	at lucee.runtime.type.UDFImpl._call(UDFImpl.java:350)
	at lucee.runtime.type.UDFImpl.call(UDFImpl.java:223)
	at lucee.runtime.type.scope.UndefinedImpl.call(UndefinedImpl.java:786)
	at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:787)
	at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1775)
	at components.logger_cfc$cf.udfCall(/redacted/components/Logger.cfc:13)
	at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112)
	at lucee.runtime.type.UDFImpl._call(UDFImpl.java:350)
	at lucee.runtime.type.UDFImpl.call(UDFImpl.java:223)
	at lucee.runtime.ComponentImpl._call(ComponentImpl.java:696)
	at lucee.runtime.ComponentImpl._call(ComponentImpl.java:584)
	at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1931)
	at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:787)
	at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1775)
	at application_cfc$cf.udfCall(/Application.cfc:266)
	at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112)
	at lucee.runtime.type.UDFImpl._call(UDFImpl.java:350)
	at lucee.runtime.type.UDFImpl.call(UDFImpl.java:223)
	at lucee.runtime.ComponentImpl._call(ComponentImpl.java:696)
	at lucee.runtime.ComponentImpl._call(ComponentImpl.java:584)
	at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1931)
	at lucee.runtime.listener.ModernAppListener.call(ModernAppListener.java:444)
	at lucee.runtime.listener.ModernAppListener.onApplicationStart(ModernAppListener.java:306)
	at lucee.runtime.PageContextImpl.initApplicationContext(PageContextImpl.java:3168)
	at lucee.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:122)
	at lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:44)
	at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2493)
	at lucee.runtime.PageContextImpl._execute(PageContextImpl.java:2478)
	at lucee.runtime.PageContextImpl.executeCFML(PageContextImpl.java:2449)
	at lucee.runtime.engine.Request.exe(Request.java:45)
	at lucee.runtime.engine.CFMLEngineImpl._service(CFMLEngineImpl.java:1216)
	at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:1162)
	at lucee.loader.engine.CFMLEngineWrapper.serviceCFML(CFMLEngineWrapper.java:97)
	at lucee.loader.servlet.CFMLServlet.service(CFMLServlet.java:51)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:836)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1839)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException: No Bundle provided
	... 76 more

Here’s a snippet of the CFML code which calls Java for a bit more context. Basically we provide a name of the programming for logging purposes.

	private Object function getLogger() {
		return javaLogger.getCfmlLogger((isDefined("request.targetpage") ? request.targetPage : "Application"));
	}

This then calls this Java function.

	/**
	 * Retrieves the logger based on the provided string, used for Cfml logging
	 *
	 * @param programName The Cfml program name to use for logging
	 * @return The Logger appropriate for the program
	 */
	public static org.apache.logging.log4j.Logger getCfmlLogger(String programName) {
		return LogManager.getLogger(programName);
	}

What I’m finding is that Log4j2 in Lucee 5.3.10.120 is now running in some kind of OSGI mode. This can be seen in the difference in the stacktrace when using the older version of Lucee, 5.3.7.48 (which we’re currently using in PROD). Note the ‘ClassLoaderContextSelector’ class instead of the BundleContextSelector seen in the new version.

5.3.7.48 stacktrace.

I admit we’re using Lucee and Java in a slightly unusual way, and probably using Log4j2 independently in applications would be rare. All of our application jars are served from WEB-INF/lib which I don’t think should be an issue.

Anyone familiar with Log4j2 / OSGI that could shed some light on how to solve this? Perhaps there is a way we can prevent the use of the BundleContextSelector?

Don’t forget to tell us about your stack!

OS: Windows 10
Java Version: 1.8.0_312 (Temurin) 64bit
Tomcat Version: Apache Tomcat/9.0.20
Lucee Version: Lucee 5.3.10.120

Can’t say anything about this, but how are you creating the Javalogger instance? Can you show some code?

Not a lot to it, just a member variable against the CFML component.

/**
*	Interface for Log4j2
*/
component name="Logger" {

	javaLogger = createObject("java","com.redacted.redacted.logging.Logger");

...

I’d try creating that object by adding the jars explicit path of the library you are using. May be there is something coliding with other loaded jars.

Something like

javaLogger = createObject("java","com.redacted.redacted.logging.Logger", "path/to/your/used/library.jar");

Hi Andreas,

Apologies, only just getting around to trying this.
It didn’t work, but that’s because that Logger is our own. Inside that logging class we import…
import org.apache.logging.log4j.LogManager;
…which would be the same class as what Lucee uses now.

Not sure where to go from here, but we’re in no huge hurry to upgrade Lucee right now anyway.

Thanks for your time.
Cheers,
Glen

I would test and wait until Lucee 6, which is in beta. Its faster, has many bug fixes and security enhancements that do pass security testing.