REST service not starting at server startup

I have a web context that has REST set-up and working just fine. However, when I restart the server that Lucee is running on, I get a 404 "no rest service for [restPath] in mapping [restMapping]. Once I hit any cfm related page on the web context (/index.cfm or even just going to the login page for Lucee admin), then the rest call works just fine. So it seems as though the context isn’t being initialized automatically at server startup, and until it’s initialized the rest service handler isn’t picking up requests.

Lucee Version: Lucee 5.2.9.31
Server OS: Ubuntu 18.04.1 LTS

Hi @eddie_b,

I’ve checked it. After restarting the lucee server (without hitting the login page of lucee admin), rest service works fine for me.

URL: http://localhost:8888/rest/test/system/os
virtual: test
Physical path: C:\Portables\lucee-express-5.2.9.31\webapps\ROOT\rest\

Perhaps this is linux specific then? Because I also don’t encounter this issue when running Lucee on Windows, but when I run it on Ubuntu it seems to surface

I think this is the same as https://lucee.daemonite.io/t/scheduled-tasks-afte-restart/4707/3
I don’t think any internal lucee stuff is functioning correctly until the tomcat context has been created by mod_cfml as they do not persist through restarts.

Thanks for the response, and seems like you’re onto something. Any thoughts on a workaround? Was considering writing a custom start-up script to just send a request to /index.cfm after lucee starts so the tomcat context gets created, but would love if there was a cleaner solution

by any chance is the first request to the REST service a POST?

https://luceeserver.atlassian.net/browse/LDEV-1988

No, it’s a GET request that returns a 404. But as soon as I may a request to any *.cfm page (even one that doesn’t exist), the rest service starts working as expected again.

but isn’t that the default context which always starts when lucee is started? every other lucee context is only loaded after the first request, as this problem demonstrates

My current workaround is a cronjob on a sister machine that hits a wakeup url on the target and vice-versa (they are our dev boxes that get shutdown overnight.

I couldn’t get it to wake itself up (probably something to do with the internal apache mod_cfml proxy stuff) so doing it on a different machine with a sleep 60 seems to work (eg @reboot sleep 60 && wget http://blah.com/wakeup )

Thanks for the tip. Fortunately I was setting up a new environment, and still had the option to go with Windows, so I just opted for that, since it works just fine on Windows without any workarounds.

Really too bad that something so simple keeps me from using my preferred environment, it’s things like this that have me looking into getting off Lucee/CFML entirely.

then it’s time to file a bug, there should be no difference in behaviour between Windows and Linux

Do you mind if I ask what your URI is that you’re hitting? That will affect how Apache/mod_cfml/Tomcat responds. Most likely, this is a simple issue that can be resolved with the right config, but I need to know exactly what you’re attempting to hit before I can point you in the right direction on it.

Hi Jordan,

Thanks for the reply. It’s been a few months now, but I believe I was hitting the url [HOSTNAME]/rest/v1/auth, where [HOSTNAME] was an Apache site for which the Lucee web context operated in.

Hi Eddie,

Did you have your default document set up to be a .cfm file? If not, that would explain why the request wasn’t being passed on to Tomcat/Lucee. The default ProxyPassMatch methods are set to pass files ending in cfm, cfc, or cfml. If you have your default document set you should hit that proxypass method and be properly passed to Tomcat, then Lucee’s REST servlet. Otherwise, Apache will try to resolve it itself, and since the “/rest/” directory doesn’t actually exist, Apache would respond with a 404.

You can set the default document in Apache with the DirectoryIndex directive:

DirectoryIndex index.cfm

Thanks Jordan, however I think the request IS being passed to Tomcat/Lucee, as I get the message

no rest service for [/api/auth/] found

Which I believe is coming from Tomcat/Lucee. I also just tested it out by adding the DirectoryIndex config to apache, and it didn’t appear to have any effect.

It feels like the request is making it to Lucee, but Lucee hasn’t set-up the REST service handlers yet for this particular context.