onApplicationStart() not firing

111 views
Skip to first unread message

Phil Cruz

unread,
Aug 10, 2016, 12:40:04 PM8/10/16
to Lucee
I'm migrating an app from ACF to Lucee 5 on Windows. I was hitting some errors where some application variables I was trying to reference where not being defined. I tracked it down and it seems that onApplicationStart() was not firing. I simplified the  function to

public boolean function onApplicationStart()
 
{
 writeLog
(text="Application #this.name# started!!!", file="application", type="Debug", application="no");
 
return true;
 
}

When I restart the Lucee server and make the first request I don't get an entry in the log file. I'm looking in the correct log and I can see other log statements written there. 

If I hit a page that calls applicationStop(), then on the next request onApplicationStart() is called and I see the log entry. But why would it not be called on the very first request?


Michael Offner

unread,
Aug 10, 2016, 1:26:51 PM8/10/16
to lucee
i just did a testcase based on your input , i have the test make a little bit clearer.
component {
this.name=createUUID();
public boolean function onApplicationStart() {
  throw "start";
  return true;
  }
}
to be sure i have a new application context with every request i change the name (red) with every request and then i throw an exception (blue), because writing to the log can have a delay (for performance reasons).
this works as expected for me.
to be honest it is unlikely that the onApplicationStart does not work in that way, this would break every second application out there.
i will add a testcase that checks if onApplicationStart and onApplicationStart get invoked correctly.

Micha












--
Get 10% off of the regular price for this years CFCamp in Munich, Germany (Oct. 20th & 21st) with the Lucee discount code Lucee@cfcamp. 189€ instead of 210€. Visit https://ti.to/cfcamp/cfcamp-2016/discount/Lucee@cfcamp
---
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/c327b50e-53db-4959-b819-a40207ac407e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Phil Cruz

unread,
Aug 10, 2016, 1:33:11 PM8/10/16
to Lucee
Yes, when I create a simple test app I get the expected behavior. 

I'm only seeing this in my app that I'm converting from ACF. For now, I'm doing this 

public boolean function onRequestStart()
 
{
 
//Lucee 5 is not firing onApplicationStart on first request so we need to check if the application has been initialized
 
if (not isDefined('application.beanFactory'))
 
{
 applicationStop
();
 
return true;
 
}
}

which works but is not ideal of course. 

Any ideas how I can debug/troubleshoot why it's not firing?

-Phil

On Wednesday, August 10, 2016 at 10:26:51 AM UTC-7, Micha wrote:
i just did a testcase based on your input , i have the test make a little bit clearer.
component {
this.name=createUUID();
public boolean function onApplicationStart() {
  throw "start";
  return true;
  }
}
to be sure i have a new application context with every request i change the name (red) with every request and then i throw an exception (blue), because writing to the log can have a delay (for performance reasons).
this works as expected for me.
to be honest it is unlikely that the onApplicationStart does not work in that way, this would break every second application out there.
i will add a testcase that checks if onApplicationStart and onApplicationStart get invoked correctly.

Micha











On Wed, Aug 10, 2016 at 6:40 PM, Phil Cruz <ph...@philcruz.com> wrote:
I'm migrating an app from ACF to Lucee 5 on Windows. I was hitting some errors where some application variables I was trying to reference where not being defined. I tracked it down and it seems that onApplicationStart() was not firing. I simplified the  function to

public boolean function onApplicationStart()
 
{
 writeLog
(text="Application #this.name# started!!!", file="application", type="Debug", application="no");
 
return true;
 
}

When I restart the Lucee server and make the first request I don't get an entry in the log file. I'm looking in the correct log and I can see other log statements written there. 

If I hit a page that calls applicationStop(), then on the next request onApplicationStart() is called and I see the log entry. But why would it not be called on the very first request?


--
Get 10% off of the regular price for this years CFCamp in Munich, Germany (Oct. 20th & 21st) with the Lucee discount code Lucee@cfcamp. 189€ instead of 210€. Visit https://ti.to/cfcamp/cfcamp-2016/discount/Lucee@cfcamp
---
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com.

Michael Offner

unread,
Aug 10, 2016, 1:46:56 PM8/10/16
to lucee
I assume that the application context already exists and because of that it is not fired. Have you more than one application.cfc file with the same name inside your application?

There is one known difference to ACF when it comes to search the application.cfc.
let say you have the following mappings
----------------------------------------------------
- virtual: /susi/sorglos
- physical: /Users/urs/mappings/sorglos
----------------------------------------------------
- virtual: /susi/
- physical: /Users/urs/mappings/susi
----------------------------------------------------

and the webroot is at:
- physical: /Users/urs/webroot

When you now call /susi/sorglos/index.cfm in your browser. ACF will search the application.cfc in the following order in the following locations:
- /Users/urs/mappings/sorglos
- /Users/urs/mappings
- /Users/urs
- /Users
- /

so ACF simply goes up from the first location up to the root of the server.

Lucee on the other side will do this:
- /Users/urs/mappings/sorglos
- /Users/urs/mappings/susi
- /Users/urs/webroot

So lucee follows the logic of the mappings.
This is the onl difference to ACF i'm aware of

Micha



















To unsubscribe from this group and stop receiving emails from it, send an email to lucee+unsubscribe@googlegroups.com.

To post to this group, send email to lu...@googlegroups.com.

Michael Offner

unread,
Aug 10, 2016, 3:37:51 PM8/10/16
to lucee
FYI i have added a tstcase for the applcation.cfc start listeners

Micha

Gert Franz

unread,
Aug 10, 2016, 4:01:59 PM8/10/16
to lu...@googlegroups.com
Hi Phil,

Can you please post your application.cfc here if possible? I have a suspicion...

Gert

Sent from somewhere on the road

Phil Cruz

unread,
Aug 10, 2016, 5:29:58 PM8/10/16
to Lucee
I found the issue! If this.ormenabled = true; the event does not fire. If this.ormenabled =false it does fire. I stripped down my Application.cfc to the bare minimum removing everything until I got the event to fire Here is the code

component output
="false"{


 
this.name = "myapp";
 
this.ormenabled = false;
 
this.ormsettings = {
 datasource
="mydsn",
 cfclocation
="/components",
 eventHandling
= true,
 automanageSession
= false,
 flushatrequestend
= false,
 logsql
= false,
 dialect
= "MicrosoftSQLServer"
 
};


 
public void function onRequest(required string TargetPage)
 
{
 include arguments
.targetPage;
 
return;
 
}

 
public boolean function onApplicationStart()
 
{
 writeLog
(text="Application started...", file="application", type="Debug", application="no");


 application
.foo = "bar";

 
return true;
 
}

}

Can you confirm that is a bug?

Thanks,
Phil

Michael Offner

unread,
Aug 11, 2016, 4:02:05 PM8/11/16
to lucee
i will extend the testcase with this, can you raise a ticket here:

Thx Micha

To unsubscribe from this group and stop receiving emails from it, send an email to lucee+unsubscribe@googlegroups.com.

To post to this group, send email to lu...@googlegroups.com.

Phil Cruz

unread,
Aug 11, 2016, 4:16:45 PM8/11/16
to Lucee
Reply all
Reply to author
Forward
0 new messages