Application.cfc onError not trapping errors

OS: Windows Server 2012 R2 Standard
Java Version: 11.0.7
Tomcat Version: 9.0.35
Lucee Version: Lucee 5.3.7.47
We recently updated Tomcat and Lucee to these specs. The applications use a mixture of cferror in Applicationcfm and onError in Application.cfc. We have some error handling code that displays a friendly page and records the error.
After the upgrade errors are not being handled by the onError function. It is just dumping the error our to the screen.
Can anyone think of why this might be happening? I’ve gone through the code and made sure there are no catches with dumps in them. I’ve checked the debug settings and verified it should not be outputting errors.
In Lucee Administrator the settings for Error handling are the default installation values (nothing oddball).
This “was working before” in version 3.5. It seems to have stopped working in version 5.3. If anyone has any ideas of what I can try, please let me know. I’ve run out of ideas to try.
Thanks!

Tim, the classic explanation for a situation like that (in cf or lucee) is that the onerror method itself has an error. When that happens, cf/lucee just displays the error on screen (assuming there’s no site wide error handler defined to handle it).

Have you tried just putting a cfabort or abort script statement as the first executable line in the method? If you do, does it change from the error screen to a blank page? If so, there’s an error in the method.

Beyond that, try also removing all in the method BUT an abort, in case it’s not a runtime error.

I realize this will only help find WHAT is the source of the problem, not WHY it became an error after your updates. But you say you’re “out of ideas”, so it’s a start. :slight_smile:

And should none of this pan out, then if you feel/fear it’s a systemic problem due to the updates, you could prove it by removing any impact of your app: create a new test folder with its own application.cfc, and in that define ONLY an onerror method, with as little as possible. Then create a test.cfm page to trigger a simple error. What happens then? I appreciate that it may seem like a lot of work.

Maybe someone else with awareness of some specific known lucee problem may chime in.

I agree with @carehart re: error in the error-handler. We’ve had situations like that, and the way that I end up dealing with it is to create a “fatal error handler” in the Application.cfc itself that uses more bullet-proof error logging. So that my onError() method looks like this (pseudo code):

public void function onError() {
	try {
		// .... do some business logic stuff.
	} catch ( any fatalError ) {
		this.logFatalError( fatalError );
	}
}

// Log the errors that were thrown while trying to log the errors.
private void function logFatalError( error ) {
	systemOutput(
		serializeJson({
			error_message: "fatal error",
			root_error: error
		}),
		true,
		true
	);	
}

Since we use the system-output to log everything to the standard-out, this is just a low-level logging method that avoids using any ColdFusion components / loggers. It’s kind of the last mile effort to get something about the error logged.

Good idea there, Ben. Of course, for anyone who goes that route, note that the key is to ensure that this “last mile” handler is kept as simple as possible so as not to never itself fail. :slight_smile: That’s of course implied by what Ben shows, but I just want to reinforce that point.

It’s so easy for folks to add “just a bit more” , thinking “this should never fail”…only to find that some unexpected problem later arises that makes it fail, and now it’s back to dumping the error on screen. :slight_smile:

2 Likes

Thank you both for your help. Charlie, your suggestion for stripping the application down into it’s own bare bones application helped.
What I was able to determine is that Application.cfc has THIS.name, THIS.sessionmanagement, etc. So it is defining the application where it should be. Further down in Application.cfc we include a cfm file that sets more application settings. Within that include we also have and so on.
Once I commented out the <cfapplication tag the onError method in Application.cfc was working again.
So I guess having the two ways of defining the application settings, one in Application.cfc and one with the <CFAPPLICATION tag was breaking Lucee. I’m not sure why it was working before. But it makes sense that Lucee wouldn’t like two applications defined.

So I think the solution in my case it to get rid of the old <CFAPPLICATION tags and just use the setup settings in Application.cfc.

Thanks again for your help.

Glad to help, and to hear that your problem is resolved.