# Issues clearing application scope

**URL:** <https://dev.lucee.org/t/issues-clearing-application-scope/1974>\
**Category:** google-group-archive\
**Created:** [July 21, 2015, 2:54pm UTC](https://dev.lucee.org/t/issues-clearing-application-scope/1974 "2015-07-21T14:54:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jay\_B](https://dev.lucee.org/user_avatar/dev.lucee.org/jay_b/32/4878_2.png) [@Jay\_B](https://dev.lucee.org/u/Jay_B)\
**Post date:** [July 21, 2015, 2:54pm UTC](https://dev.lucee.org/t/issues-clearing-application-scope/1974/1 "2015-07-21T14:54:24Z")

</div>

I am setting a variable in application.cfc

```
<cfif isdefined("application.Portcullis") eq false>
        <cfset application.Portcullis = 

```

createObject(“component”,“cfc.Portcullis”).init()/\>

In OnRequestStart I have

```
<cfif structKeyExists(url,'reinit')>
        <cfset OnApplicationStart() />
</cfif>

```

So if I add ?reinit=1 to the url the application should restart.

If I make changes to the component, and do a ?reinit=1 -most- of the time,  
this seems to work but some times the only way I can get the changes to  
take effect is to restart the service

I have Inspect Template set to Always, I clear the object cache. I’ve even  
tried deleting the cfc from the server to try throw an error but it doesn’t  
even do that…sometimes.

Any thoughts on why this might be? It’s very frustrating.

---

<div class="post-metadata">

**Author:** ![Adam\_Cameron2](https://dev.lucee.org/letter_avatar_proxy/v4/letter/a/9de053/32.png) [@Adam\_Cameron2](https://dev.lucee.org/u/Adam_Cameron2)\
**Post date:** [July 21, 2015, 4:22pm UTC](https://dev.lucee.org/t/issues-clearing-application-scope/1974/2 "2015-07-21T16:22:10Z")

</div>

> ```
> <cfif structKeyExists(url,'reinit')>
> <cfset OnApplicationStart() />
> </cfif>
> 
> ```

If you want to restart yer app, you really should restart yer app, not just  
call the event handler which runs when the app starts.

Doing things this way is kinda like thinking calling a JS onclick event  
handler will make your actual mouse button depress.

To restart the app… run applicationStop()  
[http://docs.lucee.org/reference/functions/applicationstop.html](http://docs.lucee.org/reference/functions/applicationstop.html). On the  
next request the application will completely restart _properly_.On Tuesday, 21 July 2015 15:54:24 UTC+1, Jay B wrote:

–  
Adam

---

<div class="post-metadata">

**Author:** ![Sean\_Daniels](https://dev.lucee.org/user_avatar/dev.lucee.org/sean_daniels/32/264_2.png) [@Sean\_Daniels](https://dev.lucee.org/u/Sean_Daniels)\
**Post date:** [July 21, 2015, 3:10pm UTC](https://dev.lucee.org/t/issues-clearing-application-scope/1974/3 "2015-07-21T15:10:02Z")

</div>

Maybe add a call to onApplicationEnd() before onApplicationStart() in your reinit block?\> On Jul 21, 2015, at 10:54 AM, Jay B \<@Jay\_B\> wrote:

> I am setting a variable in application.cfc
> 
> ```
> <cfif isdefined("application.Portcullis") eq false>
> <cfset application.Portcullis = createObject("component","cfc.Portcullis").init()/>
> </cfif>
> 
> ```
> 
> In OnRequestStart I have
> 
> ```
> <cfif structKeyExists(url,'reinit')>
> <cfset OnApplicationStart() />
> </cfif>
> 
> ```
> 
> So if I add ?reinit=1 to the url the application should restart.
> 
> If I make changes to the component, and do a ?reinit=1 -most- of the time, this seems to work but some times the only way I can get the changes to take effect is to restart the service
> 
> I have Inspect Template set to Always, I clear the object cache. I’ve even tried deleting the cfc from the server to try throw an error but it doesn’t even do that…sometimes.
> 
> Any thoughts on why this might be? It’s very frustrating.
> 
> –  
> 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](mailto:lucee+unsubscribe@googlegroups.com).  
> To post to this group, send email to [lucee@googlegroups.com](mailto:lucee@googlegroups.com).  
> To view this discussion on the web visit [https://groups.google.com/d/msgid/lucee/195953ec-1590-49ae-9f06-03f84ad12e9d%40googlegroups.com](https://groups.google.com/d/msgid/lucee/195953ec-1590-49ae-9f06-03f84ad12e9d%40googlegroups.com).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
