I am developing a Lucee extension and am running into an issue when I restart Lucee from both the Lucee GUI and programmatically using the cfadmin
tag. In one part of my extension I need to call createPageContext
on an instance of the CFMLEngine but I get an exception on line 173 of PageContextUtil.java that says Index 0 out of bounds for length 0
From what I can gather is that there is no ServletConfig registered on the engine instance. I will only receive this error after restarting Lucee from the GUI or programmatically. On first boot of the server though everything works great.
The function I am calling that will execute the extension code is inside of the onApplicationStart
method.
In my extension I am using @isapir library GitHub - isapir/lucee-apps: Allows external Java code to interact with Lucee applications and am basing a lot of the extension off of his lucee-websocket extension as well.
I am using the official Lucee docker image lucee:5.3.8.206-nginx
a stack trace and code sample would really help
it sounds like you are doing something too early, before the the context is (re) started ?
1 Like
@bdw429s I believe you may have come across this issue several years ago based on an issue I found. [LDEV-1405] - Lucee you posted a stack trace in the comments which it seems to line up with the outdated version of this file Lucee/core/src/main/java/lucee/runtime/util/PageContextUtil.java at fbb3551d34490bcb643495696885d0668927b615 · lucee/Lucee · GitHub I am having the same issue where it is trying to access a config that isn’t registered with the current thread. Did you ever find a workaround for this?
Nope, never found a work around. And as you can see from the comment thread in that ticket, Micha closed the ticket even though it wasn’t fixed simply because I said I had “given up” on solving a specific part of it.
Can you please provide a stripped down example, I.e a git repo which demonstrates the problem?
Reproducible issues can be addressed…
I wish it were that simple. The problem is that it requires installing NATS Jetstream and setting up a stream and subjects similar to how RabbitMQ works since NATS is a messaging system. I know not everyone is willing to install additional software on their machines to troubleshoot issues for someone else.
You may have luck just using the minimum Java necessary to create a native thread outside of any 3rd party lib.
var CFRunnable = createDynamicProxy(
new CFRunnable(),
[ "java.lang.Runnable" ]
);
var myThread = createObject( "java", "java.lang.Thread" )
.init( CFRunnable );
myThread.start();
// Wait for thread to finish
myThread.join();
And CFRunnable.cfc
has this
component {
function init(){
// Pas anything you need your runnable to have into the constructor and store it here
// The code in this method runs inside of the main HTTP thread
}
function run(){
// The code in this method runs inside of your native Java thread
writeDump( var="Running from Thread-land!", output="console" );
}
}
Now you can put whatever logic you’ve been using to create your page context inside the run()
method of the CFRunnable
component.
Also, a shameless plug for this ticket of mine which would solve all of this nonsense with a built in feature:
https://luceeserver.atlassian.net/browse/LDEV-3960