Need Help Getting Started With Application.cfc

I’m completely new to Lucee. I’m trying to get my app to work but I’m having some difficulties instantiating objects in the Application.cfc file.

I would like to know if anyone would mind sharing some code examples of how to set up the Application.cfc and particularly how to instantiate objects (using the CreateObject() function) inside that file and assigning those objects to the application scope. We also have a great deal of conditional logic contained in our Application.cfc files to help determine environment variables etc.

Below is a code example of how I’m trying to create an object.

boolean function onApplicationStart(){
set getCerts = CreateObject(“component”, “cfc.get_certs”);

    return true;

This code gives me the following error:
Missing [;] or [line feed] after expression

Don’t forget to tell us about your stack!

OS: Mac OSX 10.14.6
Java Version: 1.8.0_251
Tomcat Version: 8.5.58
Lucee Version:

you don’t need (cf)set in script!

getCerts = CreateObject(“component”, “cfc.get_certs”);

thanks so much! This seems to have helped getting it to move forward. Now all i get is a blank page so i can’t tell if the object was actually created. So if i want to dump it out is it just a simple dump? ?

You’ll need to scope the object variable. Here’s slightly simpler syntax.

void function onApplicationStart(){
  application.getCerts = New cfc.get_certs();

Thanks to all who replied. This was helpful (I think). I actually think it did work but I can’t tell. When this gets to my display page i just get a blank page. I’ve tried dumping the object like this:

But I’m getting the following error (with or without the tags:
Syntax Error, Invalid Construct

use the code button when posting code :slight_smile:

the first 5 or so lines of the java stacktrace are always useful to include