Javasettings loadpath only working in first context/app

|Version |Lucee 6.1.1.118|
|Version Name |Gelert|
|Release date |Nov 11, 2024|
|Loader Version |6.0.3.1|
|Servlet Container |Apache Tomcat/9.0.89|
|Java |11.0.23 (Eclipse Adoptium) 64bit|
|OS |Windows Server 2022 (10.0) 64bit|
|Architecture |64bit |

Works fine in 6.0.3.1.

We have a mapping in lucee admin “/global”

We have several sites applications.cfc using:

   THIS.javaSettings = {
    	loadPaths = ["/global/lib/sides/sides-1.0.17.jar"]
    };

We call site 1 and the objects create successfully.

If we call the exact same code in site 2 we throw an exception:

If restart services and call site 2 first it works correctly. Then call site 1 and it fails with same error.

Only the first context loaded appears to work.

The complete code to create the objects:

<cfset VARIABLES.PDDocument = CreateObject("java", "org.apache.pdfbox.pdmodel.PDDocument", "/global/lib/sides/sides-1.0.18.jar") />
		<cfset VARIABLES.PDDocumentInformation = CreateObject("java", "org.apache.pdfbox.pdmodel.PDDocumentInformation", "/global/lib/sides/sides-1.0.18.jar") />
		<cfset VARIABLES.PDPageContentStream = CreateObject("java", "org.apache.pdfbox.pdmodel.PDPageContentStream", "/global/lib/sides/sides-1.0.18.jar") />
		<cfset VARIABLES.PDPageContentStreamAppendMode = CreateObject("java", "org.apache.pdfbox.pdmodel.PDPageContentStream$AppendMode", "/global/lib/sides/sides-1.0.18.jar") />
		<cfset VARIABLES.PDType1Font = CreateObject("java", "org.apache.pdfbox.pdmodel.font.PDType1Font", "/global/lib/sides/sides-1.0.18.jar") />
		<cfset VARIABLES.pdfTextMatrix = CreateObject("java", "org.apache.pdfbox.util.Matrix", "/global/lib/sides/sides-1.0.18.jar") />
		<cfset VARIABLES.PDExtendedGraphicsState = CreateObject("java", "org.apache.pdfbox.pdmodel.graphics.state.PDExtendedGraphicsState", "/global/lib/sides/sides-1.0.18.jar") />
		<cfset VARIABLES.pdfAccessPermission = CreateObject("java", "org.apache.pdfbox.pdmodel.encryption.AccessPermission", "/global/lib/sides/sides-1.0.18.jar") />
		<cfset VARIABLES.pdfStandardProtectionPolicy = CreateObject("java", "org.apache.pdfbox.pdmodel.encryption.StandardProtectionPolicy", "/global/lib/sides/sides-1.0.18.jar") />

the complete error log:

lucee.runtime.exp.NativeException: No matching Constructor for org.apache.pdfbox.pdmodel.PDPageContentStream(org.apache.pdfbox.pdmodel.PDDocument, org.apache.pdfbox.pdmodel.PDPage, org.apache.pdfbox.pdmodel.PDPageContentStream$AppendMode, boolean, boolean) found at lucee.transformer.dynamic.meta.Clazz.getConstructorMatch(Clazz.java:292) at lucee.transformer.dynamic.DynamicInvoker.createInstance(DynamicInvoker.java:150) at lucee.runtime.reflection.pairs.ConstructorInstance.getResult(ConstructorInstance.java:93) at lucee.runtime.reflection.pairs.ConstructorInstance.invoke(ConstructorInstance.java:59) at lucee.runtime.reflection.Reflector.callConstructor(Reflector.java:889) at lucee.runtime.java.JavaObject.init(JavaObject.java:321) at lucee.runtime.java.JavaObject.call(JavaObject.java:249) at lucee.runtime.java.JavaObject.call(JavaObject.java:282) at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:796) at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1992) at breakdownservices.services.sidesservice_cfc$cf.udfCall5(/com/breakdownservices/services/sidesService.cfc:610) at breakdownservices.services.sidesservice_cfc$cf.udfCall(/com/breakdownservices/services/sidesService.cfc) at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112) at lucee.runtime.type.UDFImpl._call(UDFImpl.java:357) at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:214) at lucee.runtime.type.scope.UndefinedImpl.callWithNamedValues(UndefinedImpl.java:800) at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:875) at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:2024) at breakdownservices.services.sidesservice_cfc$cf.udfCall3(/com/breakdownservices/services/sidesService.cfc:424) at breakdownservices.services.sidesservice_cfc$cf.udfCall(/com/breakdownservices/services/sidesService.cfc) at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112) at lucee.runtime.type.UDFImpl._call(UDFImpl.java:357) at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:214) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:716) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:588) at lucee.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:2052) at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:875) at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:2024) at sides.controllers._view_cfm$cf.call(/global/sides/controllers/_view.cfm:76) at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:1046) at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:940) at lucee.runtime.PageContextImpl.doInclude(PageContextImpl.java:921) at sides.index_cfm$cf.call(/global/sides/index.cfm:10) at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:1046) at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:940) at lucee.runtime.PageContextImpl.doInclude(PageContextImpl.java:921) at virtualaudition.side_cfm$cf.call(/virtualaudition/side.cfm:18) at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:1046) at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:940) at lucee.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:213) at lucee.runtime.listener.ModernAppListener.onRequest(ModernAppListener.java:100) at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2725) at lucee.runtime.PageContextImpl._execute(PageContextImpl.java:2712) at lucee.runtime.PageContextImpl.executeCFML(PageContextImpl.java:2683) at lucee.runtime.engine.Request.exe(Request.java:45) at lucee.runtime.engine.CFMLEngineImpl._service(CFMLEngineImpl.java:1159) at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:1116) 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:623) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:199) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:144) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:168) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:144) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:168) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:481) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:130) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:346) at org.apache.coyote.ajp.AjpProcessor.service(AjpProcessor.java:424) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:928) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1791) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52) at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1190) at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:63) at java.base/java.lang.Thread.run(Unknown Source) Caused by: java.lang.NoSuchMethodException: No matching Constructor for org.apache.pdfbox.pdmodel.PDPageContentStream(org.apache.pdfbox.pdmodel.PDDocument, org.apache.pdfbox.pdmodel.PDPage, org.apache.pdfbox.pdmodel.PDPageContentStream$AppendMode, boolean, boolean) found ... 71 more 

We’ve had similar problems with javaSettings.loadPaths, and our solution has been to not use it. Instead, we’ve used this javaLoader component, which has been much more reliable. JavaLoader/javaloader/JavaLoader.cfc at develop · markmandel/JavaLoader · GitHub

1 Like

I tried with javaloader. I get exactly the same results. 1st site/context works fine. second doesn’t.

I also removed

 THIS.javaSettings = {
    	loadPaths = ["/global/lib/sides/sides-1.0.17.jar"]
    };

from the application.cfc since it seems redundant as createObject contains the path to the jar. Same result.

The only way I got it to work is dropping the jar in /lucee/lib
and removing the paths in the createObjects. Not ideal. this means I can’t update lucee without updating the codebase at the same time and anytime we need ot modify the jar I have to update all our servers lucee/lib.

Like I said. Code worked fine in 6.0.3.1.

Could this be a similar issue as Lucee 5 class loading issues with Thread.currentThread().getContextClassLoader().getResourceAsStream()