8 Replies Latest reply on Mar 24, 2013 3:57 PM by Aegis Kleais

    Resetting the application

    Aegis Kleais Level 3

      I've been reading up on CF10's applicationStop() function and something simply isn't clicking as after I use it I get an error that states:

       

      APPLICATION '' DOES NOT EXIST.

       

      And after I remove the code and run the page again, the dump I have shows the old APPLICATION's information (one of the variables in the structure is a 'dateInitialized' which sets the current date into it when the application starts, and it's showing an old date)

       

      I put this code in the APPLICATION.cfc constructor area so that it runs at the beginning of the page load.

       

      I'm assuming my issue here is partly due to where I'm putting the code, but Adobe's page on applicationStop() is not specific as to this.

        • 1. Re: Resetting the application
          Adam Cameron. Level 5

          Instead of describing your code, can you post it?

           

          --

          Adam

          • 2. Re: Resetting the application
            Aegis Kleais Level 3

            Yeah, but in this case it seems like explaining it would be better than cutting and pasting the 1000+ lines of my Application.cfc file.

             

            application.cfc:

            <cfcomponent

                 output="false">

             

                 <cfset applicationStop() />

             

                 <!--- Variables, Methods and other Application.cfc stuff here. --->

             

            </cfcomponent>

             

            So basically I added the applicationStop() line, reloaded the page.  Removed it and reloaded the page again, and the application seems to persist rather than being stopped.

            • 3. Re: Resetting the application
              Adam Cameron. Level 5

              Well that's a bit obtuse. Obviously not all 1000 lines of the Application.cfc are going to be relevant here, are they? You should be able to pare the code back to what's giving you the problems.

               

              More reading:

              http://adamcameroncoldfusion.blogspot.co.nz/2012/12/need-help-know-how-to-ask-for-it.html

               

              And are you telling me you have a call to applicationStop() in your Application.cfc's pseudo-constructor?

               

              How is that ever supposed to do anything useful, given that code is run on every request..?

               

              --

              Adam

              • 4. Re: Resetting the application
                Aegis Kleais Level 3

                Adam, to be short with you here and stop another fight between the both of us, yes, my code may be wrong, but no, I did not ask the question in the wrong manner.

                 

                As you can see by the code that I JUST gave you, it is no different than how I explained it in my previous post.  It is code I put immediately after the opening <cfcomponent> tag in the application.cfc file outside of all functions.  I even stated that I checked on Adobe's OFFICIAL information about this feature, and it made no discernment on where the code can and cannot be placed.

                 

                If *you* understand that this won't work because you have some knowledge about how code in this particular area of the file functions, it should be well within the area of expectation that not everyone shares that knowledge.

                 

                How else can I give you the code you're asking for in the manner that you're wanting.  If I literally cut and paste the application.cfc file into this response, it looks exactly like I coded (sans the comment that indicates that the methods and constructor code area immediately after it).

                • 5. Re: Resetting the application
                  Aegis Kleais Level 3

                  I've found that placing the code into the onRequestStart() seems to execute the method.  So even though I don't know why it's not working where I had it, if it at least works by doing it this way, I'll just leave it at that.  It's not comprehension, but it solves the problem.

                  • 6. Re: Resetting the application
                    Adam Cameron. Level 5

                    The code you posted was fine. My reference to you beig obtuse was related to your comment regarding posting the entire 1000 lines of Application.cfc in there. Which was an obtuse comment to make. Still, if that's what you thought you might need to do, then the link I sent you would be useful for you to work out what code one ought to post when asking a question.

                     

                    Your code might well have been exactly as you described, but when yuo're just describing it, we don't know this. Hence just posting the code is the best aproach (and then explaining the code if it's not clear as well can help).

                     

                    I asked you how you expected having applicationStop() running every request was likely to do something you wanted it to because it seemed like a reasonable question. Think it through: the code in the pseudo constructor is run on every request. So on every request, you are calling applicationStop(). Does that sound like what you wanted to be doing?

                     

                    --

                    Adam

                    • 7. Re: Resetting the application
                      Adam Cameron. Level 5

                      Doesn't this still mean you're running applicationStop() every request?

                       

                      --

                      Adam

                      • 8. Re: Resetting the application
                        Aegis Kleais Level 3

                        I just don't want to overwhelm people with too much information.  I'm a bit usability buff and one of the things I realize about getting help from people is that if I write a wall of text that is very detailed, fewer people (understandably) take the time to respond to it.

                         

                        I'm in development right now.  And even through when my application starts up, it can determine it's in a "development" environment rather than a production one, there have been times where I needed to kill off my application so it would not persist the data and emulate starting up a new application.

                         

                        Since the code seems to have actual effect on the application when placed into the onRequestStart() method, I'll just ensure I'm in development "mode" and check if the URL key 'resetApp' is specified, and if so, stop the application.

                         

                        Still, I wonder why the code doesn't work in the constructor.  Or maybe it would once the application started up.  Gonna do some testing on that to get a better grasp.